Vertex shader for moving objects on Z-axis

Hi,

I’m trying to move my instanced objects array on Z-axis using shader, the displacement should be read from a TOP.

This is basically what Noise shaders do, except that I don’t map object’s UV positions to the TOP, but instead I want to use vertex [x, y] world coordinates.

I’ve come up with a shader that does that, but can’t map vertex [x, y] position properly. Currently all objects are moving synchronically, likely pointing to the same pixel of the TOP. The shader preview on tour however, looks properly (vertices moving in waves).

I’m attaching the .toe file.
vertex_shader_move_objects.toe (6.89 KB)

Maybe that’s a job for geometry shader? It’s time to do some GLSL tutorials. :slight_smile:

The set of values for P is going to be the same for every geometry rendered, since you are doing instancing. If you want to get the new P after instancing is applied you need to get it out of TDDeform(). Or use the TDInstance* functions more directly if you don’t want the value coming out in world space. That will give you a different value for P and thus texture_position for each object.

How to use TDInstance ?

The documentation for this functions is here:
derivative.ca/wiki099/index … L_Material
Take a look and let me know what needs further clarification.

I managed to apply transformation using
vec4 worldSpacePos = TDInstanceDeform( P + NewPos ), but trying understand how to apply rotation and scale. As in wiki I should use TDInstanceMat(), but I’m missing something …

What is the code you currently have that uses TDInstanceMAT()?

At the moment None . Did not figure out how to apply transofmations to it or with it.
Instancing with texture.16.toe (8.42 KB)