Help with SSAO shader.

Everything about development and the OpenMW source code.
Post Reply
drshfyersrg
Posts: 8
Joined: 17 Sep 2017, 23:52

Help with SSAO shader.

Post by drshfyersrg »

For whatever reason, nobody has been working on an SSAO shader :( I'm very nooby to glsl, but I decided to take matters into my own hands. I noticed in the obj frag and terrain frag that there's a depth float. I used this and ported over the opengl example ssao shader to OSG. (https://github.com/McNopper/OpenGL/blob ... .frag.glsl)

I added this ssao to both my terrain and obj frag. No errors, but when debugging the output, it's empty: https://i.imgur.com/faSFVZL.png (should show AO). One thing I did notice is that there seems to be no projection matrix available in either the terrain frag or obj frag...

EDIT: Nope, I'm just stupid... the matrices are in the vertex shaders...

Changed a couple of things in the code: https://pastebin.com/raw/MnCzxCr7
Please and thank you.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Help with SSAO shader.

Post by scrawl »

Hm, you're trying to add this to the terrain and object shaders? That's not how it works. For post effects like SSAO, you need to render a full-screen quad with the scene and depth textures as input. Doing them in the object shader itself won't work, because you need the result of surrounding pixels as an input, which obviously haven't been rendered yet.

There's a discussion here on the possibility of supporting post effects in a generic manner.
drshfyersrg
Posts: 8
Joined: 17 Sep 2017, 23:52

Re: Help with SSAO shader.

Post by drshfyersrg »

Oh, haha. I found it odd that there was no post-processing to speak of, so I just assumed this was how it was done :D
Too bad the project isn't active. thanks for the quick answer, though! :)
User avatar
psi29a
Posts: 5355
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Help with SSAO shader.

Post by psi29a »

drshfyersrg wrote: 18 Sep 2017, 01:02 Too bad the project isn't active. thanks for the quick answer, though! :)
What project and why do you reason that?
drshfyersrg
Posts: 8
Joined: 17 Sep 2017, 23:52

Re: Help with SSAO shader.

Post by drshfyersrg »

The one referenced in the thread linked (https://github.com/scrawl/openmw/tree/effectcompositor)

No commit in 2 months.
User avatar
psi29a
Posts: 5355
Joined: 29 Sep 2011, 10:13
Location: Belgium
Gitlab profile: https://gitlab.com/psi29a/
Contact:

Re: Help with SSAO shader.

Post by psi29a »

I think it has more to do with Scrawl's lack of time than it being a dead project. I could be wrong of course, the discussion about it elsewhere on the forum and no one has really stepped up until now. ;)

If you decide to work on and improve it, then it isn't dead is it? 8-)
Post Reply