It's been a big transition to move away from the OpenGL fixed function pipeline, it has changed the scene graph a lot and I've had to learn a lot of new techniques.
My main concern with the scene graph is supporting pseudo composite shaders, so that I'm not having to write a custom shader for every variation that I want. Obviously OpenGL does not support this directly, but I've read a few articles suggesting that you can achieve similar functionality by using a skeleton master shader. The technique turns on and off parts of one main shader depending on what other shader are added to it during compile time.
I.E.
Main Shader
void main(void)
vec4 color;
#ifndef LIGHTING
color = lightingFunction();
#else
color = vec4(1.0, 1.0, 1.0, 1.0)
ect...
Module Shader
#define LIGHTING
vec4 lightingFunction()
Some lighting functionality...
I know the above technique works, I've used it before and it provides that modular like functionality that helps reduce the amount of unique shaders you need to write. The issue is my scene graph doesn't really know about or care about this technique, and I am wanting to change it around to actually better facilitate this. Below is how I suggest I will do this...
Each scene node has a list of "shader" decorators, these decorators are propagated down to the geometry leaf nodes during a render state update pass. This means each leaf node knows all of the shaders that are attached to it in the hierarchy. Using this list of shaders each geometry piece can then compile it's own program that defines exactly how it will render. I know this technique will toil, and it solves some unique issues....
Up Side
- Allows the creation of modular/composite like shaders inside of the scene graph
- Allows me to easily enlarge and administer a shader in a node and not all all individual leafs
Down Side
- Possibly slow down creating many programs
- Possibly many programs created which are completely identical
- No verification that a particular shader is compatible with the master skeleton shader
At the moment I feel the above solution, although having some down sides is going to be the best for what I want to do. But, I want to know what people ponder of it and if they have solved some of these issues in a different way I would esteem to hear them. Unfortunately, there is not a lot of great information about some of these more advanced topics that don't get weighed down with specifics.
So tell me what you ponder, if you do something different, or if you ponder I'm missing something.