Workaround for a strange GLSL bug

It seems like GLSL compiler is incorrectly inlining 'texelFetch(int index, ...)' and thus implicitly casting sampler2D to int
This commit is contained in:
RaveYard 2025-04-02 12:57:31 +02:00 committed by Magnus Norddahl
commit 0ede28b03d
2 changed files with 6 additions and 1 deletions

View file

@ -43,7 +43,7 @@ void main()
{
if (USE_DEPTHFADETHRESHOLD)
{
float behindFragmentDepth = texelFetch(LinearDepth, uViewOffset + ivec2(gl_FragCoord.xy), 0).r;
float behindFragmentDepth = texelFetchSampler2D(LinearDepth, uViewOffset + ivec2(gl_FragCoord.xy), 0).r;
material.Base.a *= clamp((behindFragmentDepth - pixelpos.w) / uDepthFadeThreshold, 0.0, 1.0);
}

View file

@ -121,3 +121,8 @@ vec4 texelFetch(int index, ivec2 P, int lod)
{
return texelFetch(textures[nonuniformEXT(uTextureIndex + index)], P, lod);
}
vec4 texelFetchSampler2D(sampler2D s, ivec2 P, int lod)
{
return texelFetch(s, P, lod);
}