From 80f032414a8d88fa439d9725fd475a9c0d27e41e Mon Sep 17 00:00:00 2001 From: getdls Date: Thu, 7 Dec 2017 00:19:27 +0100 Subject: [PATCH] [XCX] Bloom pixelation and scale fix Smoother bloom --- .../8c1e55fd967b0496_0000000000000079_ps.txt | 56 ++++- .../af7acf7fb6dca1be_0000000000079249_ps.txt | 2 +- .../b3fb199c73caa796_00000000000003c9_ps.txt | 237 ++++++++++++++++++ .../fdb5a87dd0368c6b_000000000000f249_ps.txt | 2 +- 4 files changed, 290 insertions(+), 7 deletions(-) create mode 100644 Source/XenobladeX/b3fb199c73caa796_00000000000003c9_ps.txt diff --git a/Source/XenobladeX/8c1e55fd967b0496_0000000000000079_ps.txt b/Source/XenobladeX/8c1e55fd967b0496_0000000000000079_ps.txt index 8813443a..d89fddd5 100644 --- a/Source/XenobladeX/8c1e55fd967b0496_0000000000000079_ps.txt +++ b/Source/XenobladeX/8c1e55fd967b0496_0000000000000079_ps.txt @@ -9,18 +9,50 @@ $scaleFactorY = always_decimal_format($fullHeight / 720.0); #version 420 #extension GL_ARB_texture_gather : enable // shader 8c1e55fd967b0496 -// ver/horz alignment tweak, just a magic value -// To-do. Go back and re-center all passes instead. +// 1/4 -> 1/16 bloom pyramid . Pixelated unless scaled but still needs blur for light bleed.. +// To-do. Check if screen res is * samples stable const float resScale = ; +//const int sampleScale = 1; //const float resScale = 4.0; const float repositionBloom = 1.00125; +highp float lineRand(vec2 co) +{ + highp float a = 12.9898; + highp float b = 78.233; + highp float c = 43758.5453; + highp float dt = dot(co.xy, vec2(a, b)); + highp float sn = mod(dt, 3.14); + return fract(sin(sn) * c); +} uniform ivec4 uf_remappedPS[5]; layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf4e76000 res 320x180x1 dim 1 tm: 4 format 0816 compSel: 0 1 2 5 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 6 6 6 border: 0 layout(location = 0) in vec4 passParameterSem0; layout(location = 0) out vec4 passPixelColor0; uniform vec2 uf_fragCoordScale; +// FabriceNeyret2, single pass gaussian by intermediate MIPmap level. https://www.shadertoy.com/view/ltScRG +// I hereby pledge my loyalty to the FabriceNeyret2 fanclub, this is bloody beautiful! +const int samples = 8, //check if must scale to pascal levels +LOD = 2, // gaussian done on MIPmap at scale LOD +sLOD = 1 << LOD; // tile size = 2^LOD +const float sigma = float(samples) * .25; + +float gaussian(vec2 i) { + 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; + + for (int i = 0; i < s*s; i++) { + vec2 d = vec2(i%s, i / s)*float(sLOD) - float(samples) / 2.; + O += gaussian(d) * textureLod(sp, U + scale * d, float(LOD)); + } + + return O / O.a; +} int clampFI32(int v) @@ -54,7 +86,8 @@ void main() vec3 cubeMapSTM; int cubeMapFaceId; R0f = passParameterSem0; - + //R0f.xy = R0f.xy - (lineRand(gl_FragCoord.xy)*0.015); + //R0f.xy = vec2((passParameterSem0.x + passParameterSem0.z), (passParameterSem0.y + passParameterSem0.w)); // 0 R1f.x = R0f.x + (intBitsToFloat(uf_remappedPS[0].x) / resScale); R1f.y = R0f.y + (intBitsToFloat(uf_remappedPS[0].y) / resScale); @@ -74,12 +107,25 @@ void main() R0f.y = backupReg1f + (intBitsToFloat(uf_remappedPS[4].y) / resScale); + vec2 coord = passParameterSem0.xy*textureSize(textureUnitPS0, 0); // R0f.xy;// vec2(0.5, 0.5); + vec2 ps = vec2(1.0) / textureSize(textureUnitPS0, 0); + vec2 uv = coord * ps; + + R4f.xyz = blur(textureUnitPS0, uv, ps).xyz; + //R4f.xyz = (texture(textureUnitPS0, R1f.xy).xyz); + R3f.xyz = (texture(textureUnitPS0, R0f.zw).xyz); + R2f.xyz = (texture(textureUnitPS0, R2f.xy).xyz);// prob? + R1f.xyz = (texture(textureUnitPS0, R1f.zw).xyz); + R0f.xyz = (texture(textureUnitPS0, R0f.xy).xyz); + + /* //org R4f.xyz = (texture(textureUnitPS0, R1f.xy).xyz); R3f.xyz = (texture(textureUnitPS0, R0f.zw).xyz); - R2f.xyz = (texture(textureUnitPS0, R2f.xy).xyz); + R2f.xyz = (texture(textureUnitPS0, R2f.xy).xyz);// prob? R1f.xyz = (texture(textureUnitPS0, R1f.zw).xyz); R0f.xyz = (texture(textureUnitPS0, R0f.xy).xyz); - + + */ // 0 PV0f.x = R4f.y * intBitsToFloat(uf_remappedPS[0].z); PV0f.y = R4f.x * intBitsToFloat(uf_remappedPS[0].z); diff --git a/Source/XenobladeX/af7acf7fb6dca1be_0000000000079249_ps.txt b/Source/XenobladeX/af7acf7fb6dca1be_0000000000079249_ps.txt index b09c8a40..2e719744 100644 --- a/Source/XenobladeX/af7acf7fb6dca1be_0000000000079249_ps.txt +++ b/Source/XenobladeX/af7acf7fb6dca1be_0000000000079249_ps.txt @@ -13,7 +13,7 @@ $scaleFactorY = always_decimal_format($fullHeight / 720.0); //to do - extra edge smooth pass, //const float resScale = 2.0;// 2.0 looks good const float resScale = ; -const float shadowExposure = 0.75; //By truncating shadow, we decrease overall exposure during day only. +const float shadowExposure = 0.85; //By truncating shadow, we decrease overall exposure during day only. uniform ivec4 uf_remappedPS[31]; layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf4386000 res 1280x720x1 dim 1 tm: 4 format 001a compSel: 0 1 2 3 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 0 layout(binding = 1) uniform sampler2D textureUnitPS1;// Tex1 addr 0xf599a000 res 1024x1024x1 dim 1 tm: 4 format 0005 compSel: 0 4 4 5 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler1 ClampX/Y/Z: 6 6 6 border: 2 diff --git a/Source/XenobladeX/b3fb199c73caa796_00000000000003c9_ps.txt b/Source/XenobladeX/b3fb199c73caa796_00000000000003c9_ps.txt new file mode 100644 index 00000000..87e323ff --- /dev/null +++ b/Source/XenobladeX/b3fb199c73caa796_00000000000003c9_ps.txt @@ -0,0 +1,237 @@ + + + +#version 420 +#extension GL_ARB_texture_gather : enable +// shader b3fb199c73caa796 // bloom pyramid sample 1st +const float resScale = ; +//const float resScale = 3.0; +uniform ivec4 uf_remappedPS[4]; +layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf551a000 res 1280x720x1 dim 1 tm: 4 format 001a compSel: 0 1 2 3 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 0 +layout(binding = 1) uniform sampler2D textureUnitPS1;// Tex1 addr 0xf470a000 res 1280x720x1 dim 1 tm: 4 format 0816 compSel: 0 1 2 5 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler1 ClampX/Y/Z: 2 2 2 border: 0 +layout(location = 0) in vec4 passParameterSem0; +layout(location = 0) out vec4 passPixelColor0; +uniform vec2 uf_fragCoordScale; +const int samples = 8, //check if must scale to pascal levels 8 balances 13 is smooth. +LOD = 2, // gaussian done on MIPmap at scale LOD +sLOD = 1 << LOD; // tile size = 2^LOD +const float sigma = float(samples) * .25; + +float gaussian(vec2 i) { + 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; + + for (int i = 0; i < s*s; i++) { + vec2 d = vec2(i%s, i / s)*float(sLOD) - float(samples) / 2.; + O += gaussian(d) * textureLod(sp, U + scale * d, float(LOD)); + } + + return O / O.a; +} + + +int clampFI32(int v) +{ +if( v == 0x7FFFFFFF ) + return floatBitsToInt(1.0); +else if( v == 0xFFFFFFFF ) + return floatBitsToInt(0.0); +return floatBitsToInt(clamp(intBitsToFloat(v), 0.0, 1.0)); +} +float mul_nonIEEE(float a, float b){ return min(a*b,min(abs(a)*3.40282347E+38F,abs(b)*3.40282347E+38F)); } +void main() +{ +vec4 R0f = vec4(0.0); +vec4 R1f = vec4(0.0); +vec4 R2f = vec4(0.0); +vec4 R3f = vec4(0.0); +vec4 R4f = vec4(0.0); +vec4 R5f = vec4(0.0); +vec4 R6f = vec4(0.0); +vec4 R7f = vec4(0.0); +vec4 R123f = vec4(0.0); +vec4 R124f = vec4(0.0); +vec4 R125f = vec4(0.0); +vec4 R126f = vec4(0.0); +vec4 R127f = vec4(0.0); +float backupReg0f, backupReg1f, backupReg2f, backupReg3f, backupReg4f; +vec4 PV0f = vec4(0.0), PV1f = vec4(0.0); +float PS0f = 0.0, PS1f = 0.0; +vec4 tempf = vec4(0.0); +float tempResultf; +int tempResulti; +ivec4 ARi = ivec4(0); +bool predResult = true; +vec3 cubeMapSTM; +int cubeMapFaceId; +R0f = passParameterSem0; +// 0 +R1f.x = R0f.x + intBitsToFloat(uf_remappedPS[0].x)/resScale; +R1f.y = R0f.y + intBitsToFloat(uf_remappedPS[0].y)/resScale; +R0f.z = R0f.x + intBitsToFloat(uf_remappedPS[0].z)/resScale; +R0f.w = R0f.y + intBitsToFloat(uf_remappedPS[0].w)/resScale; +// 1 +backupReg0f = R0f.x; +backupReg1f = R0f.y; +backupReg0f = R0f.x; +backupReg1f = R0f.y; +R0f.x = backupReg0f + intBitsToFloat(uf_remappedPS[1].x)/resScale; +R0f.y = backupReg1f + intBitsToFloat(uf_remappedPS[1].y) /resScale; +R1f.z = backupReg0f + intBitsToFloat(uf_remappedPS[1].z) /resScale; +R1f.w = backupReg1f + intBitsToFloat(uf_remappedPS[1].w) /resScale; + +vec2 coord = passParameterSem0.xy*textureSize(textureUnitPS0, 0); // R0f.xy;// vec2(0.5, 0.5); + +vec2 ps = vec2(1.0) / textureSize(textureUnitPS0, 0); +vec2 uv = coord * ps; + +R2f.xyzw = blur(textureUnitPS1, uv, ps); + +R3f = R2f; +R4f = R2f; +R5f = R2f; + +/* +R2f.xyzw = (texture(textureUnitPS1, R1f.xy).xyzw); +R3f.xyzw = (texture(textureUnitPS1, R0f.zw).xyzw); +R4f.xyzw = (texture(textureUnitPS1, R0f.xy).xyzw); +R5f.xyzw = (texture(textureUnitPS1, R1f.zw).xyzw); +*/ +//R1f.xyzw = blur(textureUnitPS0, uv, ps); +//R7f = R6f; +//R0f = R6f; +//R1f = R6f; +R6f.xyzw = (texture(textureUnitPS0, R1f.xy).xyzw); +R7f.xyzw = (texture(textureUnitPS0, R0f.zw).xyzw); +R0f.xyzw = (texture(textureUnitPS0, R0f.xy).xyzw); +R1f.xyzw = (texture(textureUnitPS0, R1f.zw).xyzw); +// 0 +PV0f.x = R2f.z + R3f.z; +PV0f.y = R2f.y + R3f.y; +PV0f.z = R2f.x + R3f.x; +PV0f.w = R2f.w + R3f.w; +// 1 +PV1f.x = PV0f.x + R4f.z; +PV1f.y = PV0f.y + R4f.y; +PV1f.z = PV0f.z + R4f.x; +PV1f.w = PV0f.w + R4f.w; +R127f.x = R6f.x + R7f.x; +PS1f = R127f.x; +// 2 +PV0f.x = PV1f.x + R5f.z; +PV0f.y = PV1f.y + R5f.y; +PV0f.z = PV1f.z + R5f.x; +PV0f.w = PV1f.w + R5f.w; +R127f.w = R6f.y + R7f.y; +PS0f = R127f.w; +// 3 +PV1f.x = PV0f.x * intBitsToFloat(uf_remappedPS[2].z); +PV1f.y = PV0f.y * intBitsToFloat(uf_remappedPS[2].z); +PV1f.z = PV0f.z * intBitsToFloat(uf_remappedPS[2].z); +PV1f.w = PV0f.w * intBitsToFloat(uf_remappedPS[2].z); +R127f.z = R6f.z + R7f.z; +PS1f = R127f.z; +// 4 +PV0f.x = max(PV1f.x, 0.0); +PV0f.y = max(PV1f.y, 0.0); +PV0f.z = max(PV1f.z, 0.0); +PV0f.w = max(PV1f.w, 0.0); +R126f.y = R6f.w + R7f.w; +PS0f = R126f.y; +// 5 +R6f.x = min(PV0f.x, 4.0); +PV1f.x = R6f.x; +R125f.y = min(PV0f.y, 4.0); +PV1f.y = R125f.y; +R126f.z = min(PV0f.z, 4.0); +PV1f.z = R126f.z; +R125f.w = min(PV0f.w, 4.0); +R124f.x = R127f.x + R0f.x; +PS1f = R124f.x; +// 6 +PV0f.x = PV1f.z + -(intBitsToFloat(uf_remappedPS[2].x)); +PV0f.y = PV1f.y + -(intBitsToFloat(uf_remappedPS[3].x)); +PV0f.z = PV1f.z + -(intBitsToFloat(uf_remappedPS[3].x)); +PV0f.w = PV1f.x + -(intBitsToFloat(uf_remappedPS[3].x)); +R127f.y = PV1f.y + -(intBitsToFloat(uf_remappedPS[2].x)); +PS0f = R127f.y; +// 7 +R127f.x = R6f.x + -(intBitsToFloat(uf_remappedPS[2].x)); +PV1f.y = max(PV0f.z, 0.0); +PV1f.z = max(PV0f.y, 0.0); +PV1f.w = max(PV0f.w, 0.0); +R126f.x = max(PV0f.x, 0.0); +PS1f = R126f.x; +// 8 +backupReg0f = R127f.y; +R125f.x = dot(vec4(intBitsToFloat(uf_remappedPS[3].y),intBitsToFloat(uf_remappedPS[3].y),intBitsToFloat(uf_remappedPS[3].y),-0.0),vec4(PV1f.y,PV1f.z,PV1f.w,0.0)); +PV0f.x = R125f.x; +PV0f.y = R125f.x; +PV0f.z = R125f.x; +PV0f.w = R125f.x; +R127f.y = max(backupReg0f, 0.0); +PS0f = R127f.y; +// 9 +backupReg0f = R126f.y; +backupReg1f = R127f.x; +backupReg2f = R127f.w; +R127f.x = R127f.z + R0f.z; +R126f.y = backupReg0f + R0f.w; +PV1f.z = max(backupReg1f, 0.0); +R127f.w = backupReg2f + R0f.y; +R126f.w = R126f.z * PV0f.x; +PS1f = R126f.w; +// 10 +tempf.x = dot(vec4(intBitsToFloat(uf_remappedPS[2].y),intBitsToFloat(uf_remappedPS[2].y),intBitsToFloat(uf_remappedPS[2].y),-0.0),vec4(R126f.x,R127f.y,PV1f.z,0.0)); +PV0f.x = tempf.x; +PV0f.y = tempf.x; +PV0f.z = tempf.x; +PV0f.w = tempf.x; +R124f.w = tempf.x; +R127f.z = R125f.y * R125f.x; +PS0f = R127f.z; +// 11 +PV1f.x = R125f.w * R125f.x; +PV1f.y = R6f.x * R125f.x; +R125f.z = R127f.w + R1f.y; +R127f.w = R127f.x + R1f.z; +R0f.w = R126f.y + R1f.w; +PS1f = R0f.w; +// 12 +backupReg0f = R124f.x; +R124f.x = (R125f.y * R124f.w + R127f.z); +R125f.y = (R6f.x * R124f.w + PV1f.y); +PV0f.z = backupReg0f + R1f.x; +R123f.w = (R126f.z * R124f.w + R126f.w); +PV0f.w = R123f.w; +R127f.x = (R125f.w * R124f.w + PV1f.x); +PS0f = R127f.x; +// 13 +R125f.x = R127f.w * intBitsToFloat(uf_remappedPS[3].z); +R126f.y = R125f.z * intBitsToFloat(uf_remappedPS[3].z); +PV1f.z = PV0f.z * intBitsToFloat(uf_remappedPS[3].z); +R127f.w = R0f.w * intBitsToFloat(uf_remappedPS[3].z); +PS1f = min(PV0f.w, intBitsToFloat(uf_remappedPS[2].w)); +// 14 +PV0f.x = min(R127f.x, intBitsToFloat(uf_remappedPS[2].w)); +PV0f.y = min(R125f.y, intBitsToFloat(uf_remappedPS[2].w)); +PV0f.z = min(R124f.x, intBitsToFloat(uf_remappedPS[2].w)); +R0f.x = max(PV1f.z, PS1f); +PS0f = R0f.x; +// 15 +R0f.y = max(R126f.y, PV0f.z); +R0f.z = max(R125f.x, PV0f.y); +R0f.w = max(R127f.w, PV0f.x); +// export +passPixelColor0 = vec4(R0f.x, R0f.y, R0f.z, R0f.w)*1.5; +} diff --git a/Source/XenobladeX/fdb5a87dd0368c6b_000000000000f249_ps.txt b/Source/XenobladeX/fdb5a87dd0368c6b_000000000000f249_ps.txt index fcc6bf7a..3969af6e 100644 --- a/Source/XenobladeX/fdb5a87dd0368c6b_000000000000f249_ps.txt +++ b/Source/XenobladeX/fdb5a87dd0368c6b_000000000000f249_ps.txt @@ -12,7 +12,7 @@ $scaleFactorY = always_decimal_format($fullHeight / 720.0); // shadows scaling, ie 4096 = x4 // To do - some nice edge smoothing at higher res const float resScale = ; -const float shadowExposure = 0.75; +const float shadowExposure = 0.85; //const float resScale = 4; uniform ivec4 uf_remappedPS[23]; layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf4386000 res 1280x720x1 dim 1 tm: 4 format 001a compSel: 0 1 2 3 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 0