How to know inside a shader what exact object is the shader attached.
-
I created a shader that needs to know exactly what object it is attached to.
So, if a material that contains that shader in, for example, the Color channel, is assigned to different objects, it will produce different results.
I know that the VolumeData contains a list of all objects being rendered and that each object in the VolumeData, obtained by GetObj(i) contains a RayObject that contains the texture_link parameter.
But, inside my shader, I get ALL the objects that include the material that contains the shader.
So, from inside the shader, how can I know what is the exact object that is being rendered? -
I guess I can only make sure I know what is the object being rendered from inside the Output method, as in the InitRender method I can't make sure what is the one being affected.
-
Ok, found out what is wrong.
The code inside the Output is being executed in multiple threads.
So, one thread may be calculating the color of one object but the data I have in my struct is from another object being calculated by another thread.
Is there any way to force a shader to be only calculate in a single thread?
Or, is there any way to get a unique value from each object so that I can store a set of structures in the InitRender method, and detect which one is being rendered in the Output method and use the correct structure of data?