It seems the reality of the situation is that the new version has removed a feature and in no way replaced it with a new feature, which means it has essentially dropped support to fade in/out objects correctly in an advanced system.
The user has to do something about it now instead of the engine doing it like it was in 1.11.2.
Essentially, each material in 1.11.2 was complete. It was 1 step and one file.
Each material in 13.3.4 is incomplete, since it needs another material to function, and you can no longer set shader parameters in the material, which means you need to do that in code instead.
This means it is 1 step for the material, 1 step for the caster material and then 1 step to set the shader parameters in code. 3 different steps for each material instead of 1.
The previous way to define the shadow caster per material:
Code: Select all
shadow_caster_vertex_program_ref DepthShadowmapCaster_StaticAlphaRejection_VS
{
}
shadow_caster_fragment_program_ref DepthShadowmapCaster_StaticAlphaRejection_PS
{
param_named alphaRejectionGreater float 0.5
}
You could also right then and there set parameters for the shaders, which I did for many materials where I wanted special attributes, such as a different alpha rejection value per material.
This is no longer possible in 13.3.4, which is extremely bad, and I would have to make code at startup to specifically set attributes to these shadow caster materials. That is a major issue, as that means that a material is not even a material anymore as you cannot even define what you need in it anymore when it comes to the shadow caster. In the worst case scenario, you would have to define a whole new shadow caster material per material.
The new way to define the shadow caster per material (which also needs another material to even function):
Code: Select all
shadow_caster_material DepthShadowmapCaster_StaticAlphaRejection
This does not support setting special attributes and is not a real part of the material, which also creates more problems below.
Also, this breaks the standard of normal shaders in passes in materials, as they work exactly like they did in 1.11.2, which is the correct way of handling this feature (as it is just that much more simple).
The previous chain was like this for each object:
- Create the entity from a mesh and attach it to a scene node.
- Clone the material and set it to the entity.
- Fade it in/out.
- On destruction of the object, destroy the cloned material.
The new chain would be like this:
- Create the entity from a mesh and attach it to a scene node.
- Clone the material and set it to the entity.
- NEW! Clone the shadow caster material and set it to the cloned material.
- Fade it in/out.
- NEW! On destruction of the object, destroy the cloned shadow caster material.
- On destruction of the object, destroy the cloned material.
The previous chain was like this for each material (looping through them when they are loaded for each resource group):
- Check if we should alter the current material to something else (to support GPU animation for example, controlled from the options menu, material specific stuff, etc).
- Alter the materials shadow caster shaders to the correct one needed. Also set special parameters to them if needed.
- Cloned materials that use this material then also gets the correct shadow caster shaders, which is perfect.
The new chain would be something like this for each material:
- Check if we should alter the current material to something else (to support GPU animation for example, controlled from the options menu, material specific stuff, etc).
- NEW! ??? Clone the shadow caster material somehow? But place it where? How would I know when the base material gets unloaded? This is impossible. I have asked this question many times in this forum post, which I have not received an answer to, which means this must be done by the user, but its almost impossible (or at least extremely hard) to know how to do that in an advanced system.
- Alter the materials shadow caster shaders to the correct one needed. Also set special parameters to them if needed.
- ALTERED! Cloned materials that use this material does not get the shadow caster shader, that must be done specifically instead by the user somehow, which is also confusing.
Also, exporting materials with the new system in 13.3.4 would be impossible, as the shadow caster material would be cloned with another name and therefore would be impossible to load an exported material.
Then, even more user code would have to be created to just handle this little issue.
In 1.11.2, the material would be exported with the specific shadow caster shader and all its shader attributes instead, and there would be no issue at all. There would be no new name that you would have to relink or something like that, it would just work.
You also talk about ACT_CUSTOM, but that won't work even if it is per object, since the shaders themselves in the shader caster material can change at any given moment, and so can their shader inputs.
It would be a very complex system to have to use renderable->setCustomParameter on every object for each time its shader is altered, and also in a specific manner (since setCustomParameter is index based, and not name based like setNamedConstant). That means for every shader that index changes, and the code would have to somehow keep a track on that for each and every update of the shader.
Or, you would have to just have a simpler project with almost no shaders or features at all.
In 1.11.2 this worked in just one simple function (setNamedConstant) and it handled everything automatically, not even having to know if the shader has the parameter or not or where that parameter exist as an index in the shader.
But even if ACT_CUSTOM somehow got a named function like that, I would still have to handle everything I have talked about even if I used ACT_CUSTOM regarding the shader caster materials, as their shaders needs to be exchanged.
Also, it cannot be set directly in the material definition like the 1.11.2 system could. That has to be taken care through code, which again makes a material not really a material anymore.
ACT_CUSTOM is not flexible since it always has to input a Vector4. Sometimes it might be needed to input stuff like a matrix, and that would also need many user defined functions, which again breaks the pattern of the simple system as it is for all other shaders with named parameters.
I see it as I have a few choices regarding this issue:
- I do special user code to handle the new shadow caster materials.
The user code required to handle the per-object shadow caster materials is extremely hard to do though, and I would argue that it is extremely poor design that every user needs to do this, instead of it being supported by the engine, like it used to be in 1.11.2.
It would clutter the entire project with extra code, double the amount of materials and would most likely create bugs (since if it is missed somewhere, it will be invalid for that object and all future objects using that material).
And I still don't know how to handle the destruction of the shadow caster materials correctly, as those cloned ones will be set on materials that I never know when they will be destroyed.
They can either be a material loaded by a resource group, a material created from scratch or a material cloned, which makes it extremely complex to try to handle the destruction of the shadow caster materials. This was all handled automatically in 1.11.2 since it was instead in the actual material and not a required extra material.
.
- I remove all code in Ogre for shadows.
Then I create my own material scheme in every material in the game for it, which goes to the old (better) system of doing stuff, which means it is in the same material instead.
That would of course mean I would have to handle rendering the shadows myself instead, and it would be extremely hard, time consuming and complex to do correctly for multiple shadows.
The drawback of this system is that each material would only handle one way of casting shadows, and not per-pass like the system was before, so this is not a good alternative at all compared to the one in 1.11.2.
.
- I pray and wait for a future Ogre version that gets back support for this feature, making a material a material again.
But that seems very unlikely since this forum post shows pretty clearly that it is intended and that Ogre now only targets simpler projects with less advanced features.
.
- I stop trying to upgrade, since the upgrade is actually a downgrade, since the new version is worse than the old version when it comes to this dealbreaker. I don't think the new shadow caster system is very thought through, and I would never think that such a simple system as it was before could became this big of a problem.
This would probably mean the death of my project though, as I would no longer be able to upgrade the engine.
I would also have to choose another engine for my next project of course, as this is no longer able to be used for bigger projects. This is really depressing to see.
I would suggest to anyone else with an advanced project thinking about upgrading to 13.3.4 to wait until this design error has been fixed.
Otherwise you will have a very bad time when it comes to shadow casters (if you want to handle them correctly that is, with multiple shaders/materials in a dynamic system).