Marty McFly's Ambient Obscurance (MXAO) with IL

  • lowenz
More
6 years 3 months ago - 6 years 3 months ago #501 by lowenz Replied by lowenz on topic Marty McFly's Ambient Obscurance (MXAO) with IL
It's already corrected BUT not working!
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
// Vertex Shader
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

struct MXAO_VSOUT
{
	float4              position    : SV_Position;
        float2              texcoord    : TEXCOORD0;
        float2              scaledcoord : TEXCOORD1;
        nointerpolation int samples     : TEXCOORD2;
        nointerpolation int blursamples : TEXCOORD3;
        float3              uvtoviewADD : TEXCOORD4;
        float3              uvtoviewMUL : TEXCOORD5;
};

MXAO_VSOUT VS_MXAO(in uint id : SV_VertexID)
{
        MXAO_VSOUT MXAO;

        MXAO.texcoord.x = (id == 2) ? 2.0 : 0.0;
        MXAO.texcoord.y = (id == 1) ? 2.0 : 0.0;
        MXAO.scaledcoord.xy = MXAO.texcoord.xy / MXAO_GLOBAL_RENDER_SCALE;
        MXAO.position = float4(MXAO.texcoord.xy * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);

        MXAO.samples   = 8;
        MXAO.blursamples = 3;

        int blurqualityTweak   = (MXAO_GLOBAL_RENDER_SCALE < 0.707) + MXAO_TWO_LAYER - MXAO_ENABLE_TSS;
        int samplequalityTweak = -MXAO_GLOBAL_SAMPLE_QUALITY_PRESET * 2 * MXAO_ENABLE_TSS;

        if(     MXAO_GLOBAL_SAMPLE_QUALITY_PRESET == 0) { MXAO.samples = 8   + samplequalityTweak; MXAO.blursamples = 3 + blurqualityTweak;}
        else if(MXAO_GLOBAL_SAMPLE_QUALITY_PRESET == 1) { MXAO.samples = 16  + samplequalityTweak; MXAO.blursamples = 3 + blurqualityTweak;}
        else if(MXAO_GLOBAL_SAMPLE_QUALITY_PRESET == 2) { MXAO.samples = 24  + samplequalityTweak; MXAO.blursamples = 2 + blurqualityTweak;}
        else if(MXAO_GLOBAL_SAMPLE_QUALITY_PRESET == 3) { MXAO.samples = 32  + samplequalityTweak; MXAO.blursamples = 2 + blurqualityTweak;}
        else if(MXAO_GLOBAL_SAMPLE_QUALITY_PRESET == 4) { MXAO.samples = 64  + samplequalityTweak; MXAO.blursamples = 2 + blurqualityTweak;}
        else if(MXAO_GLOBAL_SAMPLE_QUALITY_PRESET == 5) { MXAO.samples = 96  + samplequalityTweak; MXAO.blursamples = 1 + blurqualityTweak;}
        else if(MXAO_GLOBAL_SAMPLE_QUALITY_PRESET == 6) { MXAO.samples = 255 + samplequalityTweak; MXAO.blursamples = 0 + blurqualityTweak;}

        MXAO.blursamples = max(MXAO.blursamples,0);

        MXAO.uvtoviewADD = float3(-1.0,-1.0,1.0);
        MXAO.uvtoviewMUL = float3(2.0,2.0,0.0);

        //static const float FOV = 70.0;

        //MXAO.uvtoviewADD = float3(-tan(radians(FOV * 0.5)).xx,1.0);
        //MXAO.uvtoviewADD.y *= BUFFER_WIDTH * BUFFER_RCP_HEIGHT;
        //MXAO.uvtoviewMUL = float3(-2.0 * MXAO.uvtoviewADD.xy,0.0);

        return MXAO;
}
Last edit: 6 years 3 months ago by lowenz.
The topic has been locked.
  • Marty McFly
  • Topic Author
More
6 years 3 months ago - 6 years 3 months ago #502 by Marty McFly Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Then you are not using the very latest version, I changed them to floats already, which bypasses this issue.
Last edit: 6 years 3 months ago by Marty McFly.
The topic has been locked.
  • crosire
More
6 years 3 months ago #503 by crosire Replied by crosire on topic Marty McFly's Ambient Obscurance (MXAO) with IL

