[SOLVED] Problem with PF_D32_FLOAT shadows

Problems building or running the engine, queries about how to use features etc.
Post Reply
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

[SOLVED] Problem with PF_D32_FLOAT shadows

Post by xrgo »

Ogre 2.1
Hello! I was using a code like this one to create my compositor shadow node:

Code: Select all

    Ogre::CompositorShadowNodeDef *shadowNodeDef = root->getCompositorManager2()->addShadowNodeDefinition( "ShadowNode" );

    shadowNodeDef->setNumShadowTextureDefinitions( 4 );
    shadowNodeDef->setNumTargetPass( 4 );

    //Splits
    int shadowRes = 4096;
    for(int i=0; i<4; i++){
        Ogre::ShadowTextureDefinition *texDef = shadowNodeDef->addShadowTextureDefinition( 0, i, Ogre::StringConverter::toString(i), false );
        texDef->numSplits = 4;
        texDef->width = shadowRes;
        texDef->height = shadowRes;
        texDef->pssmLambda = 0.95;
        texDef->formatList.push_back( Ogre::PF_FLOAT32_R );
        texDef->shadowMapTechnique = Ogre::SHADOWMAP_PSSM;
    }

    for(int i=0; i<4; i++){
        Ogre::CompositorTargetDef *targetDef = shadowNodeDef->addTargetPass( Ogre::StringConverter::toString(i) );
        targetDef->setNumPasses( 2 );
        //Clear
        Ogre::CompositorPassDef *passClearDef = targetDef->addPass( Ogre::PASS_CLEAR );
        ((Ogre::CompositorPassClearDef*)(passClearDef))->mColourValue = Ogre::ColourValue::White;
        //Scene
        Ogre::CompositorPassDef *passSceneDef = targetDef->addPass( Ogre::PASS_SCENE );
        passSceneDef->mShadowMapIdx = i;
    }
But now! I want to change PF_FLOAT32_R for PF_D32_FLOAT, but when I do that I get glitchy shadows on the first 1 or 2 splits =(
the strange thing is that this script works very well:

Code: Select all

compositor_node_shadow ShadowNode
{
	technique pssm
	num_splits		4
	pssm_lambda		0.95
	shadow_map 0 4096 4096 PF_D32_FLOAT light 0 split 0
	shadow_map 1 4096 4096 PF_D32_FLOAT light 0 split 1
	shadow_map 2 4096 4096 PF_D32_FLOAT light 0 split 2
	shadow_map 3 4096 4096 PF_D32_FLOAT light 0 split 3

	shadow_map 0 1 2 3
	{
		pass clear
		{
			colour_value 1 1 1 1
		}
		pass render_scene
		{
		}
	}
}
but I need to do it in C++, what am I missing in my C++ code??

thanks!!

EDIT: lol, I just quickly solved it... I was missing this in ShadowTextureDefinition:

Code: Select all

/// Depth Buffer's pool ID. If the format is a depth format, it
        /// is recommended you set this value to POOL_NON_SHAREABLE
        uint16      depthBufferId;
xrgo
OGRE Expert User
OGRE Expert User
Posts: 1148
Joined: Sat Jul 06, 2013 10:59 pm
Location: Chile
x 168

Re: [SOLVED] Problem with PF_D32_FLOAT shadows

Post by xrgo »

Forgot to mention that my app now uses ~500mb of video memory less!! just by changing from PF_FLOAT32_R to PF_D32_FLOAT (4 splits 4k res)!! go PF_D32_FLOAT!! :D
Post Reply