Some time ago I fired off a resource thread and this thread is along those lines but not exactly. Because of this I started a new thread and also just to let the old one die.
For those of you working with shaders I have an important question. How in the world are you rendering with these when:
- Each shader can and will require different parameters.
- Each shader is for a different 'effect' and may also require several textures
For example, I have a shader manager that handles the actual shader objects. I have a central rendering system that, when created, takes all of the objects from my object manager and examines their shader ID. It groups objects with the same shader IDs into lists. These lists simply contain the ID of the object in the game object list. Later during rendering I start with the first shader and render all objects in the first shader list and continue this until all lists are rendered.
In order to speed up rendering and culling each list is culled and placed into a master list. The number of objects per shader is stored so that the rendering system knows when to switch shaders.
This is all fine and well until I attempt to set the parameters of shaders. My default ambient, diffuse, specular shader requires a material containing 3 4D vectors used as color values for light properties. The specular component also contains a specular power factor that must be set. The world/projection matrix must also be sent to the shader as well as textures.
Now I can do some type of checking in the shader to determine if or how many textures are being used up to a maximum of 5 textures. I do not, however, have a way of specifying how each texture stage should be blended together and since you cannot use the output of one shader as the input for another without re-rendering the geometry I'm sort of stuck. How the Direct3D fixed function pipeline created stages for blending is beyond me and perhaps it's not possible with the current shader models.
What I'm lost on is how do I specify that shader X requires certain params and shader Y requires other params? This is quite confusing. All I can come up with is this: