Page 1 of 4

Native Ambient Occlusion (SSAO) shader

Posted: Sun Sep 29, 2019 6:29 am
by blue_max
This is still a little rough; but here's a preview of the next effect I'm working on: SSAO
ssao1-1.jpg
ssao1-2.jpg
ssao1-3.jpg
It can be combined with the bloom effect but I disabled that for these screenshots.

Re: Native Ambient Occlusion (SSAO) shader

Posted: Sun Sep 29, 2019 6:34 am
by blue_max
A few more screenshots:
ssao2-1.jpg
ssao2-2.jpg
ssao2-3.jpg

Re: Native Ambient Occlusion (SSAO) shader

Posted: Sun Sep 29, 2019 9:28 am
by Darksaber
Wow :)

Re: Native Ambient Occlusion (SSAO) shader

Posted: Sun Sep 29, 2019 2:33 pm
by Trevor
Wow indeed, cant wait to download
Trev

Re: Native Ambient Occlusion (SSAO) shader

Posted: Sun Sep 29, 2019 3:03 pm
by JeremyaFr
Good :thumbs:

Re: Native Ambient Occlusion (SSAO) shader

Posted: Sun Sep 29, 2019 8:17 pm
by blue_max
Thanks guys. To be honest, it is a little rough and there's a minor performance hit; but I'll continue to refine this shader in the near future. I'm currently trying to contact the original author of the shader before releasing it. Otherwise I guess I can code my own version as well.
ssao3.jpg
ssao4.jpg

Re: Native Ambient Occlusion (SSAO) shader

Posted: Sun Sep 29, 2019 9:26 pm
by Trevor
Oh, I see an error in your last screenshot, you are including engine glow in AO which you shouldn't (they show on the x-wing as 4 quads) otherwise the AO shots all look good and accurate.
Lights of course should always be full-bright too, which I actually just noticed, so maybe a second pass accounting for illumination is needed? (see hangar ceiling and x-wing cockpit lights are being occluded when they are sources of emission)

Trev

Re: Native Ambient Occlusion (SSAO) shader

Posted: Mon Sep 30, 2019 2:13 am
by ual002
Good lord.

Re: Native Ambient Occlusion (SSAO) shader

Posted: Mon Sep 30, 2019 4:49 am
by Bman
Nice

Re: Native Ambient Occlusion (SSAO) shader

Posted: Mon Sep 30, 2019 5:24 am
by blue_max
You're a keen observer, Trevor. Yes indeed, I just fixed the engine glow and the light textures. I'm using the bloom mask that is later used to compute the bloom effect to fix the light textures, so I guess people may have to combine the bloom shader and SSAO.

Re: Native Ambient Occlusion (SSAO) shader

Posted: Mon Sep 30, 2019 9:19 am
by keiranhalcyon7
Nah, just move the code that generates that mask up front, and run it if either one of the the two effects are active.

Re: Native Ambient Occlusion (SSAO) shader

Posted: Tue Oct 01, 2019 6:36 pm
by Kampher
This looks amazing! Thank you for your work on this. I can't wait.

Re: Native Ambient Occlusion (SSAO) shader

Posted: Tue Oct 01, 2019 8:35 pm
by Turgidson
Wow, looks great. With all your hard work, XWA may get modern, state-of-the art graphics. For a 20-years old game that's hugely impressive.

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 4:45 am
by blue_max
Thanks for your support guys. Yes, the idea is to improve the graphics rendering of this game to a more modern level -- well, I think that's essentially the common goal of the XWAU team anyway. It does look a bit better; but don't expect something like the recent Star Wars Battlefront games ;)

ssao5-1.jpg
ssao5-2.jpg
keiranhalcyon7 wrote:
Mon Sep 30, 2019 9:19 am
Nah, just move the code that generates that mask up front, and run it if either one of the the two effects are active.
Indeed! I ended up doing this exactly, thanks for your suggestion!

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 9:45 am
by Michal
Wow

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 10:21 am
by Mark_Farlander
Looks promising.

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 11:57 am
by Vince T
Nice! Looking forward to testing that with the VSD :D

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 4:54 pm
by Trevor
WOWOWOWOW, I am amazed how good it looks on the ISD.

Now, can I ask what options we will get? i.e. can we change the test distance (i.e. setting the test to say 500m would effectively occlude all interior sections)

could we set the number of times it is calculated?

What I am thinking here is ExteriorAO (using a long test distance and low power for space, high power for atmosphere) and InteriorAO (using short test distance and higher power as a basic DIR (Diffuse Inter-Reflection))

Trev

EDIT, the default MXAO shader in reshade has a disabled "Indirect Lighting" option * which is what I mean by DIR... I cant test however but since its part of the shader can you enable it ?
*