lowenz wrote: It's already corrected BUT not working!

Yay. Another bug. I don't like GLSL.
The topic has been locked.
  • lowenz
More
6 years 3 months ago #504 by lowenz Replied by lowenz on topic Marty McFly's Ambient Obscurance (MXAO) with IL

Marty McFly wrote: Then you are not using the very latest version, I changed them to floats already, which bypasses this issue.

Where can I find it?
The topic has been locked.
  • lowenz
More
6 years 3 months ago #505 by lowenz Replied by lowenz on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Found it: pastebin.com/Gn3EUMyf

Is this the lastest? Thanks!
The topic has been locked.
  • Martigen
More
6 years 3 months ago - 6 years 3 months ago #506 by Martigen Replied by Martigen on topic Marty McFly's Ambient Obscurance (MXAO) with IL

Marty McFly wrote: Then you are not using the very latest version, I changed them to floats already, which bypasses this issue.

Marty can update the 1st post with the very latest version?

And/or merge into Reshade's Github for shaders?

Finally, thank you SO MUCH for making this :) Runs faster and looks better than other AO implementations often officially supported in games!
Last edit: 6 years 3 months ago by Martigen.
The following user(s) said Thank You: Marty McFly
The topic has been locked.
  • Marty McFly
  • Topic Author
More
6 years 3 months ago - 6 years 3 months ago #507 by Marty McFly Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
I wanted to upload it to github but then I made some amazing progress: a rewritten sample placement allows me to drop the sample counts of all quality presets, so "very low" for example looks same with 4 samples (new code) and 8 samples (old code) so I went ahead and lowered all qualities respectively this should boost performance a lot with same visuals. What I need to refine is the blur code, I made a rather vast change to it but it's hard to tweak right now and I'd prefer if it could work without user interaction just like the old one.
[strike]I'll continue working on this, got another2 ideas which I'd like to try out after that, then I'll release and update the github one.[/strike]

Tested both, turned out beautifully. MXAO just got faster!
Last edit: 6 years 3 months ago by Marty McFly.
The topic has been locked.
  • Wolfmeister1010
More
6 years 3 months ago #508 by Wolfmeister1010 Replied by Wolfmeister1010 on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Does anyone know how to/want to make a reshade preset using MXAO for AC Origins? It isn't using HBAO this time around and I find the inhouse AO technique they used to be pretty flat. I wonder if MXAO would help make the game look a lot more fleshed out.


Anyone wanna give it a try? I'm new to all this.
The topic has been locked.
  • Marty McFly
  • Topic Author
More
6 years 3 months ago #509 by Marty McFly Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Well, are you familiar with ReShade itself? If no, there's an excellent guide by FierySwordswoman on the forums here somewhere that should get you started. After that, using MXAO is just like using any other effect.
The topic has been locked.
  • Uncle Crassius
More
6 years 3 months ago #510 by Uncle Crassius Replied by Uncle Crassius on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Adding to what Marty said, the environments in AC:O are very foggy which leads to rather unsightly AO bleeding in many instances.
The topic has been locked.
  • Wolfmeister1010
More
6 years 3 months ago - 6 years 3 months ago #511 by Wolfmeister1010 Replied by Wolfmeister1010 on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Is that something that can be sorta fine tuned to be fixed?


Also yes I use Reshade all the time to answer the previous question, I just have not gone into more advanced effects like MXAO.



EDIT: Read some previous posts-seems that we cant get rid of AO bleed fully because we're adding the effect on TOP of the game whereas ingame AO options put the effect in before the VFX and transparencies and whatnot. That makes sense. Sucks-but makes sense.
Last edit: 6 years 3 months ago by Wolfmeister1010.
The topic has been locked.
  • Marty McFly
  • Topic Author
More
6 years 3 months ago #512 by Marty McFly Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
You can however just make it fade out before the fog kicks in.
Using MXAO is just like using any other shader. You drop it into your shader folder and enable it. Best practice is to switch to debug mode first to see if the AO works as expected (you should see some white with gray shadowing around objects). If that's the case, you can start tweaking.

If no AO shows up / looks glitchy, you need to turn some knobs on the depth buffer management in ReShade, at the preprocessor options. AC:O isn't listed in the "Games" tab on this site but Unity for example has

Game uses a reversed logarithmic depth buffer.

