Shader effect system design

Started by
0 comments, last by Jim1664 11 years, 9 months ago
I am currently working on the shader effect system for my rendering engine and i am not quite sure how to properly design it. A shader effect in my engine describes the shader pipeline configuration for a single rendering effect (this basically means setting the right shaders for each stage and setting the correct shader parameters). What i want to achieve is a system with high flexibility without making it overly complex and unmaintainable.

Having this said, I can't figure out a good way to handle shader parameters that exist in more than one shader but are different in its type. For instance lets say i have a single shader effect which combines a vertex shader which has an parameter "Color" as a vector3 and a pixel shader which also has a parameter "Color" but as a vector4.

The problem is, it would be nice to set the parameters by using a parameter name, but what should i do in case of the example above?

The solutions that came into my mind are the following:

  1. Do not allow a combination of shaders where shader parameters conflict (kind of unflexible)
  2. Ignore shader parameter conflicts and just set the bytes that fit into the parameter / are provided by the application (maybe results in hard to find errors)
  3. Set the parameters per shader and not for the whole shader effect (uncomfortable)


Personally I am not a big fan of any of these solutions, but i think (1) and (2) could be ok. Setting the parameters for every single shader (3) feels a little bit too tiring and uncomfortable.

I am interested in how you handled this problem in your code. Are there any good solutions i have not thought of?

Thanks for your help!
Advertisement
I would do 2, but produce an annoying warning/error if there are parameters with matching names but differing types.

This topic is closed to new replies.

Advertisement