Code: Select all

#ifndef MXAO_ENABLE_IL

 #define MXAO_ENABLE_IL			0	//[0 or 1]	Enables Indirect Lighting calculation. Will cause a major fps hit.

#endif

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 5:42 pm
by Darksaber
New word of the day Occlude, honestly never heard of that one before

Sorry, to go off topic

Carry on :D

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 5:53 pm
by Jaeven
Hot damn that looks good.

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 6:19 pm
by blue_max
Thanks for your comments guys. I'm using a somewhat simple SSAO implementation and learning how it works at the same time. Right now, you can set how many iterations/samples you want up to a maximum of 4/16. The radius of the effect, the attenuation/falloff, the sub-resolution used to compute it and the blur.

I'm *just* realizing some of the limitations of SSAO: you can either get the parameters to work nice on distant objects, or get it to work on close objects -- but probably not both at the same time. If I disable the perspective correction for the radius, then I can get it working on both distant and close objects; but then close objects (like the cockpit) tend to obscure distant objects a little bit. I guess I can put switches to disable/enable perspective-correct SSAO and maybe enable multiple passes with different settings as you suggest, Trevor (although that will probably come in version 2.0)

The other problem is that close objects will always interact with distant objects anyway because the back faces of closer objects are culled and the depth values for those faces are lost. So I'm not sure if there's anything that can be done about that...

Some sort of basic Diffuse Inter-Reflection should be possible now, yes -- I just have to figure out a nice way to compute it and mix it. I'm not implementing MXAO directly (that shader is a bit too complex for me right now); but I'm aware that it does some form of DIR and I'm trying to figure out how to translate the relevant bits. So, maybe in the near future... :)

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 8:12 pm
by Trevor
The other problem is that close objects will always interact with distant objects anyway because the back faces of closer objects are culled and the depth values for those faces are lost. So I'm not sure if there's anything that can be done about that...
Ah yes, round the x-wing cannons and the nearest ISD turbolaser… hmm, yeah that is a shortcoming of SSAO compared to world AO - but then world AO is very slow since it does everything so compromise must be made.

Also, that's cool you are programming it yourself, it means you will know more about it and should be able to read it back easier since its in your own dialect/style.

Any chance of someone enabling MXAO_ENABLE_IL =1 in reshade preprocessor and showing me some screenshots, the best Ive seen is a garbled mess (where apparently its using the CFB as a normal map and combining with an odd z-buffer... :eek: )

Trev

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 9:32 pm
by blue_max
I would also like to see an example of MXAO with IL enabled :) I know DarHan posted some config in the Bloom thread; but it didn't work for me when I tried it and I haven't gone back to fiddle with it to make it work.

Anyway, now that I think about it, there might be something I can do about close objects occluding distant objects. I could probably have two SSAO buffers: one for distant objects and one for close objects/cockpits but both sharing the same depth buffer. The thing is, in the image above the ISD is actually fully rendered and then the X-Wing is rendered on top of it. So, at some point, the depth buffer contains all the info to shade the ISD but then this information is destroyed when the X-Wing is rendered. Maybe if I introduce a Z-threshold and switch the render targets at the right time... Maybe...

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 9:52 pm
by keiranhalcyon7
blue_max wrote:
Wed Oct 02, 2019 6:19 pm
The other problem is that close objects will always interact with distant objects anyway because the back faces of closer objects are culled and the depth values for those faces are lost. So I'm not sure if there's anything that can be done about that...
There's always the chance that Jeremy knows where back face culling is done and can disable it with a hook. I imagine the render pipeline portion of the code is rather complex, though.

The cockpit images up thread look pretty good, but IMO the change in the ISD images is all but unnoticeable due to the game engine's lack of shadows (which are probably a pipe dream to add).
Trevor wrote:
Wed Oct 02, 2019 8:12 pm
Ah yes, round the x-wing cannons and the nearest ISD turbolaser… hmm, yeah that is a shortcoming of SSAO compared to world AO - but then world AO is very slow since it does everything so compromise must be made.
The appropriate solution would probably be baked AO maps... which may not be totally out of the question for ddraw to load on the side.

Re: Native Ambient Occlusion (SSAO) shader

Posted: Wed Oct 02, 2019 9:59 pm
by Turgidson
blue_max wrote:
Wed Oct 02, 2019 4:45 am
Thanks for your support guys. Yes, the idea is to improve the graphics rendering of this game to a more modern level -- well, I think that's essentially the common goal of the XWAU team anyway. It does look a bit better; but don't expect something like the recent Star Wars Battlefront games ;)
As far as I know, there's no VR support on the PC version of Battlefront II (and only 20 minutes on the PS4). So I'd actually expect more. :-D
(now I'd need to find a cheap VR set)