dimanche 1 mai 2016

GLSL skips "if" statement

So my GLSL fragment shader (don't think it matters) skips the "if" statement. The shader itself is very short (can't go further without solving this).

Basically I send some data via a uniform buffer object and use it further in the shader. However, the thing skips the assignment attached to the "if" statement for whatever reason.

I checked the values of the buffer object using glGetBufferSubData (tested with specific non zero values). Everything is where it needs to be. So I'm really kinda lost here. Must be some GLSL weirdness I'm not aware of.

Currently the

#version 420

layout(std140, binding = 2) uniform textureVarBuffer
{
    vec3    colorArray;             // 16 bytes
    int     textureEnable;          // 20 bytes
    int     normalMapEnable;        // 24 bytes
    int     reflectionMapEnable;    // 28 bytes

};

out vec4 frag_colour;

void main() {
    frag_colour = vec4(1.0, 1.0, 1.0, 0.5);

    if (textureEnable == 0) {
        frag_colour = vec4(colorArray, 0.5);    
    }
}

Aucun commentaire:

Enregistrer un commentaire