[XCX] Colour banding fix, godray stencil, AA and brightness tweaks

Add - God ray stencil scaling. Actually does improve quality.. just hard
to notice
Fix - Sky colour banding,  increase depth + dithering
Improve - Brightness truncation banding,   increase depth + dithering
Improve - AA "fix" edges was still using old logic
This commit is contained in:
getdls 2017-11-27 23:05:06 +01:00
parent 52f4c1dbda
commit 6331abdc50
5 changed files with 162 additions and 10 deletions

View File

@ -61,7 +61,7 @@ R0i = floatBitsToInt(passParameterSem0);
R1i = floatBitsToInt(passParameterSem1); R1i = floatBitsToInt(passParameterSem1);
if( activeMaskStackC[1] == true ) { if( activeMaskStackC[1] == true ) {
//R2i.xyzw = floatBitsToInt(textureGather(textureUnitPS0, intBitsToFloat(R0i.zw)).xyzw); // cemu bug? Review later //R2i.xyzw = floatBitsToInt(textureGather(textureUnitPS0, intBitsToFloat(R0i.zw)).xyzw); // cemu bug? Review later
R0i.x = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R1i.xy)).x); // edge blur/chromatic //R0i.x = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R1i.xy)).x); // edge blur/chromatic
} }
if( activeMaskStackC[1] == true ) { if( activeMaskStackC[1] == true ) {
activeMaskStack[1] = activeMaskStack[0]; activeMaskStack[1] = activeMaskStack[0];

View File

@ -0,0 +1,127 @@
#version 420
#extension GL_ARB_texture_gather : enable
// shader 810cde937ebbdf9f // Tiny rand dithering fixing sky banding
// To-do incremental seed would be lovely... except from using previous pass as input I have no idea..
uniform ivec4 uf_remappedPS[5];
layout(location = 0) in vec4 passParameterSem0;
layout(location = 0) out vec4 passPixelColor0;
uniform vec2 uf_fragCoordScale;
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);
}
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 R123f = 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;
R0f.xy = R0f.xy - (lineRand(gl_FragCoord.xy)*0.015);
// 0
backupReg0f = R0f.x;
backupReg0f = R0f.x;
backupReg1f = R0f.y;
backupReg1f = R0f.y;
backupReg2f = R0f.z;
backupReg2f = R0f.z;
tempf.x = dot(vec4(backupReg0f,backupReg1f,backupReg2f,-0.0),vec4(backupReg0f,backupReg1f,backupReg2f,0.0));
PV0f.x = tempf.x;
PV0f.y = tempf.x;
PV0f.z = tempf.x;
PV0f.w = tempf.x;
R1f.w = 1.0;
PS0f = R1f.w;
// 1
tempResultf = 1.0 / sqrt(PV0f.x);
PS1f = tempResultf;
// 2
R127f.x = R0f.x * PS1f;
PV0f.x = R127f.x;
R127f.y = R0f.y * PS1f;
PV0f.y = R127f.y;
R127f.z = R0f.z * PS1f;
PV0f.z = R127f.z;
// 3
tempf.x = dot(vec4(intBitsToFloat(uf_remappedPS[0].x),intBitsToFloat(uf_remappedPS[0].y),intBitsToFloat(uf_remappedPS[0].z),-0.0),vec4(PV0f.x,PV0f.y,PV0f.z,0.0));
PV1f.x = tempf.x;
PV1f.y = tempf.x;
PV1f.z = tempf.x;
PV1f.w = tempf.x;
// 4
PV0f.x = intBitsToFloat(uf_remappedPS[1].z) * R127f.z;
PV0f.w = max(PV1f.x, -(PV1f.x));
// 5
R123f.x = (intBitsToFloat(uf_remappedPS[1].y) * R127f.y + PV0f.x);
PV1f.x = R123f.x;
R127f.z = -(PV0f.w) + 1.0;
R127f.z = clamp(R127f.z, 0.0, 1.0);
PV1f.z = R127f.z;
// 6
R123f.w = (intBitsToFloat(uf_remappedPS[1].x) * R127f.x + PV1f.x);
R123f.w = clamp(R123f.w, 0.0, 1.0);
PV0f.w = R123f.w;
tempResultf = log2(PV1f.z);
if( isinf(tempResultf) == true ) tempResultf = -3.40282347E+38F;
PS0f = tempResultf;
// 7
PV1f.x = PS0f * intBitsToFloat(uf_remappedPS[2].w);
tempResultf = log2(PV0f.w);
if( isinf(tempResultf) == true ) tempResultf = -3.40282347E+38F;
PS1f = tempResultf;
// 8
PV0f.y = PS1f * intBitsToFloat(uf_remappedPS[3].w);
R127f.w = exp2(PV1f.x);
PS0f = R127f.w;
// 9
R127f.x = (R127f.z * intBitsToFloat(0x3f733333) + -(PS0f));
PV1f.z = PS0f + -(intBitsToFloat(0x3f4ccccd));
R126f.x = exp2(PV0f.y);
PS1f = R126f.x;
// 10
PV0f.y = PV1f.z * intBitsToFloat(0x40a00000);
PV0f.y = clamp(PV0f.y, 0.0, 1.0);
// 11
backupReg0f = R127f.w;
R127f.w = (R127f.x * PV0f.y + backupReg0f);
PV1f.w = R127f.w;
// 12
R127f.y = (PV1f.w * intBitsToFloat(uf_remappedPS[2].y) + intBitsToFloat(uf_remappedPS[4].y));
R127f.z = (PV1f.w * intBitsToFloat(uf_remappedPS[2].x) + intBitsToFloat(uf_remappedPS[4].x));
// 13
R123f.x = (R127f.w * intBitsToFloat(uf_remappedPS[2].z) + intBitsToFloat(uf_remappedPS[4].z));
PV1f.x = R123f.x;
// 14
R1f.x = (R126f.x * intBitsToFloat(uf_remappedPS[3].x) + R127f.z);
R1f.y = (R126f.x * intBitsToFloat(uf_remappedPS[3].y) + R127f.y);
R1f.z = (R126f.x * intBitsToFloat(uf_remappedPS[3].z) + PV1f.x);
// export
passPixelColor0 = vec4(R1f.x, R1f.y, R1f.z, R1f.w);
}

