Marty McFly's Ambient Obscurance (MXAO) with IL

More
2 years 4 months ago #621 by Marty McFly
Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
The AO itself probably looks like this raytraced AO there but as it's not integrated into the lighting system, you won't get such results.
The following user(s) said Thank You: jmx777
The topic has been locked.
More
2 years 4 months ago - 2 years 4 months ago #622 by SurfNSlide
Replied by SurfNSlide on topic Marty McFly's Ambient Obscurance (MXAO) with IL
HI, I'm pretty new to all this stuff, so maybe my questions are a bit dumb ^^

1. Is the PDF description file in the 2.0 version (downloadable in OP) still valid for the current 3.x.x version? If not, where is a manual for a noob like me?

2. I tried several presets I downloaded for Far Cry 5 and then also made one of my own reusing a lot of stuff and tweaking it to fit my personal taste to get some experience with all this stuff. MXAO (and also MartyMcFly DOF) seem to work in none of them (as I dont see any changes when switchign them on or off. I also tried with ridicolous values, so there must be another probhlem than my eyes being too bad.
Any troubleshooting tips for those?

Im using 3.1.1 (since newer versions seem to have problems with EAC in FC5).
From what I understand, the preprocessing values are important for that, heres mine:


RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=1000.0,RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=0,RESHADE_DEPTH_INPUT_IS_REVERSED=0,RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=1
I also tried reversed on 1 and did reload after, no change

3. Can I also profit from the better SMAA shader posted a few pages before?

best regards
Andy
Last edit: 2 years 4 months ago by SurfNSlide.
The topic has been locked.
More
2 years 4 months ago #623 by JBeckman
For Far Cry 5 it might be that it's sending or receiving network traffic and this is detected by ReShade which in turn disables depth.

This doesn't mean you're actively playing co-op or such but the game would periodically check the status for say the ongoing challenges, the arcade mode or the Bloomberg telemetry functionality.

Reversed with logarithmic should work for depth detection assuming the game process isn't sending enough data back and forth for ReShade to toggle off the depth buffer functionality and then turn it on if there's less network activity.

I think there was also some other issue with the game too where ReShade can lose the depth hook but I don't really know what causes this, perhaps the newer versions of ReShade with the depth buffer settings could work around this but then you'd run into EAC having blocked ReShade though it's keeping the existing whitelist for previous versions.
The following user(s) said Thank You: SurfNSlide
The topic has been locked.
More
2 years 4 months ago #624 by SurfNSlide
Replied by SurfNSlide on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Thanks for the info. So I’ll try it in offline mode I suppose.

Any ideas why MXAO isn’t working? Or is it the same reasons?

What about the readme of 2.0? I’m really trying to understand it, but without a documentation I’m lost since I don’t have any experience in shader coding or programming at all For that matter.
The topic has been locked.
More
2 years 4 months ago - 2 years 4 months ago #625 by Marty McFly
Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
If it works, the ingame documentation is very self explanatory, hover over values to see some short information. No matter what settings you useyyou should at least see some sort of SSAO, if not, something is still borked with the depth buffer. Try enabling debug mode in MXAO for easier tweaking and also try the Display depth shader, that should show you the depth buffer. If it only contains black or white, something is wrong. Readme is not 100 percent up to date but for most of the values, it suffices. I wanted to update after I add my cone traced AO but I'm kinda stuck atm.
Last edit: 2 years 4 months ago by Marty McFly.
The following user(s) said Thank You: SurfNSlide
The topic has been locked.
More
2 years 4 months ago #626 by SurfNSlide
Replied by SurfNSlide on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Thanks, Im gonna look over the readme 2.0 and try to figure out if maybe i screwed up some settings or the network traffic is the problem as soon as im back at home with my gaming PC ;)

Pretty sure its not working at all right now, since the debug options didnt show me anything, meaning one option all black (or white??) and the other just the exact same scenery as before if I recall correctly, not exactly sure anymore. I will try it out again, as well.

