[Ogre 2.0] scene_depth_range issues

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


Post Reply
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

[Ogre 2.0] scene_depth_range issues

Post by al2950 »

The scene_depth_range does not work in Ogre 2.0. The offending code is here;

Code: Select all

void SceneManager::getMinMaxDepthRange( const Frustum *shadowMapCamera,
                                        Real &outMin, Real &outMax ) const
{
    if( !mCurrentShadowNode )
    {
        outMin = 0.0f;
        outMax = 100000.0f;
    }
    else
    {
        mCurrentShadowNode->getMinMaxDepthRange( shadowMapCamera, outMin, outMax );
    }
}
Keep in mind that both scene_depth_range and shadow_scene_depth_range use this same code path.The first issue is if no mCurrentShadowNode is set, then the ranges are unlikely to be correct! I thought this would be simple to solve, however mCurrentShadowNode is never unset, and so we will also try to get the shadow camera depth range even if we are not rendering the shadow pass.

Any ideas of how to proceed? Would it make sense to have a mCurrentCompisitorNode instead of a specific shadow node and the obvious virtuals. This would be set when each node is executed and then it could be up to the node to work out the current depth range? Having said that the scene_depth_range is more complicated than the shadow depth, as we want the max depth range to be equal to the furthest object in the current frustum we are trying to render, not necessarily the max camera render distance.... I think!
User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5296
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1278
Contact:

Re: [Ogre 2.0] scene_depth_range issues

Post by dark_sylinc »

I've looked at the code and meditated a bit about it. I also remembered the problem I faced back then.

What getMinMaxDepthRange does is to return the tightest depth range in which the objects are going to be rendered from a shadow mapping perspective. That means min >= shadowCam->nearClippingRage and max <= shadowCam->farClippingRange.
If there's not enough information, it returns the extremely conservative range [0; 100.000)
This function is only meant for shadow mapping, and shouldn't be used for anything else.
however mCurrentShadowNode is never unset,
This is not entirely correct. The next pass_scene will call SceneManager::_setCurrentShadowNode with mShadowNode = nullptr; therefore unsetting the shadow node.
This is an accidental, but probably desirable behavior. If the current pass is going to be used for shadow mapping (but you're not using shadow nodes), the fallback to [0; 100.000) may actually work for you (specially for i.e. directional shadow maps).

scene_depth_range was initially intended for shadow mapping, thus I modified its behavior for getting proper shadow mapping.
I think the proper course of action is to create a different binding that returns the scene's depth range of the current camera; not for shadow mapping purposes (use near and far planes? or the intersection between those planes and the scene aabb?).
al2950
OGRE Expert User
OGRE Expert User
Posts: 1227
Joined: Thu Dec 11, 2008 7:56 pm
Location: Bristol, UK
x 157

Re: [Ogre 2.0] scene_depth_range issues

Post by al2950 »

Apologies for the very late reply, work went a bit wrong and needed my undivided attention!
The next pass_scene will call SceneManager::_setCurrentShadowNode with mShadowNode = nullptr; therefore unsetting the shadow node.
Yes, somehow when debugging I got mixed up and was convinced the shadow node was never unset, but it does! I have had a closer look at this and I agree with your view that something should be done for scene_depth, however its not really that important at the moment. I have created a ticket if you wanted to discuss any implementation specifics;
https://ogre3d.atlassian.net/browse/OGRE-454

As for what the values should be I think they should be the tightest depth range of that current render (intersection of near/far planes and the scene aabb) as thats the whole point of it in my view.
Post Reply