PDA

View Full Version : what does mi_call_material really do?


nine020ho
September 28th, 2005, 00:58
In my test scene, I shoot a ray into the scene and hit an object that has a red material on it. I then call mi_call_material on the state and it returns a red color from the surface. If I move the state->point to a different location, I get the color of a different surface, a surface that I have assigned a blue material. Is mi_call_material shooting a ray of its own? And if so, what shader is it using?



Given a position in space and a normal, how do I evaluate the resultColor of a material? mi_call_shader works for tags like file nodes or texture nodes, but it doesn’t evaluate a whole material that is made up of a collection of tags. And since I’m working on a general solution, navigating through the parameters of a material to find out what the “transparency” is connected to is not an option.



Is there a way to evaluate a material on a surface and assume that there are no other objects visible in the scene? Is it possible to turn off the visibility of every object in the scene except for the current one and then turn them all on again?





Here’s a recap of what I’m trying to do.





PROBLEM :

I am shooting rays from a surface into the scene using a light map shader.



If the ray hits an object, I want to determine if the object is transparent ie. the resultColor of calling its shader has an alpha < 1, so that I can march to the next surface and get its normal.



When the mi_trace_transparent function is called and the object is transparent, the object’s material knows that it is transparent and casts its own ray to see what’s behind it and returns a final composited color value.



I am trying to get the material with transparency to either not cast that ray to probe what’s behind it so that I can get the uncomposited alpha value.



FAILED SOLUTIONS :



1. After mi_trace_transparent returns a successful hit, set the state->dir to 0,0,0 and then use mi_call_material. The idea was that when the material was called, it would try to continue the ray that it inherited from state->dir. Since I didn’t care about rgb values (which would likely be 0,0,0 with a zero normal), I hoped to end up with alpha value. This appears not to have worked.

2. It was recommended to me that setting the refraction level to be equal to the trace depth such that the mi_trace_transparent would account for trace and the resulting transparent material would not be allowed to shoot another trace. This too doesn’t seem to work.

3. Assuming that the material called by mi_call_material is actually shooting a ray to see what’s behind it, I thought that if I move the state->point to a location way out in space, where there is nothing behind it, that the material would return the background color, black in my case, and give me the alpha value of the material. This doesn’t work either, which leads me back to the question, what does mi_call_material do?





Once again, thanks for the help that I’ve been receiving. Although I haven’t solved my problem, I’ve learned a bunch.



-Daniel