So as you probably noticed 35 commits have just been pushed onto master from the experimental branch. This is a new feature called “Material Parameter Overrides” which is designed to integrate materials into the scene graph more closely by allowing Controls and AppStates to manipulate global material state.
This makes it much easier to implement features such as:
- In-pass Shadow Mapping
- Model selection effects / rim lighting
- Filters which require material information. E.g. motion blur, heat haze, etc.
- Local reflection mapping
- Fading between LOD levels
- Shader LOD, e.g. vertex lighting or disable specular for far away objects
- Hardware skinning using shared materials
- Soft particles
- Fog without using a filter
- And probably a lot more…
You can see an example of how to use this new feature in TestMatParamOverride where a material color is being overridden through the root node to be set to something else. This is done without the materials being modified. This also works for parameters which are bound to a define, so you can do things like enable per-vertex lighting globally for the entire scene without having to traverse the scene graph or modify models after they have been loaded.
Many features implemented in the past had to work around the lack of parameter overrides. The soft particles processor had to enumerate all materials just so that it could set the depth texture parameter. Hardware skinning was implemented by traversing the model’s scene graph and then setting parameters on the material – this failed spectacularly when using a shared material instance since the bone matrices parameter would be corrupted and the animation of the other models would break. Fog had to be implemented as a filter which meant that fog would not be rendered at all when viewed through a transparent surface.
This feature will be included in alpha 5 which will be released in a week.