OpenGLES2 freeze in part of shader it shouldn't be reaching
Posted: Fri Aug 11, 2017 2:41 pm
Hi Folks,
I have a weird problem with a shader I'm debugging for openFL running on the raspberry pi.
OpenGLES freezes ( reboot is needed!) in a part of the shader that it shouldn't be reaching.
I have found a fix but I do not understand why it is working.
This is the fragment shader.
and here's the vertex shader:
the uColorTransform is set to true when we are using a colorTransform in the code and the vColorMultipliers is a mat4 filled with values.
But when uColorTransform = false It shouldn't be reaching that part of the shader, but it still freezes!
I know color.a is the culprit, If I comment it out or check for a value > 0.0 the freeze is gone, even though it's never getting to that part of the shader.
So by changing the uColorTransfrom part to
I can fix it. But I really want to understand what is happening.
Is this caused by an optimisation or am I missing something else?
Kind Regards
Patrick
I have a weird problem with a shader I'm debugging for openFL running on the raspberry pi.
OpenGLES freezes ( reboot is needed!) in a part of the shader that it shouldn't be reaching.
I have found a fix but I do not understand why it is working.
This is the fragment shader.
Code: Select all
precision mediump float
varying float vAlpha;
varying mat4 vColorMultipliers;
varying vec4 vColorOffsets;
varying vec2 vTexCoord;
uniform bool uColorTransform;
uniform sampler2D uImage0;
void main(void) {
vec4 color = texture2D (uImage0, vTexCoord);
if (color.a == 0.0) {
gl_FragColor = vec4 (0.0, 0.0, 0.0, 0.0);
} else if (uColorTransform) {
color = vec4 (color.rgb / color.a, color.a);
color = vColorOffsets + (color * vColorMultipliers);
gl_FragColor = vec4 (color.rgb * color.a * vAlpha, color.a * vAlpha);
} else {
gl_FragColor = color * vAlpha;
}
}Code: Select all
attribute float aAlpha;
attribute mat4 aColorMultipliers;
attribute vec4 aColorOffsets;
attribute vec4 aPosition;
attribute vec2 aTexCoord;
varying float vAlpha;
varying mat4 vColorMultipliers;
varying vec4 vColorOffsets;
varying vec2 vTexCoord;
uniform mat4 uMatrix;
uniform bool uColorTransform;
void main(void) {
vAlpha = aAlpha;
vTexCoord = aTexCoord;
if (uColorTransform) {
vColorMultipliers = aColorMultipliers;
vColorOffsets = aColorOffsets;
}
gl_Position = uMatrix * aPosition;
}But when uColorTransform = false It shouldn't be reaching that part of the shader, but it still freezes!
I know color.a is the culprit, If I comment it out or check for a value > 0.0 the freeze is gone, even though it's never getting to that part of the shader.
So by changing the uColorTransfrom part to
Code: Select all
else if (uColorTransform) {
color = vec4 (color.rgb / color.a, color.a);
color = vColorOffsets + (color * vColorMultipliers);
if(color.a > 0.0){
gl_FragColor = vec4 (color.rgb * color.a * vAlpha, color.a * vAlpha);
}
}
I can fix it. But I really want to understand what is happening.
Is this caused by an optimisation or am I missing something else?
Kind Regards
Patrick