I am integrating some of my existing game entites into my current project which implements shadow mapping. Currently, I bind the ShadowMap texture to GL_TEXTURE0. This forces me to modify the drawing code for my entites to use GL_TEXTURE1. All of this works fine, it’s just that I would prefer to have unified game entity code that works with both shadowing and unshadowing applications. I have pondered passing the texture unit as a parameter to the rendering code.
But my question is: On what texture unit do most people put their shadow map?
I think you expose your geometry state on a too low level to the content code.
Typically, my content code will use an abstract collection of state, that says “here’s my diffuse color map, and here’s my reflectivity map, and here’s my specular modulation color, and by the way, here’s the name of the special effect that I’d like to be rendered with (which maps to shaders)”.
Then, the renderer extracts this data and turns it into actual GL (or DirectX) code. That way, if the shading model changes, you’re isolated. Similarly, if the rendering API changes, you’re isolated. If you abstract “a card with texture units” but not the shading model, you can still change the API, but not the shading model, so that would still be too low level.
In your case, the renderer would have a case for objects with diffuse color map, shadow map, and no enabled lights, and would set it up however seems fit for your renderer. Personally, I almost always put diffuse color in texture unit 0, but there’s no reason for that other than tradition.
Thanks JWatte - That was exactly the information I was looking for…