mirror of
https://github.com/cemu-project/cemu_graphic_packs.git
synced 2024-11-27 03:54:15 +01:00
[XCX] LOD Gaussian
Add - Lod Gauss - Initial commit, to be scaled after some testing
This commit is contained in:
parent
e81f9e967d
commit
584831d7a8
@ -8,6 +8,8 @@ $scaleFactorY = always_decimal_format($fullHeight / 720.0);
|
|||||||
|
|
||||||
#version 420
|
#version 420
|
||||||
#extension GL_ARB_texture_gather : enable
|
#extension GL_ARB_texture_gather : enable
|
||||||
|
#define pow2(x) (x * x)
|
||||||
|
|
||||||
// shader d8e69e8df8c227f5
|
// shader d8e69e8df8c227f5
|
||||||
// Bloom/blur 1st step, 1280->640->1280
|
// Bloom/blur 1st step, 1280->640->1280
|
||||||
// To do, go back and remove all test blurs..
|
// To do, go back and remove all test blurs..
|
||||||
@ -30,143 +32,33 @@ highp float lineRand(vec2 co)
|
|||||||
return fract(sin(sn) * c);
|
return fract(sin(sn) * c);
|
||||||
}
|
}
|
||||||
|
|
||||||
vec4 blur21Vert(sampler2D image, vec2 vuv, vec2 res) {
|
|
||||||
// Note, must use gl_FragCord not emulated coordinates to sample between textels
|
|
||||||
// Two pass implementation
|
|
||||||
|
|
||||||
//iq CC , http://rastergrid.com/blog/2010/09/efficient-gaussian-blur-with-linear-sampling/
|
// FabriceNeyret2, single pass gaussian by intermediate MIPmap level. https://www.shadertoy.com/view/ltScRG
|
||||||
vec3 blr = vec3(0.0);
|
// I hereby pledge my loyalty to the FabriceNeyret2 fanclub, this is bloody beautiful!
|
||||||
|
|
||||||
blr += 0.026109*texture(image, (vuv + vec2(0.0, -15.5)) / res.xy).xyz;
|
const int samples = 35, //check if must scale to pascal levels
|
||||||
blr += 0.034202*texture(image, (vuv + vec2(0.0, -13.5)) / res.xy).xyz;
|
LOD = 2, // gaussian done on MIPmap at scale LOD
|
||||||
blr += 0.043219*texture(image, (vuv + vec2(0.0, -11.5)) / res.xy).xyz;
|
sLOD = 1 << LOD; // tile size = 2^LOD
|
||||||
blr += 0.052683*texture(image, (vuv + vec2(0.0, -9.5)) / res.xy).xyz;
|
const float sigma = float(samples) * .25;
|
||||||
blr += 0.061948*texture(image, (vuv + vec2(0.0, -7.5)) / res.xy).xyz;
|
|
||||||
blr += 0.070266*texture(image, (vuv + vec2(0.0, -5.5)) / res.xy).xyz;
|
|
||||||
blr += 0.076883*texture(image, (vuv + vec2(0.0, -3.5)) / res.xy).xyz;
|
|
||||||
blr += 0.081149*texture(image, (vuv + vec2(0.0, -1.5)) / res.xy).xyz;
|
|
||||||
blr += 0.041312*texture(image, (vuv + vec2(0.0, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.081149*texture(image, (vuv + vec2(0.0, 1.5)) / res.xy).xyz;
|
|
||||||
blr += 0.076883*texture(image, (vuv + vec2(0.0, 3.5)) / res.xy).xyz;
|
|
||||||
blr += 0.070266*texture(image, (vuv + vec2(0.0, 5.5)) / res.xy).xyz;
|
|
||||||
blr += 0.061948*texture(image, (vuv + vec2(0.0, 7.5)) / res.xy).xyz;
|
|
||||||
blr += 0.052683*texture(image, (vuv + vec2(0.0, 9.5)) / res.xy).xyz;
|
|
||||||
blr += 0.043219*texture(image, (vuv + vec2(0.0, 11.5)) / res.xy).xyz;
|
|
||||||
blr += 0.034202*texture(image, (vuv + vec2(0.0, 13.5)) / res.xy).xyz;
|
|
||||||
blr += 0.026109*texture(image, (vuv + vec2(0.0, 15.5)) / res.xy).xyz;
|
|
||||||
|
|
||||||
blr /= 0.93423; // renormalize to compensate for the 4 taps I skipped
|
float gaussian(vec2 i) {
|
||||||
return vec4(blr, 1.0);
|
return exp(-.5* dot(i /= sigma, i)) / (6.28 * sigma*sigma);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
vec4 blur(sampler2D sp, vec2 U, vec2 scale) {
|
||||||
|
vec4 O = vec4(0);
|
||||||
|
int s = samples / sLOD;
|
||||||
|
|
||||||
vec4 blur21Horiz(sampler2D image, vec2 vuv, vec2 res) {
|
for (int i = 0; i < s*s; i++) {
|
||||||
//iq CC
|
vec2 d = vec2(i%s, i / s)*float(sLOD) - float(samples) / 2.;
|
||||||
vec3 blr = vec3(0.0);
|
O += gaussian(d) * textureLod(sp, U + scale * d, float(LOD));
|
||||||
|
|
||||||
blr += 0.026109*texture(image, (vuv + vec2(-15.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.034202*texture(image, (vuv + vec2(-13.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.043219*texture(image, (vuv + vec2(-11.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.052683*texture(image, (vuv + vec2(-9.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.061948*texture(image, (vuv + vec2(-7.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.070266*texture(image, (vuv + vec2(-5.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.076883*texture(image, (vuv + vec2(-3.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.081149*texture(image, (vuv + vec2(-1.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.041312*texture(image, (vuv + vec2(0.0, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.081149*texture(image, (vuv + vec2(1.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.076883*texture(image, (vuv + vec2(3.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.070266*texture(image, (vuv + vec2(5.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.061948*texture(image, (vuv + vec2(7.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.052683*texture(image, (vuv + vec2(9.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.043219*texture(image, (vuv + vec2(11.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.034202*texture(image, (vuv + vec2(13.5, 0.0)) / res.xy).xyz;
|
|
||||||
blr += 0.026109*texture(image, (vuv + vec2(15.5, 0.0)) / res.xy).xyz;
|
|
||||||
|
|
||||||
blr /= 0.93423; // renormalize to compensate for the 4 taps I skipped
|
|
||||||
return vec4(blr, 1.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
vec2 Circle(float Start, float Points, float Point)
|
return O / O.a;
|
||||||
{
|
|
||||||
float Rad = (3.141592 * 2.0 * (1.0 / Points)) * (Point + Start);
|
|
||||||
return vec2(sin(Rad), cos(Rad));
|
|
||||||
}
|
|
||||||
|
|
||||||
vec4 circleBlur(sampler2D image, vec2 vuv, vec2 res){
|
|
||||||
//original by jcant0n ?
|
|
||||||
//vec2 uv = gl_FragCoord.xy / res.xy;
|
|
||||||
vec2 uv = vuv;
|
|
||||||
vec2 PixelOffset = 1.9 / res.xy; //1.0
|
|
||||||
|
|
||||||
float Start = 2.0 / 14.0;
|
|
||||||
vec2 Scale = 0.66 * 4.0 * 2.0 * PixelOffset.xy;
|
|
||||||
|
|
||||||
vec3 N0 = texture(image, uv + Circle(Start, 14.0, 0.0) * Scale).rgb;
|
|
||||||
vec3 N1 = texture(image, uv + Circle(Start, 14.0, 1.0) * Scale).rgb;
|
|
||||||
vec3 N2 = texture(image, uv + Circle(Start, 14.0, 2.0) * Scale).rgb;
|
|
||||||
vec3 N3 = texture(image, uv + Circle(Start, 14.0, 3.0) * Scale).rgb;
|
|
||||||
vec3 N4 = texture(image, uv + Circle(Start, 14.0, 4.0) * Scale).rgb;
|
|
||||||
vec3 N5 = texture(image, uv + Circle(Start, 14.0, 5.0) * Scale).rgb;
|
|
||||||
vec3 N6 = texture(image, uv + Circle(Start, 14.0, 6.0) * Scale).rgb;
|
|
||||||
vec3 N7 = texture(image, uv + Circle(Start, 14.0, 7.0) * Scale).rgb;
|
|
||||||
vec3 N8 = texture(image, uv + Circle(Start, 14.0, 8.0) * Scale).rgb;
|
|
||||||
vec3 N9 = texture(image, uv + Circle(Start, 14.0, 9.0) * Scale).rgb;
|
|
||||||
vec3 N10 = texture(image, uv + Circle(Start, 14.0, 10.0) * Scale).rgb;
|
|
||||||
vec3 N11 = texture(image, uv + Circle(Start, 14.0, 11.0) * Scale).rgb;
|
|
||||||
vec3 N12 = texture(image, uv + Circle(Start, 14.0, 12.0) * Scale).rgb;
|
|
||||||
vec3 N13 = texture(image, uv + Circle(Start, 14.0, 13.0) * Scale).rgb;
|
|
||||||
vec3 N14 = texture(image, uv).rgb;
|
|
||||||
|
|
||||||
vec3 color = vec3(0, 0, 0);
|
|
||||||
color.rgb =
|
|
||||||
(N0 * 0.01478636) +
|
|
||||||
(N1 * 0.03696590) +
|
|
||||||
(N2 * 0.07393179) +
|
|
||||||
(N3 * 0.07393179) +
|
|
||||||
(N4 * 0.12013917) +
|
|
||||||
(N5 * 0.16018555) +
|
|
||||||
(N6 * 0.17620411) +
|
|
||||||
(N7 * 0.17620411) +
|
|
||||||
(N8 * 0.16018555) +
|
|
||||||
(N9 * 0.12013917) +
|
|
||||||
(N10 * 0.07393179) +
|
|
||||||
(N11 * 0.07393179) +
|
|
||||||
(N12 * 0.03696590) +
|
|
||||||
(N13 * 0.03696590) +
|
|
||||||
(N14 * 0.01478636);
|
|
||||||
|
|
||||||
return vec4(color.rgb, 1.0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
vec4 blur25(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
|
|
||||||
//curent implentation doesn't work in cemu..
|
|
||||||
//mattdesl MIT - https://github.com/Jam3/glsl-fast-gaussian-blur
|
|
||||||
vec4 color = vec4(0.0);
|
|
||||||
vec2 off1 = vec2(1.44827586) * direction;
|
|
||||||
vec2 off2 = vec2(3.37931034) * direction;
|
|
||||||
vec2 off3 = vec2(5.31034483) * direction;
|
|
||||||
vec2 off4 = vec2(7.24137931) * direction;
|
|
||||||
vec2 off5 = vec2(9.17241379) * direction;
|
|
||||||
vec2 off6 = vec2(11.10344828) * direction;
|
|
||||||
|
|
||||||
//color += texture2D(image, uv - (off6 / resolution)) * 0.00001361;
|
|
||||||
color += texture2D(image, uv - (off5 / resolution)) * 0.00044240;
|
|
||||||
color += texture2D(image, uv - (off4 / resolution)) * 0.00581436;
|
|
||||||
color += texture2D(image, uv - (off3 / resolution)) * 0.03730881;
|
|
||||||
color += texture2D(image, uv - (off2 / resolution)) * 0.12888498;
|
|
||||||
color += texture2D(image, uv - (off1 / resolution)) * 0.25281284;
|
|
||||||
color += texture2D(image, uv) * 0.14944601;
|
|
||||||
color += texture2D(image, uv + (off1 / resolution)) * 0.25281284;
|
|
||||||
color += texture2D(image, uv + (off2 / resolution)) * 0.12888498;
|
|
||||||
color += texture2D(image, uv + (off3 / resolution)) * 0.03730881;
|
|
||||||
color += texture2D(image, uv + (off4 / resolution)) * 0.00581436;
|
|
||||||
color += texture2D(image, uv + (off5 / resolution)) * 0.00044240;
|
|
||||||
//color += texture2D(image, uv + (off6 / resolution)) * 0.00001361;
|
|
||||||
///= 0.93423
|
|
||||||
return color /= 0.93423;
|
|
||||||
}
|
|
||||||
|
|
||||||
int clampFI32(int v)
|
int clampFI32(int v)
|
||||||
{
|
{
|
||||||
@ -200,7 +92,7 @@ bool predResult = true;
|
|||||||
vec3 cubeMapSTM;
|
vec3 cubeMapSTM;
|
||||||
int cubeMapFaceId;
|
int cubeMapFaceId;
|
||||||
R0f = passParameterSem0;
|
R0f = passParameterSem0;
|
||||||
R0f.xy = vec2((passParameterSem0.x + passParameterSem0.z) , (passParameterSem0.y + passParameterSem0.w) ); //center point
|
R0f.xy = vec2((passParameterSem0.x + passParameterSem0.z), (passParameterSem0.y + passParameterSem0.w));
|
||||||
|
|
||||||
// 0
|
// 0
|
||||||
R1f.x = R0f.x + intBitsToFloat(uf_remappedPS[0].x) / resScale;
|
R1f.x = R0f.x + intBitsToFloat(uf_remappedPS[0].x) / resScale;
|
||||||
@ -218,25 +110,27 @@ R1f.z = backupReg0f + intBitsToFloat(uf_remappedPS[1].z)/resScale;
|
|||||||
R1f.w = backupReg1f + intBitsToFloat(uf_remappedPS[1].w) / resScale;
|
R1f.w = backupReg1f + intBitsToFloat(uf_remappedPS[1].w) / resScale;
|
||||||
|
|
||||||
|
|
||||||
|
//color.a = 1.0;
|
||||||
|
|
||||||
R2f.xyz = (texture(textureUnitPS1, R1f.xy).xyz);
|
R2f.xyz = (texture(textureUnitPS1, R1f.xy).xyz);
|
||||||
R3f.xyz = (texture(textureUnitPS1, R0f.zw).xyz);
|
R3f.xyz = (texture(textureUnitPS1, R0f.zw).xyz);
|
||||||
R4f.xyz = (texture(textureUnitPS1, R0f.xy).xyz);
|
R4f.xyz = (texture(textureUnitPS1, R0f.xy).xyz);
|
||||||
R5f.xyz = (texture(textureUnitPS1, R1f.zw).xyz);
|
R5f.xyz = (texture(textureUnitPS1, R1f.zw).xyz);
|
||||||
|
|
||||||
//vec2 iResolution = textureSize(textureUnitPS0, 0);
|
|
||||||
|
|
||||||
R6f = circleBlur(textureUnitPS0, R1f.xy, textureSize(textureUnitPS0, 0));
|
|
||||||
R7f = circleBlur(textureUnitPS0, R0f.zw, textureSize(textureUnitPS0, 0));
|
|
||||||
R0f = circleBlur(textureUnitPS0, R0f.xy, textureSize(textureUnitPS0, 0));
|
|
||||||
R1f = circleBlur(textureUnitPS0, R1f.zw, textureSize(textureUnitPS0, 0));
|
|
||||||
|
|
||||||
|
|
||||||
|
vec2 coord = passParameterSem0.xy*textureSize(textureUnitPS0, 0); // R0f.xy;// vec2(0.5, 0.5);
|
||||||
|
|
||||||
// Sample distance fails :(
|
vec2 ps = vec2(1.0) / textureSize(textureUnitPS0, 0);
|
||||||
//R6f = mix(blur25(textureUnitPS0, R1f.xy, vec2(2560, 1440), vec2(0.0, 1.0)), blur13(textureUnitPS0, R1f.xy, textureSize(textureUnitPS0, 0), vec2(1.0,0.0)), 0.5);
|
vec2 uv = coord * ps;
|
||||||
//R7f = mix(blur25(textureUnitPS0, R0f.zw, textureSize(textureUnitPS0, 0), vec2(2.0, -3.0)), blur13(textureUnitPS0, R0f.zw, textureSize(textureUnitPS0, 0), vec2(4.0, 6.0)), 0.5);
|
|
||||||
//R0f = mix(blur25(textureUnitPS0, R0f.xy, textureSize(textureUnitPS0, 0), vec2(4.0, -6.0)), blur13(textureUnitPS0, R0f.xy, textureSize(textureUnitPS0, 0), vec2(2.0, 3.0)), 0.5);
|
R6f.xyzw = blur(textureUnitPS0, uv, ps);
|
||||||
//R1f = mix(blur25(textureUnitPS0, R1f.zw, textureSize(textureUnitPS0, 0), vec2(8.0, -9.0)), blur13(textureUnitPS0, R1f.zw, textureSize(textureUnitPS0, 0), vec2(1.1, 1.5)), 0.5);
|
|
||||||
|
// R6f.xyz = blur(textureUnitPS0, uv, ps);
|
||||||
|
// R6f.w = 1.0;
|
||||||
|
R7f = R6f;
|
||||||
|
R0f = R6f;
|
||||||
|
R1f = R6f;
|
||||||
|
|
||||||
|
|
||||||
tempf.x = dot(vec4(R2f.x, R2f.y, R2f.z, -0.0), vec4(intBitsToFloat(0x3e000000), intBitsToFloat(0x41ff0000), intBitsToFloat(0x45fe0100), 0.0));
|
tempf.x = dot(vec4(R2f.x, R2f.y, R2f.z, -0.0), vec4(intBitsToFloat(0x3e000000), intBitsToFloat(0x41ff0000), intBitsToFloat(0x45fe0100), 0.0));
|
||||||
|
Loading…
Reference in New Issue
Block a user