So these Preprocessing definitons should be correct now, right?!:
RESHADE_DEPTH_LINEARIZATION_FAR_PLANE=1000.0,RESHADE_DEPTH_INPUT_IS_UPSIDE_DOWN=0,RESHADE_DEPTH_INPUT_IS_REVERSED=1,RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=1

Do I also need this maybe?:
MXAO_MIPLEVEL_AO = 0
 MXAO_MIPLEVEL_IL = 2
 MXAO_ENABLE_IL = 0
 MXAO_ENABLE_BACKFACE = 1

Maybe with other values?! But that shouldnt prevent it from working in general I guess, since it does use standard setting if I dont specify otherwise right? Or is it already included the Shader at Version 3.4.x anyway (the one distributed with the standard shader package), and I dont need it at all for now...?!

Sorry for so many questions ^^
The topic has been locked.
More
2 years 4 months ago - 2 years 4 months ago #627 by SurfNSlide
Replied by SurfNSlide on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Ok, I was faster home than expected and straight went to testing ^^

EDIT: I just understood what u meant by Display depth shader, will try that as well, thanks

Since this is a lot I allowed myself to double post here for the sake of a clear arrangement in case other people might read this later on.
  • New findings: Weirdly, both MXAO and DOF work when i open the world map of the game, which features 3D Elements, rotational camera etc., so its quite nice to test this stuff out and play with the values, to get a better feeling forhow this works... still no idea what prevents it from working in the game though... EDIT: I just understood what u meant by Display depth shader, will try that as well, thanks. At least, limiting the network traffic doesnt seem to cut it since uplay in offline mode before starting didnt change a thing...
  • Debugging: AO/IL gives me very clealy the AO'ed areas, the other one just complete white with some rectangular black shapes in it.

As always, new questions arose:
  1. Is the "Sample Count" from the description of 2.0 referring to "Sample Quality" (Very Low - max) setting of 3.4.x? It sadly doesnt provide the sample count on each setting respectively, which I would like to know. Im sure you can help me with that?!

  2. Very interesting would be also to be able to somehow have 2 settings of this, one cranked all the way up for screenshots and one form actual playing. But as far as my research on this came, its not really possible without an extraordinary amount of work (and understanding of shading etc, which I dont have)?!

  3. I have to set normal Bias all the way up betweeen .35 and .4 to get rid of unwanted artifacts (horizontal lines on water). I also tried playing with all the other values that could cause or impact this I could think of, but nothing has proven effective... Isn't such a high value also gonna cost me much wanted details? (Wanted to provide some pictures, but weirdly my screenshot tools including reshade itself didnt work at the time, need to look after that)

  4. Where to find the Indirect Lighting, Dither Size, Blur and Smoothed Normals option in this version?
Last edit: 2 years 4 months ago by SurfNSlide.
The topic has been locked.
More
2 years 4 months ago - 2 years 4 months ago #628 by Marty McFly
Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Aight, I'll try to answer everything:

You don't need to specify preprocessor defines unless you want to change them from the standard value. My doc recommends to add them nonetheless so you have them in case you need to change them.

DisplayDepth is supposed to give you a black-white gradient, depending on how far objects are. If you actually see stuff there, everything is fine. If white is background stuff and black is foreground stuff, AO and DoF can work with it. If this image was plain white or black no matter what's onscreen, depth buffer would be borked.

The AO debug option should show you the clean AO. If that one's completely white, there's no depth info. If it's looking very glitchy and weird, depth buffer works but the preprocessor defines are wrongly configured.

Sample count indeed got replaced by sample quality because I saw almost everyone using wrong values (100 samples are WAY too high, yet people used it and complained about performance). Also 3.X has a new sampling algorithm that allows to use less samples with the same quality, thus increasing performance. I decided to untie the user settings from the shader intrinsics a bit so if I made some sort of adjustments that improve visual quality, I can just lower the quality under the hood so it looks same to end user with better performance (2.X lower sample limit was 8, current 3.X "very low" is 4, which look same). I already added information how many samples here on my drive but haven't uploaded the changes yet, mostly because I wanted to work out the new AO type + a better filter, where I'm currently stuck with the latter.

