One thing that i require for my shader is the current material properties. The diffuse, specular, ambient and emmisive colors, and the shininess-properties. I thought at first that they should probably be accessible from within my shader, turned out it wasn't, then i turned my train of thought towards setting them in OnSetConstants
Code: Select all
virtual void OnSetConstants(video::IMaterialRendererServices* services, s32 userData)
{
...
services->setVertexShaderConstant("c_AmbientColor", reinterpret_cast<f32*>(&Material.Ambient), 3);
...
}
I knew the parallax material passes SMaterial::MaterialTypeParam to it's shader, so i dug for a while and found out how.
The parallax renderer is a driver dependant class, which is a child of IMaterialRenderer. Hence it can overload OnSetMaterial
Code: Select all
virtual void OnSetMaterial(SMaterial& material, const SMaterial& lastMaterial,
bool resetAllRenderstates, IMaterialRendererServices* services) {};
But the parallax renderer compiles it's shader itself, in a driver dependant way. If i where to do the same thing, i would have to abandond the nice driver independant interfaces made avialable trough IGPUProgrammingServices and IMaterialRendererServices.
Therefore, i suggest a change.
Let us, in the driver dependant shader class(Which is created trough a 'rerouting' call trough IGPUProgrammingServices->addHighlevelshader), which calls the callback OnSetConstants, and which's OnSetMaterial is called when setting the material, store the material properties until OnSetConstants is called. Then we should pass it by reference, like this:
Code: Select all
virtual void OnSetConstants(video::IMaterialRendererServices* services, const SMaterial &CurrentMaterial, s32 userData);
I would reall like to see this in the next release of irrlicht, since it really is an easy thing to implement/change.
It would be really bad if it'd have to wait until the second next release of irrlicht =)
Luben