BGE 2D Filters: filters run per scene now (fix for [#18152]) - it (slightly) breaks backward compatibility !!!

Originally we had 2DFilters (m_filtermanager) stored in RenderTools. That way filters were stored globally and were being called once per each scene. This was producing two big problems: (1) performance and (2) flexibility of use.

(1) Performance - To run the filters 2X == 2X slower
(2) flexibility of use - Very often we want the filter in the scene but not in the UI for example.

For those reasons I believe that 2DFilters with multiple scenes was very useless or unpredictable. I hope they work fine now.
To make it work as before (2.4) you can simply recreate the 2dfilter actuators across the scenes.

* * * * *

Imagine that we have:
(a) Main Scene
(b) Overlay Scene

in Main Scene the Z Buffer and RGB will be from the main scene.
in Overlay Scene the Z Buffer will be from the Overlay Scene and the RBG buffer is from both [(a + 2D Filter) + b].

So in pseudo code if we have a,b,c,d,e scenes we have: (2DFilterE(2DFilterD(2DFilterC(2DFilterB(2DFilterA(a) + b) + c) + d) + e)
This commit is contained in:
Dalai Felinto
2010-03-03 06:38:47 +00:00
parent c26486f207
commit 0cad3ae24c
19 changed files with 46 additions and 60 deletions

View File

@@ -334,6 +334,11 @@ void KX_KetsjiEngine::RenderDome()
it++;
}
// Part of PostRenderScene()
m_rendertools->MotionBlur(m_rasterizer);
scene->Render2DFilters(m_canvas);
// no RunDrawingCallBacks
// no FlushDebugLines
}
m_dome->BindImages(i);
}
@@ -362,11 +367,7 @@ void KX_KetsjiEngine::RenderDome()
1.0
);
}
m_dome->Draw();
// run the 2dfilters and motion blur once for all the scenes
PostRenderFrame();
EndFrame();
}
@@ -859,6 +860,7 @@ void KX_KetsjiEngine::Render()
it++;
}
PostRenderScene(scene);
}
// only one place that checks for stereo
@@ -908,6 +910,7 @@ void KX_KetsjiEngine::Render()
it++;
}
PostRenderScene(scene);
}
} // if(m_rasterizer->Stereo())
@@ -1313,20 +1316,16 @@ void KX_KetsjiEngine::RenderFrame(KX_Scene* scene, KX_Camera* cam)
if (scene->GetPhysicsEnvironment())
scene->GetPhysicsEnvironment()->debugDrawWorld();
m_rasterizer->FlushDebugLines();
//it's running once for every scene (i.e. overlay scenes have it running twice). That's not the ideal.
PostRenderFrame();
// Run any post-drawing python callbacks
scene->RunDrawingCallbacks(scene->GetPostDrawCB());
}
void KX_KetsjiEngine::PostRenderFrame()
/*
To run once per scene
*/
void KX_KetsjiEngine::PostRenderScene(KX_Scene* scene)
{
m_rendertools->Render2DFilters(m_canvas);
m_rendertools->MotionBlur(m_rasterizer);
scene->Render2DFilters(m_canvas);
scene->RunDrawingCallbacks(scene->GetPostDrawCB());
m_rasterizer->FlushDebugLines();
}
void KX_KetsjiEngine::StopEngine()