To use 2 different presets, well, you can just create a second config for ReShade. In the config tab on the very top, click "+" and create your new config. Then just switch to your screenshot one and configure as you like. Remember though that these configs all use the same preprocessor stuff so if you use IL in one config, it'll be enabled for the other one as well. What you probably read about what's difficult to do is most likely using MXAO 2 times at once in 1 config, that's not possible without changes in code.

Horizontal lines (that flicker) most likely mean that you're using logarithmic depth buffer when you don't need it (the log/exp operation costs much data precision so sometimes false AO is calculated). If those lines merely follow the 3D geometry, then that's just how the water surface works. Normal bias basically just removes AO from angles below a certain angle, mostly landscape has surfaces with 160 170 degrees angle between them which in practice would not occlude each other at all, that's where normal bias kicks in. You do lose some details but on low values, only those that would not show up in real life as well. 0.6+ is too high in my opinion, as surfaces require to face each other at almost 90 degrees to cause shadowing. You should feel yourself what looks natural.

Indirect Lighting and smoothed normals are controlled by preprocessor defines ( MXAO_ENABLE_IL = 1 and MXAO_SMOOTHNORMALS = 1), dither size got removed because of my new sampling, blur is now fixed size, also due to my new sampling (the shader jitters samples in a 4x4 pattern so a blur shader needs that exact size to eradicate all blur).

To keep trac what preprocessor defines are available, just open the MXAO.fx file with a text editor of your choice, at the very top there's a list. You can tweak their values either there or in the UI, depends on you. The values you set in the UI will override those in shadercode however.
Last edit: 2 years 4 months ago by Marty McFly.
The following user(s) said Thank You: SurfNSlide
The topic has been locked.
More
2 years 4 months ago - 2 years 4 months ago #629 by SurfNSlide
Replied by SurfNSlide on topic Marty McFly's Ambient Obscurance (MXAO) with IL

Marty McFly wrote: Aight, I'll try to answer everything:

Thanks for that extensive information, really appreciate it. :cheer: Im answering specifically to some parts below:

DisplayDepth is supposed to give you a black-white gradient, depending on how far objects are. If you actually see stuff there, everything is fine. If white is background stuff and black is foreground stuff, AO and DoF can work with it. If this image was plain white or black no matter what's onscreen, depth buffer would be borked.

Seems to be alright in the world map:


Only in the furthest zoomed out level its 2D-ish as its seems:


Sadly though, its all black in game, as kind of expected at this point... Im currently trying to get some people talking who somehow got this to work according to their youtube videos.
Both (MXAO and DOF) also consume over 1 ms GPU time respectively, so those shaders are doing somehting,...or is that just normal, since they always do taht when activated?

The AO debug option should show you the clean AO. If that one's completely white, there's no depth info. If it's looking very glitchy and weird, depth buffer works but the preprocessor defines are wrongly configured. [...] Horizontal lines (that flicker) most likely mean that you're using logarithmic depth buffer when you don't need it (the log/exp operation costs much data precision so sometimes false AO is calculated)

Again, youre right, deactivating logarithmic input interpretation seems to be the appropriate fix:


Reversed seems to be the right choice though, since without it I get an opposed image basically.

The culling mask however, just gives me this though?!:


[...]You do lose some details but on low values, only those that would not show up in real life as well. 0.6+ is too high in my opinion, as surfaces require to face each other at almost 90 degrees to cause shadowing. You should feel yourself what looks natural.

Well, as I stated before, I didnt need to go up to 0.6 (maybe you didnt see the point before the numbers? xD, trying to make that clearer this time). But even 0.38 - 0.4, which indeed was needed to get those lines in the water away, was too much for my taste (at least on that world map, which may be different from actual in-game, but well hopefully see about that)... Im pretty fine with 0.256, at what those screenshots were taken. :)

...What you probably read about what's difficult to do is most likely using MXAO 2 times at once in 1 config, that's not possible without changes in code.

