]> 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 14:30:27 +0000 (17:30 +0300)
Adds few fps. Function seems to be too complex for my understanding.

shader_glsl.h

index f7a4d4900fa8e8b49306d81997d9205f4c043684..3ce89226a2b2f32716b485086e12df79120bf297 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",