]> git.rm.cloudns.org Git - xonotic/darkplaces.git/commitdiff
Small change to offset mapping
authoruis <uis9936@gmail.com>
Wed, 3 Jan 2024 21:01:49 +0000 (00:01 +0300)
committeruis <uis9936@gmail.com>
Fri, 5 Jan 2024 15:27:00 +0000 (18:27 +0300)
Adds few fps. Function seems to be too complex for my understanding.

shader_glsl.h

index 8c5c60f4779e1207caa536218158e2fe4c604109..36c8e2655fea0b383131b8a9d6188dada63d2085 100644 (file)
 "#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",
 "      //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",