Exactly. Would be quite elegant though to have like MXAO_light and MXAO_full (and maybe the same for SMAA or some others as well) then just press one hotkey, linked to all of them, switching all the "lights" off, the "fulls" on, taking a screenshot, then vice versa. But I guiess I just gotta keep dreaming then :lol:

To use 2 different presets, well, you can just create a second config [...] Remember though that these configs all use the same preprocessor stuff so if you use IL in one config, it'll be enabled for the other one as well...

Pretty much what I suspected/feared, after all I've read on that subject so far. Is there a way to maybe create a hotkey for that at least?, Otherwise, switching would become even more inconvenient, as it already is due to reloading shaders etc...
Shouldnt I be able to still have different settings for the IL (e.g. deactiavting it), or are those options gone from the UI all the way (meaning they dont show up when I add those pre definitions)?

[...] (the shader jitters samples in a 4x4 pattern so a blur shader needs that exact size to eradicate all blur).

Can you elobarate that last sentence? I dont quite understand what is meant by exact size especially... :huh:

And one last: It says in your docu also to put MXAO all the way to the top of the list to be the first shader being applied, but doesnt it make more sense to have Ambient Lighting even before that, since it changes the actual effect of AO du to other light in my environment?! Or am I missing something here?

Best regards
Last edit: 2 years 4 months ago by SurfNSlide.
The topic has been locked.
More
2 years 4 months ago - 2 years 4 months ago #630 by SurfNSlide
Replied by SurfNSlide on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Since I cant add any more links...

Could this maybe help me? Any progress on that depthtool shader in the last 2 months?
reshade.me/forum/shader-troubleshooting/...is-it-possible#25766

more porecisely, any of the ones found here:
github.com/BlueSkyDefender/Depth3D/tree/master/Shaders

I also read that my driver based Transparency SGSSAA could cause problems, any thoughts on that? Or would it also cause ReShade to not work at all if it were causing the problem?
Last edit: 2 years 4 months ago by SurfNSlide.
The topic has been locked.
More
2 years 4 months ago - 2 years 4 months ago #631 by Marty McFly
Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
AO shader works as usual when depth buffer is borked, just gets no AO data as result so you don't see anything. Checking if depth buffer is valid would give a static overhead so I decided against it.

Culling mask is correct, but I removed it in the latest update anyways because it sometimes missed fine scale AO.

I saw your values of 0.38 to 0.4, I merely stated that those are within acceptable range, 0.6 and higher would be too high.

Switching configs doesn't require reloading shaders, that's the whole point of it. Preprocessor is a text stitching tool that basically creates unique shader files, depending on what you set the preprocessor defines to. So changing those requires reloading (recompiling) the shaders, whereas switching configs just provides different uniform values to the shaders so those can be switched in realtime. Exactly how some visual settings in games require game restart, others don't.

About the sample/blur stuff, you need to know how SSAO works. If you really want to know, read the below paragraph, if not, just take my word for it.

Basically, it tries to estimate how much diffuse light hits the surface. Direct light from sun is not accounted for, it's merely for those light differences in an area that's already in a building shadow. Even the direct shadow of a car gets darker right below the car, that's what SSAO is for. Now, for a 100 percent accurate measure of indirect lighting, you'd have to account for every possible direction from the surface of an object. In games, this is only possible numerically, so the SSAO shader looks in specific directions and measures the IL, so to speak. It checks if there's something in close proximity that could block IL. To get a perfect representation, infinite amount of samples would be required. This is not feasible obviously. Now the more samples, the closer you get to the ground truth. But this requires 100, 200 samples, not good. If we try to estimate percentage of Asians in a country and we only sample 4 people, out result is very inaccurate.

The AO does a "trick" : it uses different sample points for each pixel onscreen, so no neighboring pixel looks in the same direction. That way we can sample more directions in total but it results in different estimates for each pixel (each trial results in a different % of Asians but all correlate around the actual value) so the end result is noisy. The blur shader is there to remove this noise. Now purely random directions tend to have very coarse noise, so most AO implementations repeat their random pattern after a certain amount of pixels so also the result noise is repeated. I use a 4x4 pattern so in every 4x4 tile, the top left pixels sample the same directions. This tiled noise has the advantage that if you use a 4x4 blur, all noise is gone because it's guaranteed that you averaged all possible sample values. Also it's more cache efficient because pixels using the same directions can be processed in parallel. Bottom line, since I aligned my blur with this 4x4 grid, there's no reason to change its size by the user.



