post processing

Everything about development and the OpenMW source code.
Post Reply
nicoo
Posts: 6
Joined: 30 Jun 2018, 20:00

post processing

Post by nicoo »

Hi,
after this discussion: viewtopic.php?f=2&t=5260

I'm trying to add some post processing effect. For now I try to fill the window with a white shader. you can take a look to my work: https://gitlab.com/njager/openmw/commit ... 122672ac9d

it's not working, I don't know why. If someone who knows OSG could give me a kick, I would appreciate that!
User avatar
AnyOldName3
Posts: 2666
Joined: 26 Nov 2015, 03:25

Re: post processing

Post by AnyOldName3 »

There's no geometry being drawn with that shader. Usually, post-processing is done by drawing a screen-sized square with the post-processing shader with the previous render target available as a texture.
nicoo
Posts: 6
Joined: 30 Jun 2018, 20:00

Re: post processing

Post by nicoo »

thx,
I did some modification to apply the shader on some `rootNode` (Define at line 21 of postprocessing.hpp)

https://gitlab.com/njager/openmw/commit ... 0ac2a94e06

I used this website, http://shdr.bkcore.com/, to check my white shader but I'm not able to make it work in openmw. I don't understand why...
so, as quick test, I applied the water shader on `rootNode`. The effect is dirty but at least something happen. If you want to test it, start the game, then pause it. For now I'm using the pause to turn on the effect (no way to turn it off though).

my white shader is still in the code but commented.

I don't know what kind of root node I should pass to my function, it seems I can pass node, geometry, light... A post process effect should affect everything rendered, so what root node should I target ?
raven
Posts: 66
Joined: 26 May 2016, 09:54

Re: post processing

Post by raven »

I am not an OSG user, so take this with a grain of salt.

As mentioned you need to create a quad. Attach it to your post processing camera. Then attach the camera to omw root node.

You will also need main camera render outputs as inputs for you post processing pass.

Have a look here (Rendering a scene to texture):
https://merlin.fit.vutbr.cz/wiki/index. ... ledge_base

A quick web search also produced this OpenSceneGraph NodeKit. It looks somewhat over engineered, but might get the job done:
https://github.com/cgart/osgPPU
User avatar
drummyfish
Posts: 154
Joined: 22 Oct 2017, 10:13
Contact:

Re: post processing

Post by drummyfish »

I'm in a hurry, can't read this carefully, but here's how I draw a textured fullscreen quad in OpenMW (to a screenshot):

https://gitlab.com/OpenMW/openmw/blob/m ... r.cpp#L813
A post process effect should affect everything rendered, so what root node should I target ?
It shouldn't affect GUI. If I remember correctly, RootNode is the root of everything, SceneRoot is the root of the rendered scene, so maybe that one. Here I have a little debugging helper which you can use to print the scene graph to get oriented in the nodes:

https://gitlab.com/drummyfish/osgdebug

There's also some console command you can use directly in OpenMW to do something similar.

When I have more time I'll get back to this thread :)
User avatar
AnyOldName3
Posts: 2666
Joined: 26 Nov 2015, 03:25

Re: post processing

Post by AnyOldName3 »

The console command is showscenegraph
User avatar
wazabear
Posts: 96
Joined: 13 May 2020, 19:31
Gitlab profile: https://gitlab.com/glassmancody.info

Re: post processing

Post by wazabear »

On the off chance you (or anyone else) is still interested after all these years. If i'm not mistaken Scrawl tried this using the EffectCompositor a while back, unfortunately looks like that work is forever lost. I played around with PP a month or two ago on my post_malone branch on gitlab if you want to get a rough idea of what needs to be done. Never quite figured out how to get the GUI to render. For some unfathomable reason EffectCompositor uses the vomit that is XML to define techniques, but it is worth looking at to see how they do things (it's also fairly simple for what it does).
User avatar
psi29a
Posts: 5355
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: post processing

Post by psi29a »

First things first... I believe having a working FBO that we can then render to SDL's OpenGL context is the first step here.

It's actually pretty crucial for many things, such as z-fighting solution... making the FBO's depth buffer 32-bit (as apposed to 24-bit) would resolve a few things I believe.

From there, we can attach PP on top of the FBO just before it goes to the SDL/OGL context.
Post Reply