Help with SSAO shader.

Everything about development and the OpenMW source code.
Post Reply
drshfyersrg
Posts: 8
Joined: 17 Sep 2017, 23:52
Github profile: https://github.com/erherhh4herh

Help with SSAO shader.

Post by drshfyersrg » 18 Sep 2017, 00:03

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: 2050
Joined: 18 Feb 2012, 11:51
Contact:

Re: Help with SSAO shader.

Post by scrawl » 18 Sep 2017, 00:24

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
Github profile: https://github.com/erherhh4herh

Re: Help with SSAO shader.

Post by drshfyersrg » 18 Sep 2017, 01:02

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: 3394
Joined: 29 Sep 2011, 10:13
Github profile: https://github.com/psi29a/
Contact:

Re: Help with SSAO shader.

Post by psi29a » 18 Sep 2017, 08:38

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
Github profile: https://github.com/erherhh4herh

Re: Help with SSAO shader.

Post by drshfyersrg » 19 Sep 2017, 02:02

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

No commit in 2 months.

User avatar
psi29a
Posts: 3394
Joined: 29 Sep 2011, 10:13
Github profile: https://github.com/psi29a/
Contact:

Re: Help with SSAO shader.

Post by psi29a » 19 Sep 2017, 06:20

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

Who is online

Users browsing this forum: No registered users and 2 guests