Keywords for you are "reversed" and "logarithmic" so you need to set

RESHADE_DEPTH_INPUT_IS_REVERSED=1
and
RESHADE_DEPTH_INPUT_IS_LOGARITHMIC=1

Most likely. As I said above, this applies to AC:Unity, I am merely assuming this applies to the next installment as well. Keep in mind that enabling MSAA in game options (might be denoted as "Anti Aliasing" without telling which method it is) kills off the depth buffer so MXAO cannot compute anything. In this case, the AO debug output is a plain white.
The topic has been locked.
  • Uncle Crassius
More
6 years 2 months ago - 6 years 2 months ago #513 by Uncle Crassius Replied by Uncle Crassius on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Speaking of logarithmic depth: I asked in another thread but got no answer, so sory for the OT. But in every game where it's supposed to be set to 1 I get artefacts. Turned off it always looks fine. Example from AC: Unity with depth reversed in both cases:

With Logarithmic=1 it looks like this:


Without it's good:
Last edit: 6 years 2 months ago by Uncle Crassius.
The topic has been locked.
  • Marty McFly
  • Topic Author
More
6 years 2 months ago #514 by Marty McFly Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
Precision issues most likely, I'm unsure how accurate the log function is and if it introduces rounding errors. You might need to raise the normal bias to fix those bugs.
The topic has been locked.
  • polyneutron
More
6 years 2 months ago #515 by polyneutron Replied by polyneutron on topic Marty McFly's Ambient Obscurance (MXAO) with IL
@Marty, is there any way to use MXAO along with other shaders? Using ReShade 1.1 and MXAO.fx... well, surely doesn't do a thing after I put it into the ReShade folder.
I know it's long outdated now, but I really feel much more comfortable using actual config files to work with instead of UI. So... can MXAO be added just like another shader there, or it's limited to ReShade v3-(and above)-only?
The topic has been locked.
  • Uncle Crassius
More
6 years 2 months ago #516 by Uncle Crassius Replied by Uncle Crassius on topic Marty McFly's Ambient Obscurance (MXAO) with IL

Marty McFly wrote: Precision issues most likely, I'm unsure how accurate the log function is and if it introduces rounding errors. You might need to raise the normal bias to fix those bugs.


It seems to work fine without it being turned on, though. Am I missing something?
The topic has been locked.
  • Marty McFly
  • Topic Author
More
6 years 2 months ago - 6 years 2 months ago #517 by Marty McFly Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
MXAO is limited to ReShade 3.0 only.

@logarithmic: As far as I know, it makes a minor difference in the linearized depth but helps to get more precision in far areas (for the original data) to counteract z fighting.
Last edit: 6 years 2 months ago by Marty McFly.
The topic has been locked.
  • Uncle Crassius
More
6 years 2 months ago #518 by Uncle Crassius Replied by Uncle Crassius on topic Marty McFly's Ambient Obscurance (MXAO) with IL

Marty McFly wrote: @logarithmic: As far as I know, it makes a minor difference in the linearized depth but helps to get more precision in far areas (for the original data) to counteract z fighting.


Alright, thanks. Raising normal bias only makes it disappear if AO is invisible as well. I just stick to not using it, then. Still wonder if there are people who get better results than me with it turned on.
The topic has been locked.
  • Marty McFly
  • Topic Author
More
6 years 2 months ago #519 by Marty McFly Replied by Marty McFly on topic Marty McFly's Ambient Obscurance (MXAO) with IL
What you can try as well is raising the bit depth of the depth buffer texture to R32F. Search for the singular entry of "R16F" in the MXAO shader and replace with "R32F".
The topic has been locked.
  • ShoterXX
More
6 years 2 months ago - 6 years 2 months ago #520 by ShoterXX Replied by ShoterXX on topic Marty McFly's Ambient Obscurance (MXAO) with IL
IIRC, that would come at a significant performance impact, so I'd rather have bad far areas that are probably gonna be cut-off anyway.

Also, not sure of relevant, but it just came to my head. Can't you expand the depth values whenever itgets clipped off? Say, MXAO gets clipped off at 0.5, make 0.5 the new 1, so you should have twice the steps? Unless I'm thinking stuff the wrong way.
Last edit: 6 years 2 months ago by ShoterXX.
The topic has been locked.
We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.