Hi! Thanks for the detailed report,
hyyou wrote: ↑Tue Mar 13, 2018 6:00 am
I think the formula is counter-intuitive in 2 aspects :-
- 1. For Ortho-camera, Ogre should sort by Z (i.e. vector-dot with direction of camera), not Euclidean distance.
This can be workarounded by moving orthographic camera very-far from the scene.
It was also requested in a very old post Sort by depth and not by distance + naming difficulties.
[/list]
It affects projection cameras too! Therefore I've
pushed the fix. There is no doubt euclidean distance is wrong, as we only use that calculation for depth sorting.
hyyou wrote: ↑Tue Mar 13, 2018 6:00 am
- 2. Ogre should not concern about scale of Ogre::Item. I suggest to remove the term worldRadius (?).
With current design, just scaling b up / down make b appear more-front / more-back!
It is good for sphere-like shape, but bad for billboard-like.
I can't find any pretty workaround for it without changing Ogre's code. :(
That is harder to consider. "It depends", as you said, objects with volume (cubes, sphere, complex shapes) do need their radius to be affected by world scale. Even if the object is thin, it may be viewed from any angle.
But billboards always facing towards the camera reorient themselves and have no depth thus considering scale into the radius makes no sense and can harm.
Ultimately the problem is that these are approximations to "more or less render transparents ok". True sorting would have to occur per pixel (or per triangle, and split intersecting triangles).
I'm trying to think of ideas this could be toggled per Item (i.e. "ignore scale flag") but I can't think of a method that does not waste 4 bytes per Item (I'm trying to see if we can avoid penalizing everyone for a corner case); unless you're ok with adding a macro flag:
Code: Select all
#if OGRE_CONSIDER_SCALE_WORLD_RADIUS
*worldRadius = (*localRadius) * parentScale.getMaxComponent();
#else
*worldRadius = (*localRadius);
#endif
Thus tweakable with global granularity while avoiding penalizing everyone.
I'm open to suggestions.