My hobby engine has a deferred renderer that supports normal maps and specular maps. Now, some objects may have normal maps, and some may have specular maps. In some cases, an object has both maps, and in some cases, it has neither.
The question is: how should I implement the rendering of these objects? Should I have a render queue for each different object type and render them with separate shaders like this:
Queue A: Objects without normal and specular map Queue B: Objects with normal map, without specular map Queue C: Objects without normal map, with specular map Queue D: Objects with both normal map and specular map // Render loop bind shader for type 'A' objects for each object in Queue A: render object bind shader for type 'B' objects for each object in Queue B: render object // and so forth...
Or, should I use a single shader and bind a "default" normal map and specular map for those objects that do not have such maps? By a default map, I mean for example a normal map texture that's completely colored (128, 128, 255). This would be something like this:
bind shader bind default normal map texture bind default specular map texture for each object in Queue A: render object for each object in Queue B: bind object's normal map render object bind default normal map texture for each object in Queue C: bind object's specular map render object for each object in Queue D: bind object's normal map bind object's specular map render object
Basically, the first approach would involve less texture binds and more shader binds, whereas the second approach would be the opposite. Is either of these a preferred way to approach the problem? Or have I missed something completely here?
You can assume the objects are queued correctly to the queues.