Multi-pass shader questions.
by Jon Wilsdon · in Torque Game Engine Advanced · 12/07/2006 (12:44 pm) · 1 replies
We are trying to get a 4 pass shader working and are having a bit of trouble. We have the shader working fine in RenderMonkey and so the problem is in how to convert it to a shader for the engine. First off, to get the engine to actually do all 4 passes we had to modify the engine slightly (probably breaking something to do with refraction in the process).
In CustomMaterial.cpp around line 440 in the setNextRefractPass() function we removed the following line:
and around line 491 (490 if you remove the previous line first) of that same file in the setupPass() function we also removed the following line:
Without the second change, it would skip pass 1 and try to do pass 2 as the second pass (since it starts with pass 0). Then without the first change it would always set the pass to 1 after the second pass. (That conditional around line 437 really doesn't make much sense to me).
Now that we have it going through all four passes, our problem is that in RenderMonkey the first pass writes color data to a Renderable Texture (as predefined in the Render Monkey project). The second pass writes normal data to another Renderable Texture. The third pass needs to sample the color texture written in first pass, and the fourth pass needs to sample the normal texture written in the second pass. What we can't figure out is how to create the equivalent of the Renderable Textures. Do we need to some how set it up in the engine somewhere, or can we do it all with setting up registers in the shader files? Any ideas?
In CustomMaterial.cpp around line 440 in the setNextRefractPass() function we removed the following line:
mCurPass = i+1;
and around line 491 (490 if you remove the previous line first) of that same file in the setupPass() function we also removed the following line:
mCurPass++;
Without the second change, it would skip pass 1 and try to do pass 2 as the second pass (since it starts with pass 0). Then without the first change it would always set the pass to 1 after the second pass. (That conditional around line 437 really doesn't make much sense to me).
Now that we have it going through all four passes, our problem is that in RenderMonkey the first pass writes color data to a Renderable Texture (as predefined in the Render Monkey project). The second pass writes normal data to another Renderable Texture. The third pass needs to sample the color texture written in first pass, and the fourth pass needs to sample the normal texture written in the second pass. What we can't figure out is how to create the equivalent of the Renderable Textures. Do we need to some how set it up in the engine somewhere, or can we do it all with setting up registers in the shader files? Any ideas?
Torque Owner Thomas Phillips
Tom