[1.11.6] RTSS per pixel lighting and PSSM3

Problems building or running the engine, queries about how to use features etc.
Post Reply
tritonas00
Halfling
Posts: 87
Joined: Sun Apr 08, 2018 2:21 pm
x 36

[1.11.6] RTSS per pixel lighting and PSSM3

Post by tritonas00 »

Ogre Version: 1.11.6
Operating System: Arch Linux
Render System: OpenGL

Hi. We recently enabled RTShader::PerPixelLighting in Rigs of Rods and that alone works great:

Image

Then we enabled RTShader::IntegratedPSSM3> and we have some issues with it.

Artifacts in some terrain objects:

Artifacts with lighting:

Code:

Code: Select all

Ogre::RTShader::ShaderGenerator::initialize();
Ogre::RTShader::ShaderGenerator* mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
mShaderGenerator->setShaderCachePath(cache_path);      
mShaderGenerator->addSceneManager(App::GetGfxScene()->GetSceneManager()); RoR::App::GetAppContext()->GetViewport()->setMaterialScheme(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME); Ogre::RTShader::RenderState* schemRenderState = mShaderGenerator->getRenderState(Ogre::RTShader::ShaderGenerator::DEFAULT_SCHEME_NAME); Ogre::RTShader::PerPixelLighting* perPixelLightModel = mShaderGenerator->createSubRenderState<Ogre::RTShader::PerPixelLighting>(); schemRenderState->addTemplateSubRenderState(perPixelLightModel); App::GetGfxScene()->GetSceneManager()->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED); App::GetGfxScene()->GetSceneManager()->setShadowDirectionalLightExtrusionDistance(299.0f); App::GetGfxScene()->GetSceneManager()->setShadowFarDistance(350.0f); App::GetGfxScene()->GetSceneManager()->setShadowTextureCountPerLightType(Ogre::Light::LT_DIRECTIONAL, 3); App::GetGfxScene()->GetSceneManager()->setShadowTextureSettings(2048, 3, PF_FLOAT32_R); App::GetGfxScene()->GetSceneManager()->setShadowTextureSelfShadow(true); App::GetGfxScene()->GetSceneManager()->setShadowCasterRenderBackFaces(true); MaterialPtr passCaterMaterial = MaterialManager::getSingleton().getByName("PSSM/shadow_caster"); App::GetGfxScene()->GetSceneManager()->setShadowTextureCasterMaterial(passCaterMaterial); PSSMShadowCameraSetup* pssmSetup = new PSSMShadowCameraSetup(); pssmSetup->calculateSplitPoints(3, 1, 500, 1); pssmSetup->setSplitPadding(App::GetCameraManager()->GetCamera()->getNearClipDistance()); pssmSetup->setOptimalAdjustFactor(0, 2); pssmSetup->setOptimalAdjustFactor(1, 1); pssmSetup->setOptimalAdjustFactor(2, 0.5); App::GetGfxScene()->GetSceneManager()->setShadowCameraSetup(ShadowCameraSetupPtr(pssmSetup)); auto subRenderState = mShaderGenerator->createSubRenderState<RTShader::IntegratedPSSM3>(); subRenderState->setSplitPoints(pssmSetup->getSplitPoints()); schemRenderState->addTemplateSubRenderState(subRenderState);

Any idea how to fix those issues? Thanks in advance.

paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: [1.11.6] RTSS per pixel lighting and PSSM3

Post by paroj »

you probably need some fixes hat happened after 1.11.6, notably: https://github.com/OGRECave/ogre/commit ... ed1b53620c

tritonas00
Halfling
Posts: 87
Joined: Sun Apr 08, 2018 2:21 pm
x 36

Re: [1.11.6] RTSS per pixel lighting and PSSM3

Post by tritonas00 »

Tried 13.4.4 RTSS per pixel lighting and already appreciating its listener, it seems we don't even need to specify the materials, it just finds them

Code: Select all

RTSS: using dd4567beb153c3404e287bc077bc8823_VS for Pass 0 of 'driversseat@Actor_2'
RTSS: using bd5a9bc5aa48b5b26bfa4ea89a278d61_FS for Pass 0 of 'driversseat@Actor_2'
RTSS: using dd4567beb153c3404e287bc077bc8823_VS for Pass 0 of '95bbUID-tracks/agora@Actor_2'
RTSS: using 53a10162ee1184e5fb8ff14a3a6e4a45_FS for Pass 0 of '95bbUID-tracks/agora@Actor_2'
RTSS: using dd4567beb153c3404e287bc077bc8823_VS for Pass 0 of '95bbUID-tracks/agora-trans-2@Actor_2'
RTSS: using 53a10162ee1184e5fb8ff14a3a6e4a45_FS for Pass 0 of '95bbUID-tracks/agora-trans-2@Actor_2'
RTSS: using dd4567beb153c3404e287bc077bc8823_VS for Pass 0 of '95bbUID-tracks/agora-back-2@Actor_2'
RTSS: using 7829edea6f3e391ecdfa113284dec38b_FS for Pass 0 of '95bbUID-tracks/agora-back-2@Actor_2'

Image

