Page 1 of 1

Help with SSAO shader.

Posted: 18 Sep 2017, 00:03
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.

Re: Help with SSAO shader.

Posted: 18 Sep 2017, 00:24
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.

Re: Help with SSAO shader.

Posted: 18 Sep 2017, 01:02
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! :)

Re: Help with SSAO shader.

Posted: 18 Sep 2017, 08:38
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?

Re: Help with SSAO shader.

Posted: 19 Sep 2017, 02:02
by drshfyersrg
The one referenced in the thread linked (https://github.com/scrawl/openmw/tree/effectcompositor)

No commit in 2 months.

Re: Help with SSAO shader.

Posted: 19 Sep 2017, 06:20
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-)