Skip to content

Commit 695bdbf

Browse files
committed
improve the microtexture blending factor
1 parent 5d547e3 commit 695bdbf

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

Src/Graphics/New3D/R3DShaderCommon.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ vec4 GetTextureValue()
225225

226226
blendFactor = ffL;
227227
}
228-
else if (microTexture && lod < -microTextureMinLOD)
228+
else if (microTexture && lod < 0.0)
229229
{
230230
vec4 scaleIndex = vec4(2.0, 4.0, 16.0, 256.0); // unsure if minLOD=4 has 256x scale? No games appear to use it
231231
vec2 scale = (vec2(baseTexInfo.zw) / 128.0) * scaleIndex[int(microTextureMinLOD)];
@@ -234,8 +234,8 @@ vec4 GetTextureValue()
234234
ivec2 tex2Pos = GetMicroTexturePos(microTextureID);
235235
tex2Data = texBiLinear(textureBank[(texturePage+1)&1], ivec2(0), ivec2(128), tex2Pos, fsTexCoord * scale, 0);
236236

237-
blendFactor = -(lod + microTextureMinLOD) * 0.5;
238-
blendFactor = clamp(blendFactor, 0.0, 0.5);
237+
blendFactor = -lod * exp2(-microTextureMinLOD) * 0.5;
238+
blendFactor = min(blendFactor, 0.5);
239239
}
240240

241241
tex1Data = mix(tex1Data, tex2Data, blendFactor);

0 commit comments

Comments
 (0)