View File

@ -72,11 +72,11 @@ height = 288
overwriteWidth = <?=round($scaleFactorX*512)?> overwriteWidth = <?=round($scaleFactorX*512)?>
overwriteHeight = <?=round($scaleFactorY*288)?> overwriteHeight = <?=round($scaleFactorY*288)?>
#[TextureRedefine] # "God rays" size (not quality), lens reflections. [TextureRedefine] # "God rays" stencil res, lens reflections.
#width = 256 width = 256
#height = 144 height = 144
#overwriteWidth = <?=round($scaleFactorX*256)?> overwriteWidth = <?=round($scaleFactorX*256)?>
#overwriteHeight = <?=round($scaleFactorY*144)?> overwriteHeight = <?=round($scaleFactorY*144)?>
[TextureRedefine]# Probe glow. Does not increase sample amount, only scales up [TextureRedefine]# Probe glow. Does not increase sample amount, only scales up
width = 160 width = 160

View File

@ -4,14 +4,25 @@
// To-do, .5 is daylight and 1.0 night is wiiu "correct" for nvidia // To-do, .5 is daylight and 1.0 night is wiiu "correct" for nvidia
// changes here in turn "breaks" bloom as they over or under expose depending on day/night // changes here in turn "breaks" bloom as they over or under expose depending on day/night
const float preExposure = 0.75; // old brigntess tweak. Truncates at around .45+ const float preExposure = 0.65; // old brigntess tweak. Truncates at around .45+
const float gammaPostExposure = 0.9; // compensate pre exposure, but loss of contrast when positive. const float gammaPostExposure = 0.9; // compensate pre exposure, but loss of contrast when positive.
uniform ivec4 uf_remappedPS[1]; uniform ivec4 uf_remappedPS[1];
layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf470a000 res 1280x720x1 dim 1 tm: 4 format 0816 compSel: 0 1 2 5 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 0 layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf470a000 res 1280x720x1 dim 1 tm: 4 format 0816 compSel: 0 1 2 5 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 0
layout(binding = 1) uniform sampler3D textureUnitPS1;// Tex1 addr 0x2603b000 res 16x16x16 dim 2 tm: 7 format 001a compSel: 0 1 2 3 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x10) Sampler1 ClampX/Y/Z: 2 2 2 border: 0 layout(binding = 1) uniform sampler3D textureUnitPS1;// Tex1 addr 0x2603b000 res 16x16x16 dim 2 tm: 7 format 001a compSel: 0 1 2 3 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x10) Sampler1 ClampX/Y/Z: 2 2 2 border: 0
layout(location = 0) in vec4 passParameterSem0; layout(location = 0) in vec4 passParameterSem0;
layout(location = 0) out vec4 passPixelColor0; layout(location = 0) out vec4 passPixelColor0;
uniform vec2 uf_fragCoordScale; uniform vec2 uf_fragCoordScale;
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);
}
int clampFI32(int v) int clampFI32(int v)
{ {
if( v == 0x7FFFFFFF ) if( v == 0x7FFFFFFF )
@ -37,7 +48,9 @@ bool predResult = true;
vec3 cubeMapSTM; vec3 cubeMapSTM;
int cubeMapFaceId; int cubeMapFaceId;
R0f = passParameterSem0; R0f = passParameterSem0;
R0f.xyz = (texture(textureUnitPS0, R0f.xy).xyz) * preExposure;
R0f.xyz = (texture(textureUnitPS0, R0f.xy).xyz) * (preExposure -(lineRand(gl_FragCoord.xy)*0.02));
//R0f.xyz = R0f.xyz - (lineRand(gl_FragCoord.xy)*0.1);
// 0 // 0
R127f.x = R0f.z * intBitsToFloat(uf_remappedPS[0].x); R127f.x = R0f.z * intBitsToFloat(uf_remappedPS[0].x);
R127f.x = clamp(R127f.x, 0.0, 1.0); R127f.x = clamp(R127f.x, 0.0, 1.0);

View File

@ -4,7 +4,7 @@
// cross fade brightness // cross fade brightness
// To-do, .5 is daylight and 1.0 night is wiiu "correct" for nvidia // To-do, .5 is daylight and 1.0 night is wiiu "correct" for nvidia
// changes here in turn "breaks" bloom as they over or under expose depending on day/night // changes here in turn "breaks" bloom as they over or under expose depending on day/night
const float preExposure = 0.75; // old brigntess tweak. Truncates at around .45+ const float preExposure = 0.65; // old brigntess tweak. Truncates at around .45+
const float gammaPostExposure = 0.9; // compensate pre exposure, but loss of contrast when positive. const float gammaPostExposure = 0.9; // compensate pre exposure, but loss of contrast when positive.
uniform ivec4 uf_remappedPS[1]; uniform ivec4 uf_remappedPS[1];
@ -14,6 +14,17 @@ layout(binding = 2) uniform sampler3D textureUnitPS2;// Tex2 addr 0x2603b000 res
layout(location = 0) in vec4 passParameterSem0; layout(location = 0) in vec4 passParameterSem0;
layout(location = 0) out vec4 passPixelColor0; layout(location = 0) out vec4 passPixelColor0;
uniform vec2 uf_fragCoordScale; uniform vec2 uf_fragCoordScale;
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);
}
int clampFI32(int v) int clampFI32(int v)
{ {
if( v == 0x7FFFFFFF ) if( v == 0x7FFFFFFF )
@ -40,7 +51,8 @@ bool predResult = true;
vec3 cubeMapSTM; vec3 cubeMapSTM;
int cubeMapFaceId; int cubeMapFaceId;
R0f = passParameterSem0; R0f = passParameterSem0;
R0f.xyz = (texture(textureUnitPS0, R0f.xy).xyz) *preExposure; R0f.xyz = (texture(textureUnitPS0, R0f.xy).xyz) * (preExposure -(lineRand(gl_FragCoord.yx)*0.02));
//R0f.xyz = (texture(textureUnitPS0, R0f.xy).xyz) *preExposure;
// 0 // 0
backupReg0f = R0f.x; backupReg0f = R0f.x;
PV0f.x = backupReg0f * intBitsToFloat(uf_remappedPS[0].x); PV0f.x = backupReg0f * intBitsToFloat(uf_remappedPS[0].x);