Forgot to mention: MSAA causes the depth buffer to be overridden, ingame AA is MSAA most of the time. Don't confuse with SMAA, this is shader AA which is fine.
Last edit: 2 years 4 months ago by Marty McFly.
The topic has been locked.
More
2 years 4 months ago - 2 years 4 months ago #632 by SurfNSlide
Replied by SurfNSlide on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Thanks for clarifying :)

So in a simplified way I understand: we get (almost, theoretically) the result of 16 times more samples than are actually are used, resulting in saving a lot of performance used for this. The tradeoff is: The representation of AO shadows being not pixel accurate but only about 4x4 pixel accurate.
Using the Asians analogy: our 4x4 grid is the country. we sample 4 persons for the percentage of Asians 16 times at different locations and then calculate correlation between those percentages/values. Instead of getting a more accurate percentage of Asians of 16 independend (equally sized) areas of that country we only get it for the whole country but with the same precision, as if we had it done just for one of those mentioned areas.

With AA techniques I’m actually quite familiar, I normally use T(S)AA ingame in modern Games or SMAA if I got performance problems. I avoid using FXAA as I think the blurry edges are horrible. Sometimes I add the mentionened transparency SparseGrid SSAA, if there’s still performance I don’t use and still get a stable 60 FPS after.
Just out of interest: SSAA (downsampling) like I use in old games like AoE3, which I want to make a preset for at some point, doesn’t mess with depth buffer? Surely AO would look great there (if there is a depth buffer at all^^)

Now for my further tests I did more research and turned everything off that could mess with depthbuffer access at all/did the following:
  • ingame TAA
  • driver TSGSSAA
  • all overlays excluding NVIDIA since I really didn’t get that to work, but deactivated all displays of it
  • quitted afterburner/Rivatuner
  • tried windowed/borderless/fullscreen modes
  • switchting uplay offline
Any other ideas or do I have to just to live with it not working? ^^ sadly the other preset writers on sfx.thelazy.net aren’t replying yet...

Lastly: if I wanted to change presets for playing screenshotting, there’s no more elegant way (like a hotkey) than opening ReShade Window and selecting a different one from the Dropdown-Menü in home-section?
Last edit: 2 years 4 months ago by SurfNSlide.
The topic has been locked.
More
2 years 4 months ago - 2 years 4 months ago #633 by Marty McFly
Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Your understanding is about the AO grid thingy is correct. Losing accuracy from 1 pixel accuracy to 4x4 is not that bad, SSAO is a low frequency filter anyways and you don't see a difference between those results in the final image, only in debug mode. When it's mixed with color, it looks exactly same.

If all those attempts at getting the depth buffer to work don't work, you're out of luck, I guess. Maybe some earlier ReShade version worked, who knows. Maybe it's even tied to some technically unrelated ingame setting like UI scale or whatever.

And no, there's no more convenient way. I personally have the ReShade ui open all the time when taking screenshots as often filters have to be tweaked per scene.
Last edit: 2 years 4 months ago by Marty McFly.
The following user(s) said Thank You: SurfNSlide
The topic has been locked.
More
2 years 4 months ago #634 by SurfNSlide
Replied by SurfNSlide on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Kind of funny actually, Far Cry 4 had the option to choose from SSAO, SSBC and HBAO+ (thats also a AO techniques right?!) and now they just have nothing at all... maybe they didnt wanna render recent consoles obsolete already, lol...
The topic has been locked.
More
2 years 4 months ago #635 by Marty McFly
Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
SSAO is not integral to visuals if the art director is any good. Also, this is common with gfx tech, abbreviations mix and have multiple meanings.

