diff --git a/handheld/shaders/gbc_pokemon_modernizer.slang b/handheld/shaders/gbc_pokemon_modernizer.slang new file mode 100644 index 00000000..d3ab4bbf --- /dev/null +++ b/handheld/shaders/gbc_pokemon_modernizer.slang @@ -0,0 +1,49 @@ +#version 450 + +// GBC Pokemon Modernizer +// by torridgristle +// license: Public Domain + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; +} global; + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; + +precision lowp float; + +const mat3 GBCMatrix = mat3( 0.924, 0.021, 0.013, 0.048, 0.787, 0.249, 0.104, 0.09, 0.733 ) + +void main() +{ + vec3 Picture = texture(Source, vTexCoord).xyz; + + Picture *= Picture; + Picture *= GBCMatrix; + Picture = sqrt(Picture); + + FragColor = vec4(Picture,1.0); +} diff --git a/reshade/bloom.slangp b/reshade/bloom.slangp new file mode 100644 index 00000000..cb53c4bb --- /dev/null +++ b/reshade/bloom.slangp @@ -0,0 +1,50 @@ +shaders = 7 + +shader0 = shaders/bloom/BloomPass0.slang +alias0 = Bloom1 +float_framebuffer0 = true + +shader1 = shaders/bloom/BloomPass1.slang +alias1 = Bloom2 +float_framebuffer1 = true + +shader2 = shaders/bloom/BloomPass2.slang +alias2 = Bloom3 +float_framebuffer2 = true +scale2 = 0.5 +scale_type2 = source + +shader3 = shaders/bloom/BloomPass3.slang +alias3 = Bloom4 +float_framebuffer3 = true +scale3 = 0.5 +scale_type3 = source + +shader4 = shaders/bloom/BloomPass4.slang +alias4 = Bloom5 +float_framebuffer4 = true +scale4 = 0.5 +scale_type4 = source + +shader5 = shaders/bloom/LensFlarePass0.slang +alias5 = LensFlare1 +float_framebuffer5 = true +scale5 = 4.0 +scale_type5 = source + +//shader6 = shaders/bloom/LensFlarePass1.slang +//alias6 = LensFlare2 +//float_framebuffer6 = true + +//shader7 = shaders/bloom/LensFlarePass2.slang +//alias7 = LensFlare3 +//float_framebuffer7 = true + +shader6 = shaders/bloom/LightingCombine.slang +scale6 = 2.0 +scale_type6 = source +filter_linear6 = true + +textures = "Dirt;Sprite" +Dirt = shaders/bloom/LensDB.png +Sprite = shaders/bloom/LensSprite.png \ No newline at end of file diff --git a/reshade/shaders/bloom/BloomPass0.slang b/reshade/shaders/bloom/BloomPass0.slang new file mode 100755 index 00000000..905d0cf1 --- /dev/null +++ b/reshade/shaders/bloom/BloomPass0.slang @@ -0,0 +1,57 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +#include "params.inc" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; +layout(set = 0, binding = 3) uniform sampler2D Original; + +#include "frag_funcs.inc" + +void main() +{ + vec4 bloom = vec4(0.); + vec4 tempbloom = vec4(0.); + vec2 bloomuv = vec2(0.); + + const vec2 offset[4] = { + vec2(1.0, 1.0), + vec2(1.0, 1.0), + vec2(-1.0, 1.0), + vec2(-1.0, -1.0) + }; + + for (int i = 0; i < 4; i++) + { + bloomuv = offset[i] * (vTexCoord.xy * params.SourceSize.zw) * 2.; + bloomuv += vTexCoord.xy; + tempbloom = textureLod(Source, vec2(bloomuv.xy), 0.); + tempbloom.w = max(0., dot(tempbloom.xyz, vec3(0.333)) - global.fAnamFlareThreshold); + tempbloom.xyz = max(vec3(0.), tempbloom.xyz - vec3(global.fBloomThreshold)); + bloom += tempbloom; + } + + bloom *= 0.25; + FragColor = bloom; +} \ No newline at end of file diff --git a/reshade/shaders/bloom/BloomPass1.slang b/reshade/shaders/bloom/BloomPass1.slang new file mode 100755 index 00000000..4801a439 --- /dev/null +++ b/reshade/shaders/bloom/BloomPass1.slang @@ -0,0 +1,56 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +#include "params.inc" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; +layout(set = 0, binding = 3) uniform sampler2D Original; + +#include "frag_funcs.inc" + +void main() +{ + vec4 bloom = vec4(0.0); + + const vec2 offset[8] = { + vec2(1.0, 1.0), + vec2(0.0, -1.0), + vec2(-1.0, 1.0), + vec2(-1.0, -1.0), + vec2(0.0, 1.0), + vec2(0.0, -1.0), + vec2(1.0, 0.0), + vec2(-1.0, 0.0) + }; + + for (int i = 0; i < 8; i++) + { + vec2 bloomuv = offset[i] * (vTexCoord.xy * params.SourceSize.zw) * 4; + bloomuv += vTexCoord; + bloom += textureLod(Source, vec2(bloomuv), 0); + } + + bloom *= 0.125; + FragColor = bloom; +} \ No newline at end of file diff --git a/reshade/shaders/bloom/BloomPass2.slang b/reshade/shaders/bloom/BloomPass2.slang new file mode 100755 index 00000000..09330a26 --- /dev/null +++ b/reshade/shaders/bloom/BloomPass2.slang @@ -0,0 +1,56 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +#include "params.inc" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; +layout(set = 0, binding = 3) uniform sampler2D Original; + +#include "frag_funcs.inc" + +void main() +{ + vec4 bloom = vec4(0.0); + + const vec2 offset[8] = { + vec2(0.707, 0.707), + vec2(0.707, -0.707), + vec2(-0.707, 0.707), + vec2(-0.707, -0.707), + vec2(0.0, 1.0), + vec2(0.0, -1.0), + vec2(1.0, 0.0), + vec2(-1.0, 0.0) + }; + + for (int i = 0; i < 8; i++) + { + vec2 bloomuv = offset[i] * (vTexCoord.xy * params.SourceSize.zw) * 8.; + bloomuv += vTexCoord.xy; + bloom += textureLod(Source, vec2(bloomuv), 0.); + } + +bloom *= 0.5; // brighten up the sample, it will lose brightness in H/V Gaussian blur + FragColor = bloom; +} \ No newline at end of file diff --git a/reshade/shaders/bloom/BloomPass3.slang b/reshade/shaders/bloom/BloomPass3.slang new file mode 100755 index 00000000..17c4b35a --- /dev/null +++ b/reshade/shaders/bloom/BloomPass3.slang @@ -0,0 +1,38 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +#include "params.inc" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; +layout(set = 0, binding = 3) uniform sampler2D Original; + +#include "frag_funcs.inc" + +void main() +{ + vec4 bloom = GaussBlur22(vTexCoord.xy, Source, 16., 0., false); + bloom.w *= global.fAnamFlareAmount; + bloom.xyz *= global.fBloomAmount; + FragColor = bloom; +} \ No newline at end of file diff --git a/reshade/shaders/bloom/BloomPass4.slang b/reshade/shaders/bloom/BloomPass4.slang new file mode 100755 index 00000000..beeaccfd --- /dev/null +++ b/reshade/shaders/bloom/BloomPass4.slang @@ -0,0 +1,38 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +#include "params.inc" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; +layout(set = 0, binding = 3) uniform sampler2D Original; + +#include "frag_funcs.inc" + +void main() +{ + vec4 bloom = vec4(0.); + bloom.xyz = GaussBlur22(vTexCoord, Source, 16., 0., true).xyz * 2.5; + bloom.w = GaussBlur22(vTexCoord, Source, 32 * global.fAnamFlareWideness, 0., false).w * 2.5; // to have anamflare texture (bloom.w) avoid vertical blur + FragColor = bloom; +} \ No newline at end of file diff --git a/reshade/shaders/bloom/LensDB.png b/reshade/shaders/bloom/LensDB.png new file mode 100644 index 00000000..646972e2 Binary files /dev/null and b/reshade/shaders/bloom/LensDB.png differ diff --git a/reshade/shaders/bloom/LensFlarePass0.slang b/reshade/shaders/bloom/LensFlarePass0.slang new file mode 100755 index 00000000..ae635f84 --- /dev/null +++ b/reshade/shaders/bloom/LensFlarePass0.slang @@ -0,0 +1,174 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +#include "params.inc" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; +layout(set = 0, binding = 3) uniform sampler2D Original; + +#include "frag_funcs.inc" + +void main() +{ + vec4 lens = vec4(0.); + + // Lenz + if (global.bLenzEnable > 0.5) + { + const vec3 lfoffset[19] = { + vec3(0.9, 0.01, 4), + vec3(0.7, 0.25, 25), + vec3(0.3, 0.25, 15), + vec3(1, 1.0, 5), + vec3(-0.15, 20, 1), + vec3(-0.3, 20, 1), + vec3(6, 6, 6), + vec3(7, 7, 7), + vec3(8, 8, 8), + vec3(9, 9, 9), + vec3(0.24, 1, 10), + vec3(0.32, 1, 10), + vec3(0.4, 1, 10), + vec3(0.5, -0.5, 2), + vec3(2, 2, -5), + vec3(-5, 0.2, 0.2), + vec3(20, 0.5, 0), + vec3(0.4, 1, 10), + vec3(0.00001, 10, 20) + }; + const vec3 lffactors[19] = { + vec3(1.5, 1.5, 0), + vec3(0, 1.5, 0), + vec3(0, 0, 1.5), + vec3(0.2, 0.25, 0), + vec3(0.15, 0, 0), + vec3(0, 0, 0.15), + vec3(1.4, 0, 0), + vec3(1, 1, 0), + vec3(0, 1, 0), + vec3(0, 0, 1.4), + vec3(1, 0.3, 0), + vec3(1, 1, 0), + vec3(0, 2, 4), + vec3(0.2, 0.1, 0), + vec3(0, 0, 1), + vec3(1, 1, 0), + vec3(1, 1, 0), + vec3(0, 0, 0.2), + vec3(0.012,0.313,0.588) + }; + + vec2 lfcoord = vec2(0.); + vec3 lenstemp = vec3(0.); + vec2 distfact = vTexCoord.xy - 0.5; + distfact.x *= params.SourceSize.x / params.SourceSize.y; + + for (int i = 0; i < 19; i++) + { + lfcoord.xy = lfoffset[i].x * distfact; + lfcoord.xy *= pow(2.0 * length(distfact), lfoffset[i].y * 3.5); + lfcoord.xy *= lfoffset[i].z; + lfcoord.xy = 0.5 - lfcoord.xy; + vec2 tempfact = (lfcoord.xy - 0.5) * 2.; + float templensmult = clamp(1.0 - dot(tempfact, tempfact), 0., 1.); + vec3 lenstemp1 = vec3(dot(textureLod(Original, vec2(lfcoord.xy), 1.0).rgb, vec3(0.333))); +/* Doesn't exist in RetroArch, so comment it out +#if LENZ_DEPTH_CHECK + float templensdepth = texture(ReShade::DepthBuffer, lfcoord.xy).x; + if (templensdepth < 0.99999) + lenstemp1 = 0; +#endif +*/ + lenstemp1 = max(vec3(0.), lenstemp1.xyz - vec3(global.fLenzThreshold)); + lenstemp1 *= lffactors[i] * templensmult; + + lenstemp += lenstemp1; + } + + lens.rgb += lenstemp * global.fLenzIntensity; + } + + // Chapman Lens + if (global.bChapFlareEnable > 0.5) + { + vec2 sample_vector = (vec2(0.5, 0.5) - vTexCoord.xy) * global.fChapFlareDispersal; + vec2 halo_vector = normalize(sample_vector) * global.fChapFlareSize; + + vec3 chaplens = GetDistortedTex(Original, vTexCoord.xy + halo_vector, halo_vector, fChapFlareCA * 2.5).rgb; + + for (int j = 0; j < int(global.iChapFlareCount); ++j) + { + vec2 foffset = sample_vector * float(j); + chaplens += GetDistortedTex(Original, vTexCoord.xy + foffset, foffset, fChapFlareCA).rgb; + } + + chaplens *= 1.0 / global.iChapFlareCount; + lens.xyz += chaplens; + } + + // Godrays + if (global.bGodrayEnable > 0.5) + { + const vec2 ScreenLightPos = vec2(0.5, 0.5); + vec2 texcoord2 = vTexCoord; + vec2 deltaTexCoord = (texcoord2 - ScreenLightPos); + deltaTexCoord *= 1.0 / global.iGodraySamples * global.fGodrayDensity; + + float illuminationDecay = 1.0; + + for (int g = 0; g < int(global.iGodraySamples); g++) + { + texcoord2 -= deltaTexCoord;; + vec4 sample2 = textureLod(Original, vec2(texcoord2), 0.); + float sampledepth = textureLod(Original, vec2(texcoord2), 0.).x; + sample2.w = clamp(dot(sample2.xyz, vec3(0.3333)) - global.fGodrayThreshold, 0., 1.); + sample2.r *= 1.00; + sample2.g *= 0.95; + sample2.b *= 0.85; + sample2 *= illuminationDecay * global.fGodrayWeight; +#if GODRAY_DEPTH_CHECK == 1 + if (sampledepth > 0.99999) + lens.rgb += sample2.xyz * sample2.w; +#else + lens.rgb += sample2.xyz * sample2.w; +#endif + illuminationDecay *= global.fGodrayDecay; + } + } + + // Anamorphic flare + if (global.bAnamFlareEnable > 0.5) + { + vec3 anamFlare = vec3(0.); + const float gaussweight[5] = { 0.2270270270, 0.1945945946, 0.1216216216, 0.0540540541, 0.0162162162 }; + + for (int z = -4; z < 5; z++) + { + anamFlare += GetAnamorphicSample(0, vTexCoord.xy + vec2(0, z * (vTexCoord.y * params.SourceSize.w) * 2.), global.fFlareBlur) * fFlareTint * gaussweight[abs(z)]; + } + + lens.xyz += anamFlare * global.fFlareIntensity; + } + FragColor = lens; +} \ No newline at end of file diff --git a/reshade/shaders/bloom/LensFlarePass1.slang b/reshade/shaders/bloom/LensFlarePass1.slang new file mode 100755 index 00000000..a541dfea --- /dev/null +++ b/reshade/shaders/bloom/LensFlarePass1.slang @@ -0,0 +1,35 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +#include "params.inc" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; +layout(set = 0, binding = 3) uniform sampler2D Original; + +#include "frag_funcs.inc" + +void main() +{ + FragColor = GaussBlur22(vTexCoord, Source, 2., 0., true); +} \ No newline at end of file diff --git a/reshade/shaders/bloom/LensFlarePass2.slang b/reshade/shaders/bloom/LensFlarePass2.slang new file mode 100755 index 00000000..3db9da02 --- /dev/null +++ b/reshade/shaders/bloom/LensFlarePass2.slang @@ -0,0 +1,35 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +#include "params.inc" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; +layout(set = 0, binding = 3) uniform sampler2D Original; + +#include "frag_funcs.inc" + +void main() +{ + FragColor = GaussBlur22(vTexCoord, Source, 2., 0., false); +} \ No newline at end of file diff --git a/reshade/shaders/bloom/LensSprite.png b/reshade/shaders/bloom/LensSprite.png new file mode 100644 index 00000000..3e922dcf Binary files /dev/null and b/reshade/shaders/bloom/LensSprite.png differ diff --git a/reshade/shaders/bloom/LightingCombine.slang b/reshade/shaders/bloom/LightingCombine.slang new file mode 100755 index 00000000..8e9564a5 --- /dev/null +++ b/reshade/shaders/bloom/LightingCombine.slang @@ -0,0 +1,102 @@ +#version 450 + +layout(push_constant) uniform Push +{ + vec4 SourceSize; + vec4 OriginalSize; + vec4 OutputSize; + uint FrameCount; +} params; + +#include "params.inc" + +#pragma stage vertex +layout(location = 0) in vec4 Position; +layout(location = 1) in vec2 TexCoord; +layout(location = 0) out vec2 vTexCoord; + +void main() +{ + gl_Position = global.MVP * Position; + vTexCoord = TexCoord; +} + +#pragma stage fragment +layout(location = 0) in vec2 vTexCoord; +layout(location = 0) out vec4 FragColor; +layout(set = 0, binding = 2) uniform sampler2D Source; +layout(set = 0, binding = 3) uniform sampler2D Original; +layout(set = 0, binding = 4) uniform sampler2D Bloom3; +layout(set = 0, binding = 5) uniform sampler2D Bloom5; +layout(set = 0, binding = 6) uniform sampler2D Dirt; +layout(set = 0, binding = 7) uniform sampler2D Sprite; +layout(set = 0, binding = 8) uniform sampler2D LensFlare1; + +#include "frag_funcs.inc" + +#define saturate(c) clamp(c, 0., 1.) + +void main() +{ + vec4 color = vec4(0.); + color = texture(Original, vTexCoord.xy); + + // Bloom + vec3 colorbloom = vec3(0.); + colorbloom += texture(Bloom3, vTexCoord.xy).rgb * 1.0; + colorbloom += texture(Bloom5, vTexCoord.xy).rgb * 9.0; + colorbloom *= 0.1; + colorbloom = saturate(colorbloom); + float colorbloomgray = dot(colorbloom, vec3(0.333)); + colorbloom = mix(vec3(colorbloomgray), colorbloom, vec3(global.fBloomSaturation)); + colorbloom *= fBloomTint; + + if (global.iBloomMixmode == 0.) + color.rgb += colorbloom; + else if (global.iBloomMixmode == 1.) + color.rgb = 1. - (1. - color.rgb) * (1. - colorbloom); + else if (global.iBloomMixmode == 2.) + color.rgb = max(vec3(0.0), max(color.rgb, mix(color.rgb, (1. - (1. - saturate(colorbloom)) * (1. - saturate(colorbloom))), 1.0))); + else if (global.iBloomMixmode == 3.) + color.rgb = max(color.rgb, colorbloom); + + // Anamorphic flare + if (global.bAnamFlareEnable > 0.5) + { + vec3 anamflare = texture(Bloom5, vTexCoord.xy).w * 2. * fAnamFlareColor; + anamflare = max(anamflare, 0.0); + color.rgb += pow(anamflare, vec3(1.0 / global.fAnamFlareCurve)); + } + + // Lens dirt + if (global.bLensdirtEnable > 0.5) + { + float lensdirtmult = dot(texture(Bloom5, vTexCoord).rgb, vec3(0.333)); + vec3 dirttex = texture(Dirt, vTexCoord).rgb; + vec3 lensdirt = dirttex * lensdirtmult * global.fLensdirtIntensity; + + lensdirt = mix(vec3(dot(lensdirt.xyz, vec3(0.333))), lensdirt.xyz, vec3(global.fLensdirtSaturation)); + + if (global.iLensdirtMixmode == 0.) + color.rgb += lensdirt; + else if (global.iLensdirtMixmode == 1.) + color.rgb = 1. - (1. - color.rgb) * (1. - lensdirt); + else if (global.iLensdirtMixmode == 2.) + color.rgb = max(vec3(0.0), max(color.rgb, mix(color.rgb, (1. - (1. - saturate(lensdirt)) * (1. - saturate(lensdirt))), 1.0))); + else if (global.iLensdirtMixmode == 3.) + color.rgb = max(color.rgb, lensdirt); + } + + // Lens flares + if (global.bAnamFlareEnable > 0.5 || global.bLenzEnable > 0.5 || global.bGodrayEnable > 0.5 || global.bChapFlareEnable > 0.5) + { + vec3 lensflareSample = texture(LensFlare1, vTexCoord.xy).rgb, lensflareMask; + lensflareMask = texture(Sprite, vTexCoord + vec2( 0.5, 0.5) * (vTexCoord.xy * params.SourceSize.zw)).rgb; + lensflareMask += texture(Sprite, vTexCoord + vec2(-0.5, 0.5) * (vTexCoord.xy * params.SourceSize.zw)).rgb; + lensflareMask += texture(Sprite, vTexCoord + vec2( 0.5, -0.5) * (vTexCoord.xy * params.SourceSize.zw)).rgb; + lensflareMask += texture(Sprite, vTexCoord + vec2(-0.5, -0.5) * (vTexCoord.xy * params.SourceSize.zw)).rgb; + + color.rgb += lensflareMask * 0.25 * lensflareSample; + } + FragColor = color; +} \ No newline at end of file diff --git a/reshade/shaders/bloom/frag_funcs.inc b/reshade/shaders/bloom/frag_funcs.inc new file mode 100644 index 00000000..39d7ac01 --- /dev/null +++ b/reshade/shaders/bloom/frag_funcs.inc @@ -0,0 +1,75 @@ +vec4 GaussBlur22(vec2 coord, sampler2D tex, float mult, float lodlevel, bool isBlurVert) +{ + vec4 sum = vec4(0.); + vec2 axis = isBlurVert ? vec2(0, 1) : vec2(1, 0); + + const float weight[11] = { + 0.082607, + 0.080977, + 0.076276, + 0.069041, + 0.060049, + 0.050187, + 0.040306, + 0.031105, + 0.023066, + 0.016436, + 0.011254 + }; + + for (int i = -10; i < 11; i++) + { + float currweight = weight[abs(i)]; + sum += textureLod(tex, vec2(coord.xy + axis.xy * float(i) * (vTexCoord.xy * params.SourceSize.zw) * mult), lodlevel) * currweight; + } + + return sum; +} + +vec3 GetDnB(sampler2D tex, vec2 coords) +{ + vec3 color = vec3(max(0, dot(textureLod(tex, vec2(coords.xy), 4.).rgb, vec3(0.333)) - global.fChapFlareThreshold) * global.fChapFlareIntensity); +/* This isn't something RA has, so just comment it out +#if CHAPMAN_DEPTH_CHECK + if (textureLod(ReShade::DepthBuffer, vec4(coords.xy, 0, 3)).x < 0.99999) + color = 0; +#endif +*/ + return color; +} +vec3 GetDistortedTex(sampler2D tex, vec2 sample_center, vec2 sample_vector, vec3 distortion) +{ + vec2 final_vector = sample_center + sample_vector * min(min(distortion.r, distortion.g), distortion.b); + + if (final_vector.x > 1.0 || final_vector.y > 1.0 || final_vector.x < -1.0 || final_vector.y < -1.0) + return vec3(0, 0, 0); + else + return vec3( + GetDnB(tex, sample_center + sample_vector * distortion.r).r, + GetDnB(tex, sample_center + sample_vector * distortion.g).g, + GetDnB(tex, sample_center + sample_vector * distortion.b).b); +} + +vec3 GetBrightPass(vec2 coords) +{ + vec3 c = texture(Original, coords).rgb; + vec3 bC = max(c - global.fFlareLuminance.xxx, 0.0); + float bright = dot(bC, vec3(1.0)); + bright = smoothstep(0.0f, 0.5, bright); + vec3 result = mix(vec3(0.0), c, vec3(bright)); +/* This isn't something RA has, so just comment it out +#if FLARE_DEPTH_CHECK + float checkdepth = tex2D(ReShade::DepthBuffer, coords).x; + if (checkdepth < 0.99999) + result = 0; +#endif +*/ + return result; +} +vec3 GetAnamorphicSample(int axis, vec2 coords, float blur) +{ + coords = 2.0 * coords - 1.0; + coords.x /= -blur; + coords = 0.5 * coords + 0.5; + return GetBrightPass(coords); +} \ No newline at end of file diff --git a/reshade/shaders/bloom/params.inc b/reshade/shaders/bloom/params.inc new file mode 100644 index 00000000..93a4eddb --- /dev/null +++ b/reshade/shaders/bloom/params.inc @@ -0,0 +1,120 @@ +layout(std140, set = 0, binding = 0) uniform UBO +{ + mat4 MVP; + float iBloomMixmode; + float fBloomThreshold; + float fBloomAmount; + float fBloomSaturation; + float fBloomTint_r; + float fBloomTint_g; + float fBloomTint_b; + float bLensdirtEnable; + float iLensdirtMixmode; + float fLensdirtIntensity; + float fLensdirtSaturation; + float fLensdirtTint_r; + float fLensdirtTint_g; + float fLensdirtTint_b; + float bAnamFlareEnable; + float fAnamFlareThreshold; + float fAnamFlareWideness; + float fAnamFlareAmount; + float fAnamFlareCurve; + float fAnamFlareColor_r; + float fAnamFlareColor_g; + float fAnamFlareColor_b; + float bLenzEnable; + float fLenzIntensity; + float fLenzThreshold; + float bChapFlareEnable; + float fChapFlareThreshold; + float iChapFlareCount; + float fChapFlareDispersal; + float fChapFlareSize; + float fChapFlareCA_r; + float fChapFlareCA_g; + float fChapFlareCA_b; + float fChapFlareIntensity; + float bGodrayEnable; + float fGodrayDecay; + float fGodrayExposure; + float fGodrayWeight; + float fGodrayDensity; + float fGodrayThreshold; + float iGodraySamples; + float fFlareLuminance; + float fFlareBlur; + float fFlareIntensity; + float fFlareTint_r; + float fFlareTint_g; + float fFlareTint_b; +} global; + +#pragma parameter iBloomMixmode "Bloom Mix Mode" 0.0 0.0 2.0 1.0 +#pragma parameter fBloomThreshold "Bloom Threshold" 0.8 0.1 1.0 0.1 +#pragma parameter fBloomAmount "Bloom Amount" 0.8 0.0 20.0 0.1 +#pragma parameter fBloomSaturation "Bloom Saturation" 0.8 0.0 2.0 0.1 +#pragma parameter fBloomTint_r "Bloom Tint R" 0.7 0.0 1.0 0.05 +#pragma parameter fBloomTint_g "Bloom Tint G" 0.8 0.0 1.0 0.05 +#pragma parameter fBloomTint_b "Bloom Tint B" 1.0 0.0 1.0 0.05 +#pragma parameter bLensdirtEnable "Lens Dirt Enable" 0.0 0.0 1.0 1.0 +#pragma parameter iLensdirtMixmode "Lens Dirt Mix Mode" 0.0 0.0 3.0 1.0 +#pragma parameter fLensdirtIntensity "Lens Dirt Intensity" 0.4 0.0 2.0 0.1 +#pragma parameter fLensdirtSaturation "Lens Dirt Saturation" 2.0 0.0 2.0 0.1 +#pragma parameter fLensdirtTint_r "Lens Dirt Tint R" 1.0 0.0 1.0 0.05 +#pragma parameter fLensdirtTint_g "Lens Dirt Tint G" 1.0 0.0 1.0 0.05 +#pragma parameter fLensdirtTint_b "Lens Dirt Tint B" 1.0 0.0 1.0 0.05 +#pragma parameter bAnamFlareEnable "Anam Flare Enable" 0.0 0.0 1.0 1.0 +#pragma parameter fAnamFlareThreshold "Anam Flare Threshold" 0.9 0.1 1.0 0.1 +#pragma parameter fAnamFlareWideness "Anam Flare Width" 2.4 1.0 2.5 0.1 +#pragma parameter fAnamFlareAmount "Anam Flare Amt" 14.5 1.0 20.0 0.5 +#pragma parameter fAnamFlareCurve "Anam Flare Curve" 1.2 1.0 2.0 0.1 +#pragma parameter fAnamFlareColor_r "Anam Flare Col R" 0.012 0.0 1.0 0.01 +#pragma parameter fAnamFlareColor_g "Anam Flare Col G" 0.313 0.0 1.0 0.01 +#pragma parameter fAnamFlareColor_b "Anam Flare Col B" 0.588 0.0 1.0 0.01 +#pragma parameter bLenzEnable "Lenz Enable" 0.0 0.0 1.0 1.0 +#pragma parameter fLenzIntensity "Lenz Intensity" 1.0 0.2 3.0 0.1 +#pragma parameter fLenzThreshold "Lenz Threshold" 0.8 0.6 1.0 0.1 +#pragma parameter bChapFlareEnable "Chap Flare Enable" 0.0 0.0 1.0 1.0 +#pragma parameter fChapFlareThreshold "Chap Flare Threshold" 0.9 0.7 0.99 0.05 +#pragma parameter iChapFlareCount "Chap Flare Count" 15.0 1.0 20.0 1.0 +#pragma parameter fChapFlareDispersal "Chap Flare Dispersal" 0.25 0.25 1.0 0.05 +#pragma parameter fChapFlareSize "Chap Flare Size" 0.45 0.2 0.8 0.05 +#pragma parameter fChapFlareCA_r "Chap Flare CA R" 0.0 0.0 1.0 0.01 +#pragma parameter fChapFlareCA_g "Chap Flare CA G" 0.01 0.0 1.0 0.01 +#pragma parameter fChapFlareCA_b "Chap Flare CA B" 0.02 0.0 1.0 0.01 +#pragma parameter fChapFlareIntensity "Chap Flare Intensity" 100.0 5.0 200.0 5.0 +#pragma parameter bGodrayEnable "Godray Enable" 0.0 0.0 1.0 1.0 +#pragma parameter fGodrayDecay "Godray Decay" 0.99 0.5 0.9999 0.05 +#pragma parameter fGodrayExposure "Godray Exposure" 1.0 0.7 1.5 0.05 +#pragma parameter fGodrayWeight "Godray Weight" 1.25 0.8 1.7 0.05 +#pragma parameter fGodrayDensity "Godray Density" 1.0 0.2 2.0 0.2 +#pragma parameter fGodrayThreshold "Godray Threshold" 0.9 0.6 1.0 0.05 +#pragma parameter iGodraySamples "Godray Samples" 128.0 16.0 256.0 16.0 +#pragma parameter fFlareLuminance "Flare Luminance" 0.095 0.0 1.0 0.005 +#pragma parameter fFlareBlur "Flare Blur" 200.0 1.0 10000.0 50.0 +#pragma parameter fFlareIntensity "Flare Intensity" 2.07 0.2 5.0 0.1 +#pragma parameter fFlareTint_r "Flare Tint R" 0.137 0.0 1.0 0.05 +#pragma parameter fFlareTint_g "Flare Tint G" 0.216 0.0 1.0 0.05 +#pragma parameter fFlareTint_b "Flare Tint B" 1.0 0.0 1.0 0.05 + +vec3 fFlareTint = vec3(global.fFlareTint_r, global.fFlareTint_g, global.fFlareTint_b); +vec3 fAnamFlareColor = vec3(global.fAnamFlareColor_r, global.fAnamFlareColor_g, global.fAnamFlareColor_b); +vec3 fLensdirtTint = vec3(global.fLensdirtTint_r, global.fLensdirtTint_g, global.fLensdirtTint_b); +vec3 fBloomTint = vec3(global.fBloomTint_r, global.fBloomTint_g, global.fBloomTint_b); +vec3 fChapFlareCA = vec3(global.fChapFlareCA_r, global.fChapFlareCA_g, global.fChapFlareCA_b); + +// If 1, only pixels with depth = 1 get lens flares +// This prevents white objects from getting lens flares sources, which would normally happen in LDR +#ifndef LENZ_DEPTH_CHECK + #define LENZ_DEPTH_CHECK 0 +#endif +#ifndef CHAPMAN_DEPTH_CHECK + #define CHAPMAN_DEPTH_CHECK 0 +#endif +#ifndef GODRAY_DEPTH_CHECK + #define GODRAY_DEPTH_CHECK 0 +#endif +#ifndef FLARE_DEPTH_CHECK + #define FLARE_DEPTH_CHECK 0 +#endif \ No newline at end of file