diff --git a/shaders/dimensions/all_translucent.fsh b/shaders/dimensions/all_translucent.fsh index 00ace15..863f47f 100644 --- a/shaders/dimensions/all_translucent.fsh +++ b/shaders/dimensions/all_translucent.fsh @@ -394,6 +394,24 @@ float bias(){ return 0.0; #endif } +vec2 allocatePrecision_TangentNormal(vec2 normals){ + + vec2 newNormal = normals; + + if(normals.x < 0.0) { + newNormal.x = -pow(1.0-pow(1.0-clamp(-newNormal.x,0.0,1.0),2),0.5); + }else{ + newNormal.x = pow(1.0-pow(1.0-clamp( newNormal.x,0.0,1.0),2),0.5); + } + if(normals.y < 0.0) { + newNormal.y = -pow(1.0-pow(1.0-clamp(-newNormal.y,0.0,1.0),2),0.5); + }else{ + newNormal.y = pow(1.0-pow(1.0-clamp( newNormal.y,0.0,1.0),2),0.5); + } + + return clamp(newNormal + newNormal*interleaved_gradientNoise_temporal()*0.025,-1.0,1.0); +} + //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// //////////////////////////////VOID MAIN////////////////////////////// @@ -586,8 +604,11 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 ) #if defined ENTITIES && defined IS_IRIS if(NAMETAG > 0) nameTagMask = 0.1; #endif - - gl_FragData[2] = vec4(encodeVec2(TangentNormal*0.5+0.5), encodeVec2(GLASS_TINT_COLORS.rg), encodeVec2(GLASS_TINT_COLORS.ba), encodeVec2(0.0, nameTagMask)); + + // write with a curve applied to the normal to put denser bits where finer detail is needed. and then dither + TangentNormal = allocatePrecision_TangentNormal(TangentNormal) * 0.5 + 0.5; + + gl_FragData[2] = vec4(encodeVec2(TangentNormal), encodeVec2(GLASS_TINT_COLORS.rg), encodeVec2(GLASS_TINT_COLORS.ba), encodeVec2(0.0, nameTagMask)); //////////////////////////////////////////////////////////////////////////////// //////////////////////////////// SPECULARS ///////////////////////////////////// diff --git a/shaders/dimensions/composite3.fsh b/shaders/dimensions/composite3.fsh index 1048a58..f8bd4bd 100644 --- a/shaders/dimensions/composite3.fsh +++ b/shaders/dimensions/composite3.fsh @@ -429,6 +429,26 @@ float getBorderFogDensity(float linearDistance, vec3 playerPos, bool sky){ return borderFogDensity; } + +vec2 allocatePrecision_TangentNormal(vec2 normals){ + + vec2 newNormal = normals; + + if(normals.x < 0.0) { + newNormal.x = -(1.0-pow(1-pow(clamp(-newNormal.x,0.0,1.0),2),0.5)); + }else{ + newNormal.x = (1.0-pow(1-pow(clamp( newNormal.x,0.0,1.0),2),0.5)); + } + if(normals.y < 0.0) { + newNormal.y = -(1.0-pow(1-pow(clamp(-newNormal.y,0.0,1.0),2),0.5)); + }else{ + newNormal.y = (1.0-pow(1-pow(clamp( newNormal.y,0.0,1.0),2),0.5)); + } + + return newNormal; +} + + void main() { /* RENDERTARGETS:7,3,10 */ @@ -492,7 +512,11 @@ void main() { vec4 unpack1 = vec4(decodeVec2(data.b),decodeVec2(data.a)) ; vec4 albedo = vec4(unpack0.ba,unpack1.rg); - vec2 tangentNormals = unpack0.xy*2.0-1.0; + + vec2 tangentNormals = unpack0.xy* 2.0 - 1.0; + // this was written with a curve applied to the normal to put denser bits where finer detail is needed. this is the inverse. + tangentNormals = allocatePrecision_TangentNormal(tangentNormals); + bool nameTagMask = abs(unpack1.a - 0.1) < 0.01; float nametagbackground = nameTagMask ? 0.25 : 1.0;