AO is ambient occlusion, any type of algorithm that simulates occlusion from diffuse lighting is AO. SSAO is the name for a range of shaders that calculate said AO from screen space data (the depth buffer for example) but it is also the name for the Nvidia shader that made this tech popular plus it's used by game devs as synonyme for any garden variety AO shader with no special title. Sometimes AO can mean Ambient Obscurance which is commonly used when the angle to the surface of an occluder is taken into account, hence MXAO is ambient obscurance.

HBAO and HBAO+ are short for horizon based ambient occlusion (+), also by Nvidia, the name of a certain kind of algorithm that tries to estimate the angle of free horizon. Quite funny actually is that HBAO+, while still bearing the name, doesn't do that and uses a much simpler and faster technique instead.

SSBC is short for screen space bent cones (sometimes also called SSBN, screen space bent normals) which basically calculates AO and bends the surface orientations towards the average light source which makes shading to "wrap" around the object.

There are numerous more names and techniques, such as ASSAO (adaptive SSAO) from INTEL that employs a technique similar to the culling mask in MXAO which I couldn't reproduce due to ReShade's restrictions and per pass perf overhead in D3D9.

SAO is short for scalable ambient obscurance, another very efficient algorithm from which I borrowed the idea of using mipmaps for farther away samples, that's why MXAO doesn't kill your framerates when using large radius values.

NNAO is a funny technique called neural network ambient occlusion which tried to create AO using a neural network in code. Unfortunately the network needs around 32 samples and has some very complex arithmetics (the neural network itself) per sample so it's not competitive when compared against other techniques which need less than half of the samples (HBAO low uses 8 or 12, MXAO very low uses 4, Intel ASSAO 3 even).
The following user(s) said Thank You: Sinclair, SandyCheeks
The topic has been locked.
More
2 years 4 months ago - 2 years 4 months ago #636 by JBeckman

SurfNSlide wrote: Kind of funny actually, Far Cry 4 had the option to choose from SSAO, SSBC and HBAO+ (thats also a AO techniques right?!) and now they just have nothing at all... maybe they didnt wanna render recent consoles obsolete already, lol...


Far Cry 5 if we're talking about that is still using SSBC same as many other recent Ubisoft games, thought it had a in-game on/off option though but maybe it doesn't?

EDIT: Well the engine has support for it but after a more thorough check besides the string files and engine parameters well in-game there does not seem to be much of anything indicating it's use, some objects have what looks like baked ambient occlusion (Dark shadows in seams and such in buildings.) whereas other assets clearly have no AO at all. Curious.
Last edit: 2 years 4 months ago by JBeckman.
The topic has been locked.
More
2 years 4 months ago - 2 years 4 months ago #637 by SurfNSlide
Replied by SurfNSlide on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Yeah JBeckman, that’s what I thought too. I only guessed from what it looks like, since I’m not versed in checking files for sth like that.
It’s quite disappointing, especially compared to FC 4 and I honestly don’t understand why they would do it. Though sadly Ubisoft almost always castrates their games’ looks for fucking cheap console hardware in one way or another, but I guess that’s where the money is made nowadays and we still live in capitalism... :huh:
Last edit: 2 years 4 months ago by SurfNSlide.
The topic has been locked.
More
2 years 4 months ago #638 by lowenz
The topic has been locked.
More
2 years 4 months ago #639 by Marty McFly
Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Well, that's kind of how the IL part of MXAO works. Horizon based estimators are too slow, even HBAO+ doesn't use them anymore (even though it still bears the name).
The topic has been locked.
More
2 years 4 months ago #640 by Martigen
Marty,

Just wanted to say thank you so much for updating and fixing SMAA's predication feature a few pages back. I've tested it and -- while I'm not an expert -- it certainly looks like it's working as intended.

And thanks to Thnxlite's depth-buffer detection changes, I'm now enjoying MXAO in a buttload more games than before. Really impressive work and the overhead isn't much. Just a quick, probably obvious, question: a lot of people, including me, really have no idea how MXAO works or how to best-tweak it. Are the defaults you've set currently the best, general, all-round settings that will likely apply well for most games without a huge performance overhead?

You are a pillar of this community, again thank you :)
The topic has been locked.