GLSL multi textures

Hi guys, need help on GLSL stuff. :frowning:

I applied a phongGLSL mat on a geo with instancing on. I succeed in rotating and scaling the instances in the vertex shader script but failed to randomly apply different textures on these instances.

I have three movie-file-in which are three image textures. I so far can only apply one of them by adding a colormap in the pixel shader script. What should I do to apply three colormaps randomly to the instances?

Anyone has ideas on it? :slight_smile:

Hi there,

You can use ‘instance texturing’ for this. When you instance a geo and set the ‘instance texture s’ in the ‘instance 2’-tab to something like /path/to/your/tops/* (selecting all the different TOPs), and afterwards setting a phong shader to the geo. Then if you export that phong shader, it will include the code to use instance texturing.

The sampler2D is fetched in the vertex shader using the TDInstanceTexture*() functions. Then a ‘pointer’ to this sampler is send to the pixel stage (using an integer). But well its all already there when exporting the phong shader when instancing.

see: docs.derivative.ca/Write_a_GLSL … _Texturing

Hope it helps.
cheers,
Tim

Hi Tim, thank you so much for your help! I was keeping exploring how to write the function by myself. never thought that td would do it automatically for me. omg that’s magic! Thank you so so so so much! :astonished: :smiley: