jwwalker wrote: ↑Tue Jul 05, 2022 1:10 am
While I was waiting for more help or inspiration on the questions here, I decided to try a less programmatic approach, writing my first compositor script. Much to my surprise, it worked, pretty much right away. So my question about node aliases has become moot.
Great!
In my experience even highly configurable (from C++) compositor setups are often arranged by having "baked" nodes and then modifying them from C++ mix and matching to achieve what you need.
jwwalker wrote: ↑Tue Jul 05, 2022 1:10 am
Here's the script, please let me know if anything looks wrong or inefficient. I can't find any discussion of that rtv
block in the Ogre manual, I'm just imitating other scripts.
The script is alright. I have two suggestions:
1- Merge your clear passes for better tiler friendliness (I'm skipping irrelevant parts):
Code: Select all
target firstPass
{
pass render_scene
{
load
{
all clear
clear_colour 0.2 0.4 0.6 1
}
rq_first 0
rq_last max
}
}
target renderwindow
{
pass render_quad
{
load
{
all clear
clear_colour 0.2 0.4 0.6 1
}
material JWDepthOfField
input 0 firstDepth
input 1 firstPass
}
}
That is, the clear pass was removed and moved into the "load" section. This is more tiler friendly (e.g. TBDRs like mobile and Apple M1, and hybrid tilers like NVIDIA post-Maxwell and AMD post-Vega GPUs)
2- Consider using dont_care if it applies to you.
For example if I can assume:
-
firstPass will render to the whole screen (no pixel is left untouched by the triangles) with fully opaque triangles (i.e. alpha blending over the clear colour breaks this assumption).
-
renderwindow will render to the whole screen (same as assumption #1)
-
renderwindow doesn't need the depth buffer contents (i.e. the render_quad doesn't read renderwindow's depth buffer at all)
-
Even if assumption #3 isn't true, the depth buffer values written by renderwindow don't matter after this pass
Then we can convert your script to the following:
Code: Select all
target firstPass
{
pass render_scene
{
load
{
all clear // We still the depth (& possibly stencil) buffer to be cleared
colour dont_care // See assumption #1. We are now overriding the colour section (since it was just set to clear in previous line)
}
rq_first 0
rq_last max
}
}
target renderwindow
{
pass render_quad
{
load
{
all dont_care // See assumption #2 & #3
}
store
{
depth_stencil dont_care // See assumption #4
}
material JWDepthOfField
input 0 firstDepth
input 1 firstPass
}
}
If you are using them wrong, RenderDoc is also great for debugging incorrect usage of dont_care:
In this example, the depth value was set to store -> depth dont_care; and later we read from it; which means there's a bug (it should've been set to store -> depth = store_or_resolve).