mirror of
https://github.com/X0nk/Bliss-Shader.git
synced 2026-10-10 05:03:04 +08:00
improve normals used for refraction
This commit is contained in:
@@ -394,6 +394,24 @@ float bias(){
|
|||||||
return 0.0;
|
return 0.0;
|
||||||
#endif
|
#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//////////////////////////////
|
//////////////////////////////VOID MAIN//////////////////////////////
|
||||||
//////////////////////////////VOID MAIN//////////////////////////////
|
//////////////////////////////VOID MAIN//////////////////////////////
|
||||||
@@ -587,7 +605,10 @@ if (gl_FragCoord.x * texelSize.x < 1.0 && gl_FragCoord.y * texelSize.y < 1.0 )
|
|||||||
if(NAMETAG > 0) nameTagMask = 0.1;
|
if(NAMETAG > 0) nameTagMask = 0.1;
|
||||||
#endif
|
#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 /////////////////////////////////////
|
//////////////////////////////// SPECULARS /////////////////////////////////////
|
||||||
|
|||||||
@@ -429,6 +429,26 @@ float getBorderFogDensity(float linearDistance, vec3 playerPos, bool sky){
|
|||||||
|
|
||||||
return borderFogDensity;
|
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() {
|
void main() {
|
||||||
/* RENDERTARGETS:7,3,10 */
|
/* RENDERTARGETS:7,3,10 */
|
||||||
|
|
||||||
@@ -492,7 +512,11 @@ void main() {
|
|||||||
vec4 unpack1 = vec4(decodeVec2(data.b),decodeVec2(data.a)) ;
|
vec4 unpack1 = vec4(decodeVec2(data.b),decodeVec2(data.a)) ;
|
||||||
|
|
||||||
vec4 albedo = vec4(unpack0.ba,unpack1.rg);
|
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;
|
bool nameTagMask = abs(unpack1.a - 0.1) < 0.01;
|
||||||
float nametagbackground = nameTagMask ? 0.25 : 1.0;
|
float nametagbackground = nameTagMask ? 0.25 : 1.0;
|
||||||
|
|||||||
Reference in New Issue
Block a user