Native Ambient Occlusion (SSAO) shader

Need help editing the game? Check for help here!

Moderators: Darksaber, General_Trageton, Forceflow

Native Ambient Occlusion (SSAO) shader

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Sun Sep 29, 2019 6:29 am

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.
You do not have the required permissions to view the files attached to this post.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Sun Sep 29, 2019 6:34 am

A few more screenshots:
ssao2-1.jpg
ssao2-2.jpg
ssao2-3.jpg
You do not have the required permissions to view the files attached to this post.

User avatar
Darksaber

Fleet Admiral (Administrator)
Posts: 10316
Joined: Mon Jan 10, 2000 12:01 am
Contact:

Post by Darksaber » Sun Sep 29, 2019 9:28 am

Wow :)
“You can please some of the people all of the time, you can please all of the people some of the time, but you can’t please all of the people all of the time”.”
- John Lydgate

Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

User avatar
Trevor
Cadet 1st Class
Posts: 188
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Sun Sep 29, 2019 2:33 pm

Wow indeed, cant wait to download
Trev

JeremyaFr
Lieutenant Commander
XWAU Member
Posts: 1605
Joined: Mon Jan 18, 2010 5:52 pm
Contact:

Post by JeremyaFr » Sun Sep 29, 2019 3:03 pm

Good :thumbs:

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Sun Sep 29, 2019 8:17 pm

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
You do not have the required permissions to view the files attached to this post.

User avatar
Trevor
Cadet 1st Class
Posts: 188
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Sun Sep 29, 2019 9:26 pm

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

User avatar
ual002
Ensign
Galactic Empire
Posts: 488
Joined: Wed Sep 24, 2008 2:23 am

Post by ual002 » Mon Sep 30, 2019 2:13 am

Good lord.
For the glory of his majesty Emperor Palpatine! Image Image Image Image

Bman
Lieutenant JG
Posts: 703
Joined: Mon Apr 05, 2004 11:01 pm

Post by Bman » Mon Sep 30, 2019 4:49 am

Nice
W-I-P: ISD-II, XQ-1 Platform1, (Imp) Escort Carrier, Misc, & TFTC.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Mon Sep 30, 2019 5:24 am

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.

User avatar
keiranhalcyon7
Ensign
Posts: 274
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » 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.

Kampher
Cadet 3rd Class
Posts: 34
Joined: Tue May 09, 2006 11:01 pm

Post by Kampher » Tue Oct 01, 2019 6:36 pm

This looks amazing! Thank you for your work on this. I can't wait.

Turgidson
Cadet 3rd Class
Posts: 38
Joined: Sun Aug 25, 2019 10:02 pm

Post by Turgidson » Tue Oct 01, 2019 8:35 pm

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.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » 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 ;)

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!
You do not have the required permissions to view the files attached to this post.

Michal
Cadet 1st Class
Posts: 137
Joined: Sun May 05, 2002 11:01 pm
Contact:

Post by Michal » Wed Oct 02, 2019 9:45 am

Wow

User avatar
Mark_Farlander
Ensign
Rebel Alliance
Posts: 357
Joined: Tue Jan 16, 2018 10:47 pm

Post by Mark_Farlander » Wed Oct 02, 2019 10:21 am

Looks promising.

User avatar
General_Trageton

Fleet Admiral (Administrator)
Posts: 12128
Joined: Fri Apr 27, 2001 11:01 pm
Contact:

Post by General_Trageton » Wed Oct 02, 2019 11:57 am

Nice! Looking forward to testing that with the VSD :D
Your ship, Captain. I need a drink. - Vince Trageton
Vince T's Modding HQ | Blue Phantom Chronicles WIki | My Steam Workshop

User avatar
Trevor
Cadet 1st Class
Posts: 188
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Wed Oct 02, 2019 4:54 pm

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
Last edited by Trevor on Wed Oct 02, 2019 5:45 pm, edited 2 times in total.

User avatar
Darksaber

Fleet Admiral (Administrator)
Posts: 10316
Joined: Mon Jan 10, 2000 12:01 am
Contact:

Post by Darksaber » Wed Oct 02, 2019 5:42 pm

New word of the day Occlude, honestly never heard of that one before

Sorry, to go off topic

Carry on :D
“You can please some of the people all of the time, you can please all of the people some of the time, but you can’t please all of the people all of the time”.”
- John Lydgate

Good Things Come To Those Who Wait....
Darksaber's X-Wing Station

User avatar
Jaeven
Ensign
Galactic Empire
Posts: 399
Joined: Mon Mar 30, 2015 3:18 am

Post by Jaeven » Wed Oct 02, 2019 5:53 pm

Hot damn that looks good.

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Wed Oct 02, 2019 6:19 pm

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... :)

User avatar
Trevor
Cadet 1st Class
Posts: 188
Joined: Thu Dec 04, 2014 7:11 pm

Post by Trevor » Wed Oct 02, 2019 8:12 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...
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

blue_max
Ensign
XWAU Member
Posts: 324
Joined: Wed Mar 20, 2019 5:12 am

Post by blue_max » Wed Oct 02, 2019 9:32 pm

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...

User avatar
keiranhalcyon7
Ensign
Posts: 274
Joined: Tue Jan 02, 2018 6:41 am

Post by keiranhalcyon7 » Wed Oct 02, 2019 9:52 pm

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.

Turgidson
Cadet 3rd Class
Posts: 38
Joined: Sun Aug 25, 2019 10:02 pm

Post by Turgidson » Wed Oct 02, 2019 9:59 pm

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)

Post Reply