Skip to content

Commit

Permalink
ssao in splitscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
cryham committed Nov 11, 2024
1 parent 5a60c5e commit 7b7d8b8
Show file tree
Hide file tree
Showing 9 changed files with 76 additions and 18 deletions.
8 changes: 4 additions & 4 deletions data/gui/Editor_Options.layout
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@


<!-- 🕳️ SSAO -->
<Widget type="Button" skin="CheckBox" position="28 70 356 24" name="SSAO">
<Property key="Caption" value="#{SSAO} #704040 = #{NotDone}"/>
<Widget type="Button" skin="CheckBox" position="28 70 556 24" name="SSAO">
<Property key="Caption" value="#{SSAO} *"/>
<Property key="TextColour" value="0.3 0.7 1"/>
</Widget>

Expand Down Expand Up @@ -249,8 +249,8 @@
<Property key="Alpha" value="0.4"/>
<Property key="ImageTexture" value="gui_icons.png"/>
</Widget> -->
<Widget type="Button" skin="CheckBox" position="28 30 356 24" name="GI">
<Property key="Caption" value="#{GI} #603030 = #{NotDone}"/>
<Widget type="Button" skin="CheckBox" position="28 30 556 24" name="GI">
<Property key="Caption" value="#{GI} #603030 #{Terrain} = #{NotDone}"/>
<Property key="TextColour" value="1 0.5 0.7"/>
</Widget>

Expand Down
6 changes: 3 additions & 3 deletions data/gui/Game_Options.layout
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@


<!-- 🕳️ SSAO -->
<Widget type="Button" skin="CheckBox" position="28 70 356 24" name="SSAO">
<Property key="Caption" value="#{SSAO} #704040 = #{NotDone}"/>
<Widget type="Button" skin="CheckBox" position="28 70 456 24" name="SSAO">
<Property key="Caption" value="#{SSAO} *"/>
<Property key="TextColour" value="0.3 0.7 1"/>
</Widget>

Expand Down Expand Up @@ -250,7 +250,7 @@
<Property key="ImageTexture" value="gui_icons.png"/>
</Widget> -->
<Widget type="Button" skin="CheckBox" position="28 30 356 24" name="GI">
<Property key="Caption" value="#{GI} #603030 = #{NotDone}"/>
<Property key="Caption" value="#{GI} #603030 #{Terrain} = #{NotDone}"/>
<Property key="TextColour" value="1 0.5 0.7"/>
</Widget>

Expand Down
2 changes: 1 addition & 1 deletion src/common/AppGui.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ class AppGui : public BGui
Ogre::Pass *mSSAOPass =0;
Ogre::Pass *mApplyPass =0;
Ogre::TextureGpu *noiseTexture =0;
void InitSSAO(), UpdateSSAO();
void InitSSAO(), UpdateSSAO(Ogre::Camera *camera);


