From 4790d3748f59e3454d7f983da6bdb211e085d547 Mon Sep 17 00:00:00 2001 From: uis Date: Thu, 4 Jan 2024 00:01:49 +0300 Subject: [PATCH] Small change to offset mapping Adds few fps. Function seems to be too complex for my understanding. --- shader_glsl.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/shader_glsl.h b/shader_glsl.h index 8c5c60f4..36c8e265 100644 --- a/shader_glsl.h +++ b/shader_glsl.h @@ -871,8 +871,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", @@ -898,9 +897,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", -- 2.39.2