setCastShadows bug ?

Discussion area about developing with Ogre2 branches (2.1, 2.2 and beyond)
Post Reply
Crashy
Google Summer of Code Student
Google Summer of Code Student
Posts: 996
Joined: Wed Jan 08, 2003 9:15 pm
Location: Lyon, France
x 47
Contact:

setCastShadows bug ?

Post by Crashy »

Hi,
I'm playing with Ogre 2 and I'm having a problem when calling setCastShadows on entities.

As soon as I call setCastShadows(true) on one entity, all entities are rendered in the shadow map.

The compositor setup is quite the same as in the demos.

Code: Select all

....
target_output
	{
		pass clear
		{
			colour_value 0.35 0.35 0.35 0
		}
		pass render_scene
		{
			shadows				Shadows_FocusedShadowNode
			rq_last 89
			overlays off
		}
	}
...

abstract shadow_map shadow_map_target
{
	pass clear
	{
		colour_value 1 1 1 1
	}

	pass render_scene 
	{
		overlays			off
	}
}

compositor_node_shadow Shadows_FocusedShadowNode
{
    technique focused

	shadow_map 0 1024 1024 PF_FLOAT32_R light 0 depth_pool 2

	shadow_map 0 : shadow_map_target {}
}
Any hint ?
Follow la Moustache on Twitter or on Facebook
Image

Crashy
Google Summer of Code Student
Google Summer of Code Student
Posts: 996
Joined: Wed Jan 08, 2003 9:15 pm
Location: Lyon, France
x 47
Contact:

Re: setCastShadows bug ?

Post by Crashy »

I've done some debug to understand how is working the visibility mask culling.

I've seen that when calling MovableObject::cullFrustum in OgreSceneManager.cpp, the visibility flags passed are

Code: Select all

 camera->getLastViewport()->getVisibilityMask()&getVisibilityMask()
In the case of the shadow compositor node, the lastViewport visibility flag is set to 0xbfffffff, which is correct.
But the SceneManager::getVisibilityMask returns 0x3fffffff, which is the default value for the scene manager's visibility mask.

And as 0xbfffffff & 0x3fffffff == 0x3fffffff, this leads to render all objects to the shadow texture, even non shadow casters.

If I pass to MovableObject::cullFrustum only the viewport visibility mask (in this case 0xbfffffff ), everything's ok and only shadow casters are rendered.
Follow la Moustache on Twitter or on Facebook
Image

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4189
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 794
Contact:

Re: setCastShadows bug ?

Post by dark_sylinc »

You're correct. There is a bug in how Ogre is handling and merging the scene manager and the viewport visibility flags.

I will investigate.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 4189
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 794
Contact:

Re: setCastShadows bug ?

Post by dark_sylinc »

Fixed. Thanks.

Masking the (viewport & sceneMask) caused the reserved visibility flags to disappear.
We must always keep the reserved visibility flags of the viewport.

Crashy
Google Summer of Code Student
Google Summer of Code Student
Posts: 996
Joined: Wed Jan 08, 2003 9:15 pm
Location: Lyon, France
x 47
Contact:

Re: setCastShadows bug ?

Post by Crashy »

Cool, I'm happy I could help.
Follow la Moustache on Twitter or on Facebook
Image

Post Reply