New Feature: Material Parameter Overrides

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.


This looks great, tomorrow I’ll implement this in my shadow renderer.

Great to hear! Especially making model selection effects easier is a highly wanted feature for a lot of users (I still render them twice in my games :frowning: ). I think @thetoucher did a border outlining effect a few months ago that looked promising. No idea though, if it might benefit from the changes or if it’s already using it (or is a complete other approach).

1 Like

Heads up for those following along at home. We were going to do alpha 5 then beta but that’s not the case anymore. There will be at least alpha 6, too, now. Possibly an alpha 7.


Lots of Great Works, Thanks.

I was waiting for it since long time :grinning:

This is for meee… !!
Thanks a lot.

Now we have to redo pretty much everything using this :smiley:

And test the heck out of it before beta.

what is “test”?


There are posts where I wish I could give more likes :wink: Great work guys! I am, as always, impressed by this project!

Now you can also override material parameters within SceneProcessors and Filters, via RenderManager.addForcedMatParam().