// 🌄 GI ----------------
Expand Down
4 changes: 1 addition & 3 deletions src/common/AppGui_Compositor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,6 @@ TextureGpu* AppGui::CreateCompositor(int view, int splits, float width, float he
nd->addTextureSourceName("rt_wnd", 0, inp); // in wnd

nd->mCustomIdentifier = "old-1";
//if( pass->getParentNode()->getDefinition()->mCustomIdentifier == "CustomString" )

nd->setNumTargetPass( (!split ? 2 : 0) + 1 ); //* targets

Expand All @@ -575,8 +574,7 @@ TextureGpu* AppGui::CreateCompositor(int view, int splits, float width, float he
ps->setAllLoadActions( LoadAction::Clear );
ps->setAllStoreActions( StoreAction::Store );

ps->mProfilingId = "Render Old";
ps->mIdentifier = 21002;
ps->mProfilingId = "Render Old"; ps->mIdentifier = 21002;
// ps->mLastRQ = 199; //RQG_Fluid-1 // all

AddShadows(ps); // shadows
Expand Down
12 changes: 11 additions & 1 deletion src/common/FluidsReflect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ void ReflectListener::workspacePreUpdate( CompositorWorkspace *workspace )
mPlanarRefl->beginFrame();
}

// Update per view
//-----------------------------------------------------------------------------------
void ReflectListener::passEarlyPreExecute( CompositorPass *pass )
{
Expand All @@ -70,8 +71,11 @@ void ReflectListener::passEarlyPreExecute( CompositorPass *pass )
static_cast<const CompositorPassSceneDef *>( pass->getDefinition() );

auto id = passDef->mIdentifier;
#if 0
auto s = passDef->mProfilingId;
//** LogO("ws pass: "+toStr(id)+" "+s); //toStr(pass->getParentNode()->getId() ));
LogO("ws pass: "+toStr(id)+" "+s); //toStr(pass->getParentNode()->getId() ));
// LogO(pass->getParentNode()->getDefinition()->mCustomIdentifier));
#endif

// Ignore clear etc ---
if (pass->getType() != PASS_SCENE)
Expand All @@ -84,6 +88,10 @@ void ReflectListener::passEarlyPreExecute( CompositorPass *pass )
CompositorPassScene *passScene = static_cast<CompositorPassScene *>( pass );
Camera *camera = passScene->getCamera();


if (app->pSet->ssao) // 💫🕳️
app->UpdateSSAO(camera);

#if 0 // todo: upd ter here? for splitscreen
/// ⛰️ Terrain ----?
if (app->mGraphicsSystem->getRenderWindow()->isVisible())
Expand Down Expand Up @@ -401,6 +409,8 @@ void FluidsReflect::CreateBltFluids()

btCollisionShape* bshp = 0;
bshp = new btBoxShape(btVector3(sx,sy,sz));
// bshp = new btBoxShape(btVector3(1.,1.,1.)); //?-
// bshp->setLocalScaling(btVector3(sx,sy,sz));

// solid surf
size_t id = SU_Fluid; if (fp.solid) id += fp.surf;
Expand Down
54 changes: 52 additions & 2 deletions src/common/SSAO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ void AppGui::InitSSAO()
textureManager->removeStagingTexture( stagingTexture );
stagingTexture = 0;


//---------------------------------------------------------------------------------
// Set uniforms
MaterialPtr material =
Expand Down Expand Up @@ -162,11 +163,12 @@ void AppGui::InitSSAO()
psParamsApply->setNamedConstant( "powerScale", pSet->ssao_scale );
}


// 🕳️💫 Update
//-----------------------------------------------------------------------------------
void AppGui::UpdateSSAO()
void AppGui::UpdateSSAO(Camera* camera)
{
GpuProgramParametersSharedPtr psParams = mSSAOPass->getFragmentProgramParameters();
Camera *camera = mCamera; //mGraphicsSystem->getCamera();
#if OGRE_NO_VIEWPORT_ORIENTATIONMODE == 0
// We don't render to render window directly, thus we need to get the projection
// matrix with phone orientation disable when calculating SSAO
Expand All @@ -177,4 +179,52 @@ void AppGui::UpdateSSAO()

GpuProgramParametersSharedPtr psParamsApply = mApplyPass->getFragmentProgramParameters();
psParamsApply->setNamedConstant( "powerScale", pSet->ssao_scale );
return;
//

// Reconstruct position from depth. Position is needed in SSAO
// We need to set the parameters based on camera to the
// shader so that the un-projection works as expected
// Camera *camera = mCamera; //mGraphicsSystem->getCamera();
Vector2 projectionAB = camera->getProjectionParamsAB();
// The division will keep "linearDepth" in the shader in the [0; 1] range.
projectionAB.y /= camera->getFarClipDistance();
psParams->setNamedConstant( "projectionParams", projectionAB );

// other uniforms
/* psParams->setNamedConstant( "kernelRadius", pSet->ssao_radius );
psParams->setNamedConstant(
"noiseScale",
Vector2(
( Real( mGraphicsSystem->getRenderWindow()->getWidth() ) * 0.5f ) / 2.0f,
( Real( mGraphicsSystem->getRenderWindow()->getHeight() ) * 0.5f ) / 2.0f ) );
psParams->setNamedConstant( "invKernelSize", 1.0f / 64.0f );
psParams->setNamedConstant( "sampleDirs", (float *)kernelSamples, 64, 4 );
*/
// blur shader uniforms
MaterialPtr materialBlurH =
std::static_pointer_cast<Material>( MaterialManager::getSingleton().load(
"SSAO/BlurH", ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME ) );

Pass *passBlurH = materialBlurH->getTechnique( 0 )->getPass( 0 );
GpuProgramParametersSharedPtr psParamsBlurH = passBlurH->getFragmentProgramParameters();
psParamsBlurH->setNamedConstant( "projectionParams", projectionAB );

MaterialPtr materialBlurV =
std::static_pointer_cast<Material>( MaterialManager::getSingleton().load(
"SSAO/BlurV", ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME ) );

Pass *passBlurV = materialBlurV->getTechnique( 0 )->getPass( 0 );
GpuProgramParametersSharedPtr psParamsBlurV = passBlurV->getFragmentProgramParameters();
psParamsBlurV->setNamedConstant( "projectionParams", projectionAB );

// apply shader uniforms
MaterialPtr materialApply =
std::static_pointer_cast<Material>( MaterialManager::getSingleton().load(
"SSAO/Apply", ResourceGroupManager::AUTODETECT_RESOURCE_GROUP_NAME ) );

// Pass *passApply = materialApply->getTechnique( 0 )->getPass( 0 );
// mApplyPass = passApply;
// GpuProgramParametersSharedPtr psParamsApply = passApply->getFragmentProgramParameters();
// psParamsApply->setNamedConstant( "powerScale", pSet->ssao_scale );
}
2 changes: 1 addition & 1 deletion src/editor/App_Render2tex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ void App::AddListenerRnd2Tex()
{
if (scn->refl.mWsListener)
for (int i=0; i < RT_ALL; ++i)
rt[i].ws->addListener(scn->refl.mWsListener); // prv cam refl y?..
rt[i].ws->addListener(scn->refl.mWsListener);
}


Expand Down
2 changes: 1 addition & 1 deletion src/editor/Update_Frame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void App::update( float dt )


if (pSet->ssao)
UpdateSSAO(); // 🕳️
UpdateSSAO(mCamera); // 🕳️
if (pSet->gi)
UpdateGI(); // 🌄

Expand Down
4 changes: 2 additions & 2 deletions src/game/Game_Update.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ void App::update( float dt )
#endif


if (pSet->ssao)
UpdateSSAO(); // 🕳️
if (pSet->ssao) //-
UpdateSSAO(mCamera); // 🕳️
if (pSet->gi)
UpdateGI(); // 🌄

Expand Down

0 comments on commit 7b7d8b8

Please sign in to comment.