GLSL Uniform not initialized

Create issue
Issue #56 invalid
Pablo Mayobre created an issue

Here is the problem, when you try to initialize an uniform (uniform samper2d tex;) inside a shader, the shader is not compiled and returns "uniform couldn't be initialized".

This is not a problem with GLSL ES, since in most of the examples out there this structure is used (It could be a problem with my GPU thought).

I took this shader from the forums and tweeked it so that there would be no problem with floats, but the problem with uniforms remains:

Comments (4)

  1. Alex Szpakowski

    GLSL ES 1.0 (the shading language which OpenGL ES 2 uses) does not let you initialize a uniform variable with a value in the shader, so this line will cause an error if the GLSL ES compiler properly conforms to the specification:

    extern number fac = .5;

    The uniform sampler2D s_texi; line looks fine since it's just declaring it (and you can't initialize it with a value like you're doing with the number in any GLSL version, anyway.)

  2. Pablo Mayobre reporter

    I don't get it... Sorry I don't know much about shaders but, what is the relationship between those variables? also I think that I'm not giving the uniform a value,

    It does works on computers (of course the GLSL version is not 1.0 or 1.4)

    Thanks for your help Alex, I hope I can get to understand shaders a little more with this

  3. Pablo Mayobre reporter

    It took three months but I finally got it. Haha you were right Alex, extern can´t be initialized, instead I must pass the value after creating the shader. Also I didn´t know that extern were uniforms too.

    I leave this message for someone that might have the same issue in their code. This is a really invalid issue

  4. Log in to comment