Will try the PSSM3 stuff asap.

tritonas00
Halfling
Posts: 87
Joined: Sun Apr 08, 2018 2:21 pm
x 36

Re: [1.11.6] RTSS per pixel lighting and PSSM3

Post by tritonas00 »

Looks good!

Image

Is there any way to have light on top of shadows also? Does the order of states make any difference? Like first do the shadows and then the light maybe...

paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: [1.11.6] RTSS per pixel lighting and PSSM3

Post by paroj »

ah! I see. The issue is that PSSM only works with one (directional) shadow casting light. Probably nobody tested whether it works well with non-casting lights.
I guess it is just a matter of ordering the lighting equations - but that needs to happen in the RTSS code. The SRS are always ordered internally, no matter which one you add first.

Could you meanwhile try the CookTorranceLighting SRS instead of per-pixel? That one uses a more recent lighting evaluation. It will probably look off, but if the light is visible in the shadow, it would help me to find what to fix in per-pixel

tritonas00
Halfling
Posts: 87
Joined: Sun Apr 08, 2018 2:21 pm
x 36

Re: [1.11.6] RTSS per pixel lighting and PSSM3

Post by tritonas00 »

CookTorranceLighting seems to behave the same

Image

Code: Select all

Ogre::RTShader::ShaderGenerator::initialize();
Ogre::RTShader::ShaderGenerator* mShaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
mShaderGenerator->setShaderCachePath(cache_path);      

// Listener
auto schemeNotFoundHandler = new OgreBites::SGTechniqueResolverListener(mShaderGenerator);
Ogre::MaterialManager::getSingleton().addListener(schemeNotFoundHandler);

mShaderGenerator->addSceneManager(App::GetGfxScene()->GetSceneManager());
Ogre::RTShader::RenderState* schemRenderState = mShaderGenerator->getRenderState(Ogre::MSN_SHADERGEN);

// Per-pixel lighting
RoR::App::GetAppContext()->GetViewport()->setMaterialScheme(Ogre::MSN_SHADERGEN);
RTShader::SubRenderState* perPixelLightModel = mShaderGenerator->createSubRenderState("CookTorranceLighting");
schemRenderState->addTemplateSubRenderState(perPixelLightModel);

// PSSM3
App::GetGfxScene()->GetSceneManager()->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE_INTEGRATED);
App::GetGfxScene()->GetSceneManager()->setShadowFarDistance(350);
App::GetGfxScene()->GetSceneManager()->setShadowTextureCountPerLightType(Ogre::Light::LT_DIRECTIONAL, 3);
App::GetGfxScene()->GetSceneManager()->setShadowTextureSettings(2048, 3, PF_DEPTH16);
App::GetGfxScene()->GetSceneManager()->setShadowTextureSelfShadow(true);

MaterialPtr passCaterMaterial = MaterialManager::getSingleton().getByName("PSSM/shadow_caster");
App::GetGfxScene()->GetSceneManager()->setShadowTextureCasterMaterial(passCaterMaterial);

PSSMShadowCameraSetup* pssmSetup = new PSSMShadowCameraSetup();
pssmSetup->calculateSplitPoints(3, 1, 500, 1);
pssmSetup->setSplitPadding(App::GetCameraManager()->GetCamera()->getNearClipDistance());
pssmSetup->setOptimalAdjustFactor(0, 2);
pssmSetup->setOptimalAdjustFactor(1, 1);
pssmSetup->setOptimalAdjustFactor(2, 0.5);

App::GetGfxScene()->GetSceneManager()->setShadowCameraSetup(ShadowCameraSetupPtr(pssmSetup));
auto subRenderState = mShaderGenerator->createSubRenderState<RTShader::IntegratedPSSM3>();
subRenderState->setSplitPoints(pssmSetup->getSplitPoints());
schemRenderState->addTemplateSubRenderState(subRenderState);
tritonas00
Halfling
Posts: 87
Joined: Sun Apr 08, 2018 2:21 pm
x 36

Re: [1.11.6] RTSS per pixel lighting and PSSM3

Post by tritonas00 »

It seems this part:

Code: Select all

MaterialPtr passCaterMaterial = MaterialManager::getSingleton().getByName("PSSM/shadow_caster");
App::GetGfxScene()->GetSceneManager()->setShadowTextureCasterMaterial(passCaterMaterial);

doesn't even needed, i can't see any difference with/without

paroj
OGRE Team Member
OGRE Team Member
Posts: 1994
Joined: Sun Mar 30, 2014 2:51 pm
x 1074
Contact:

Re: [1.11.6] RTSS per pixel lighting and PSSM3

Post by paroj »

tritonas00
Halfling
Posts: 87
Joined: Sun Apr 08, 2018 2:21 pm
x 36

Re: [1.11.6] RTSS per pixel lighting and PSSM3

Post by tritonas00 »

Thank you very much, will try it ASAP!

tritonas00
Halfling
Posts: 87
Joined: Sun Apr 08, 2018 2:21 pm
x 36

Re: [1.11.6] RTSS per pixel lighting and PSSM3

Post by tritonas00 »

it works!

Image

Post Reply