TGEA dif materials
by Sean H. · in Torque Game Engine Advanced · 11/26/2007 (8:41 am) · 1 replies
I've been messing around with TGEA for the last couple of days. In particular, I've been tweaking the shaders used for dif surfaces. I managed to create a shader/material definition which renders a surface in all red. after working with TGE for so long, it was quite satisfying to finally have the ability to control the rendering of surfaces using a shader. so, I knew the shader was working at least. however, im still having some difficulties working with TGEA.
I have two questions. first of all, is it legal to reuse a shader which is bound to a custom material in other custom materials? I used the same shader for 3 different custom materials and I was getting some weird results. as the viewpoint moved around, textures on surfaces were changing. this makes me think that when you use a custom shader, the shader gets linked to the texture and thus reusing the shader on different surfaces results in textures being swapped.
Secondly, how are texture uniforms defined for dif surfaces? I figured out that texture[0] gets set in register S0. I also know that texture[1] would be used in a separate pass. I'm not clear on how the material definitions determine which textures get bound to which uniform registers. In the default baseinterior shader, I see that the lightmap usually gets set in register S1, and the normal map in register S2. Does this change for custom materials used for dif surfaces? for dif surfaces, is S1 always reserved for the lightmap? also, for a custom material definition for a dif surface, how do I set the normal map in a separate texture unit? I tried using baseTex[0] and bumpTex[0] but that didn't seem to work right. texture[0] works fine for the base texture for a custom material, but I'm not sure how I would then set the normal map texture. if I use bumpTex[0] for normal maps for custom dif materials, should this set the normal map in register S1 or S2, considering that the lightmap is usually set for S1?
any help would be appreciated.
I have two questions. first of all, is it legal to reuse a shader which is bound to a custom material in other custom materials? I used the same shader for 3 different custom materials and I was getting some weird results. as the viewpoint moved around, textures on surfaces were changing. this makes me think that when you use a custom shader, the shader gets linked to the texture and thus reusing the shader on different surfaces results in textures being swapped.
Secondly, how are texture uniforms defined for dif surfaces? I figured out that texture[0] gets set in register S0. I also know that texture[1] would be used in a separate pass. I'm not clear on how the material definitions determine which textures get bound to which uniform registers. In the default baseinterior shader, I see that the lightmap usually gets set in register S1, and the normal map in register S2. Does this change for custom materials used for dif surfaces? for dif surfaces, is S1 always reserved for the lightmap? also, for a custom material definition for a dif surface, how do I set the normal map in a separate texture unit? I tried using baseTex[0] and bumpTex[0] but that didn't seem to work right. texture[0] works fine for the base texture for a custom material, but I'm not sure how I would then set the normal map texture. if I use bumpTex[0] for normal maps for custom dif materials, should this set the normal map in register S1 or S2, considering that the lightmap is usually set for S1?
any help would be appreciated.
Torque 3D Owner Sean H.
Oh, and thanks for all the helpful responses.