Good day Lagarde,
I had been toying with a system where my classes have a meta data object within them that contains named properties of differing types. These properties can be bound to live variables in the class (or elsewhere) via pointers, or they can contain the value themselves. This enables me to take the meta object from any class and query it to see if it has a property with a certain name.
This then ties into my shader system by having a given shader depend on certain parameters, take for example a simple phong lighting shader. Such a shader might require 'diffuse', 'specular', 'specular level' and a 'light dir', these would be queried from the meta data provided to the renderer and uploaded to the hw. Should a parameter by that name not exist in the object, it can:
1. be taken from the scenes global properties,
2. be set to a suitable default (supplied in the shader description), or
3. cause the rendering for that object to raise a console warning and terminate.
* I worried initially whether a meta system such as this would be a huge overhead, pleasantly I have found this not to be the case. It is tied to a string table system where after an object makes an initial query of the property name, everything then uses string id's rather than the parameter names themselves making lookups pretty fast.
* The system allows parameters to be aliased easily and to be shared between objects (I use counted pointers currently for safety). I've not decided if aliasing a set of properties from another object is actually a good thing yet!
* Requires consistent naming of meta parameters as they are picked up only by name. (This could be extended so that a meta data parameter could be given a name and a 'nature', or a type of object could have an 'alias set' defined that would map an objects existing properties to the names required by a particular user of that object).
Overall I cannot claim that this system works perfectly (yet!) in a full scale project. I have not tested extensively against a multi thread scenario with complex scenes, I'm only just coming up to that part of the development. Currently I divide the rendering system and the object update system so they exist in different threads. The rendering system does not update meta properties from its thread, and object processing is (currently) performed serially on a single processing thread. This prevents multiple concurrent updates from occurring, but the system does not yet protect a reader from taking data whilst an update is being made.
I hope this idea, at least in part, might be food for thought though,

From: [] On Behalf Of Lagarde Sébastien
Sent: 26 April 2007 13:40
Subject: [Algorithms] Shader system design for shader centric engine



I am curious about how people automate exchange between the engine and the shader,

And how people handle shared parameter between shader ?


There is a nice article in Shader X 4 : “Transparent Shader data binding” about automate exchange,

but one of the problem of this Method is all object which will provide data for shader must derived from

a Common class (Engine Resource in this case).


I can see a less flexible way like having a class AutomateExchangeShaderPararameter, in which you would gather

All information to retrieve a fixed set of semantic variable (world matric, view matrix, fog color…).


For example you can have a :

AutomateExchangeShaderPararameter aesp;


Aesp->SetCamera(Camera) which will update projection matrix and other appropriate variable.


Then when you render your shader,

Shader->UpdateAutomatedVariable(); // will set projection matrix to right register constant value


How people are you handle this ?


One other point is how to handle shared parameter?

(Again a good article is shader X5 : case study: designing a shader subsystem for next-gen graphic engine)

You can have a global shared parameter class for your engine which collects all needed information.

Then you have some




Which will update the right value based on their frequency (typically by constant buffer).


How people actually do this?

Did you not use automated binding at all and set shader parameter variable at hand before each rendering?


I am curious about what design for Material system people use for a shader centric engine.



Lagarde Sébastien
Software engineer
Neko entertainment


This message is subject to Imagination Technologies' e-mail terms: