This code used to work correctly:It is used to not set bits in a stencil for pixels of a certain colour or opacity. The output fragment colour is not actually used.
I noticed it had stopped working correctly some months ago but I've only got round to investigating the problem today.
The symptoms were pixels that should have not been drawn (due to the stencil being zero) were randomly varying in brightness.
The problem seems to be a result of having set the out value in the shader before calling discard.
The code below works as expected.
So something in the behaviour of shaders has changed at some point but I don't know which update to the openGLES libraries introduced the problem.
PeterO
Code:
/* This file is part of the Elliott 803 emulator. Copyright © 2024 Peter Onion See LICENCE file. */precision mediump float;uniform sampler2D s_texture;in vec2 v_texCoord;out vec4 outColour;void main(){ if (gl_FrontFacing) { outColour = texture( s_texture, v_texCoord ); if((outColour.r < 0.31) || (outColour.r > 0.33) || (outColour.a<0.9)) discard; } else { discard; }}I noticed it had stopped working correctly some months ago but I've only got round to investigating the problem today.
The symptoms were pixels that should have not been drawn (due to the stencil being zero) were randomly varying in brightness.
The problem seems to be a result of having set the out value in the shader before calling discard.
The code below works as expected.
Code:
/* This file is part of the Elliott 803 emulator. Copyright © 2024 Peter Onion See LICENCE file. */precision mediump float;uniform sampler2D s_texture;in vec2 v_texCoord;void main(){vec4 pixel; if (gl_FrontFacing) { pixel = texture( s_texture, v_texCoord ); if((pixel.r < 0.31) || (pixel.r > 0.33) || (pixel.a<0.9)) discard; } else { discard; }}So something in the behaviour of shaders has changed at some point but I don't know which update to the openGLES libraries introduced the problem.
PeterO
Statistics: Posted by PeterO — Tue Jul 22, 2025 7:02 pm