From: uis Date: Wed, 3 Jan 2024 21:01:49 +0000 (+0300) Subject: Small change to offset mapping X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e2693f1d8e780bb99f4b51505a1ced8cebc86cd2;p=xonotic%2Fdarkplaces.git Small change to offset mapping Adds few fps. Function seems to be too complex for my understanding. --- diff --git a/shader_glsl.h b/shader_glsl.h index f7a4d490..3ce89226 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -884,8 +884,7 @@ "#else\n", " mediump float LODSteps = ceil(GuessLODFactor * OffsetMapping_ScaleSteps.y);\n", "#endif\n", -" mediump float LODFactor = LODSteps / OffsetMapping_ScaleSteps.y;\n", -" mediump vec4 ScaleSteps = vec4(OffsetMapping_ScaleSteps.x, LODSteps, 1.0 / LODSteps, OffsetMapping_ScaleSteps.w * LODFactor);\n", +" mediump vec4 ScaleSteps = vec4(OffsetMapping_ScaleSteps.x, LODSteps, vec2(1.0, OffsetMapping_ScaleSteps.w * LODSteps) / vec2(LODSteps, OffsetMapping_ScaleSteps.y));\n", "#else\n", " #define ScaleSteps OffsetMapping_ScaleSteps\n", "#endif\n", @@ -911,9 +910,10 @@ " //vec2 OffsetVector = vec2(normalize(EyeVectorFogDepth.xy) * ScaleSteps.x * vec2(-1, 1));\n", " vec2 OffsetVector = vec2(normalize(EyeVectorFogDepth.xyz).xy * ScaleSteps.x * vec2(-1, 1));\n", " OffsetVector *= ScaleSteps.z;\n", +" vec2 OneMinusBias_OffsetVector = (1.0 - OffsetMapping_Bias) * OffsetVector;\n", " for(i = 0.0; i < ScaleSteps.y; ++i)\n", -" TexCoord += OffsetVector * ((1.0 - OffsetMapping_Bias) - dp_textureGrad(Texture_Normal, TexCoord, dPdx, dPdy).a);\n", -" return TexCoord;\n", +" TexCoord += -dp_textureGrad(Texture_Normal, TexCoord, dPdx, dPdy).a * OffsetVector + OneMinusBias_OffsetVector;\n", +" return TexCoord;\n" "#endif\n", "}\n", "#endif // USEOFFSETMAPPING\n",