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).
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.
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 …