Browse Source

texture2DLod() is obsolete, so fix that

master
M.C. 9 months ago
parent
commit
9070693039
  1. 30
      Src/Graphics/New3D/R3DShaderTriangles.h

30
Src/Graphics/New3D/R3DShaderTriangles.h

@ -3,7 +3,7 @@
static const char *vertexShaderR3D = R"glsl(
#version 120
#version 130
// uniforms
uniform float modelScale;
@ -61,7 +61,7 @@ void main(void)
static const char *fragmentShaderR3D = R"glsl(
#version 120
#version 130
uniform sampler2D tex1; // base tex
uniform sampler2D tex2; // micro tex (optional)
@ -168,10 +168,10 @@ vec4 texBiLinear(sampler2D texSampler, float level, ivec2 wrapMode, vec2 texSize
float a = LinearTexLocations(wrapMode.s, texSize.x, texCoord.x, tx[0], tx[1]);
float b = LinearTexLocations(wrapMode.t, texSize.y, texCoord.y, ty[0], ty[1]);
vec4 p0q0 = texture2DLod(texSampler, vec2(tx[0],ty[0]), level);
vec4 p1q0 = texture2DLod(texSampler, vec2(tx[1],ty[0]), level);
vec4 p0q1 = texture2DLod(texSampler, vec2(tx[0],ty[1]), level);
vec4 p1q1 = texture2DLod(texSampler, vec2(tx[1],ty[1]), level);
vec4 p0q0 = textureLod(texSampler, vec2(tx[0],ty[0]), level);
vec4 p1q0 = textureLod(texSampler, vec2(tx[1],ty[0]), level);
vec4 p0q1 = textureLod(texSampler, vec2(tx[0],ty[1]), level);
vec4 p1q1 = textureLod(texSampler, vec2(tx[1],ty[1]), level);
if(alphaTest) {
if(p0q0.a > p1q0.a) { p1q0.rgb = p0q0.rgb; }
@ -223,14 +223,14 @@ vec4 GetTextureValue()
if (microTexture) {
vec2 scale = (baseTexSize / 128.0) * microTextureScale;
vec4 tex2Data = textureR3D( tex2, ivec2(0), vec2(128.0), fsTexCoord * scale);
float lod = mip_map_level(fsTexCoord * scale * vec2(128.0));
float blendFactor = max(lod - 1.5, 0.0); // bias -1.5
blendFactor = min(blendFactor, 1.0); // clamp to max value 1
blendFactor = (blendFactor + 1.0) / 2.0; // 0.5 - 1 range
vec4 tex2Data = textureR3D( tex2, ivec2(0), vec2(128.0), fsTexCoord * scale);
float lod = mip_map_level(fsTexCoord * scale * vec2(128.0));
float blendFactor = max(lod - 1.5, 0.0); // bias -1.5
blendFactor = min(blendFactor, 1.0); // clamp to max value 1
blendFactor = (blendFactor + 1.0) / 2.0; // 0.5 - 1 range
tex1Data = mix(tex2Data, tex1Data, blendFactor);
}
@ -424,4 +424,4 @@ void main()
}
)glsl";
#endif
#endif

Loading…
Cancel
Save