Shader does not accept the Parameters.

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Shader does not accept the Parameters.

Vasilij
Hello,

I have written vShader and fShader in GLSL ES 3.0.

I can compile them without errors and I link them to Shader-programm.
Now, when i initilaise them like this:  positionIdx = gl.glGetAttribLocation(shaderProgram, "a_position");
the int-value of "positionIdx" is -1.What can be a problem?
Reply | Threaded
Open this post in threaded view
|

Re: Shader does not accept the Parameters.

jmaasing
Shader compilers are allowed to optimize away "in" parameters (and uniforms) that are not used in the shader program. So even if "a_position" is declared in the shader, if it is not used you can get -1 as result.
Reply | Threaded
Open this post in threaded view
|

Re: Shader does not accept the Parameters.

Vasilij
In my opinion, i use that Parameters in Shaders.
Hier is a vShader:

in vec4 a_position;
void main()
{
        gl_Position = a_position;
}

and a fShader:

in vec2 a_texCoord;
uniform sampler2D s_texture;
layout(location = 0) out vec4 data;
void main ()
{
        data = texture(s_texture, a_texCoord);
}

I initialise them like this:
int positionIdx = gl.glGetAttribLocation(shaderProgram, "a_position");
int texCoordIdx = gl.glGetAttribLocation(shaderProgram, "a_texCoord");
int sampIdx = gl.glGetUniformLocation(shaderProgram, "s_texture");

Are my Shaders broken?
Reply | Threaded
Open this post in threaded view
|

Re: Shader does not accept the Parameters.

jmaasing
The only thing I can think of is that they are missing a version tag. For example #version 410 core
So maybe your driver considers them an "old" version of GLSL and fails somehow but that should've resulted in them not compiling.
Reply | Threaded
Open this post in threaded view
|

Re: Shader does not accept the Parameters.

Vasilij
Yes, i had this idea too.
I have added "#version 300 es" at the beginning of Shaders.
On PC there is an Error: "Incorrect GLSL version for token es: 300"

Not a Problem, because the RasPi can compile Shaders without Errors. But the int-Values are still -1.
Reply | Threaded
Open this post in threaded view
|

Re: Shader does not accept the Parameters.

jmaasing
I thought RasPi was GLES 2.0 only? If you give it GLES 3 shaders I guess they will fail to compile and maybe the compiler isn't nice enough to tell you they failed.
Reply | Threaded
Open this post in threaded view
|

Re: Shader does not accept the Parameters.

Sven Gothel
Administrator
On 02/13/2014 02:22 PM, jmaasing [via jogamp] wrote:
> I thought RasPi was GLES 2.0 only? If you give it GLES 3 shaders I guess they
> will fail to compile and maybe the compiler isn't nice enough to tell you they
> failed.

Note: If you look at our GearsES2 demo - or any other utilizing ShaderCode,
you will see that we add the GLSL version tag and other defines
at runtime depending on the used GLContext version.

Check call hierarchy on 'ShaderCode.addGLSLVersion(GL2ES2 gl)'.

Reason we do this is, b/c some GL implementation can by very picky
and refuse to run any shader code not matching the GLContext version.

~Sven



signature.asc (894 bytes) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: Shader does not accept the Parameters.

jmaasing
Sven Gothel wrote
On 02/13/2014 02:22 PM, jmaasing [via jogamp] wrote:
> I thought RasPi was GLES 2.0 only? If you give it GLES 3 shaders I guess they
> will fail to compile and maybe the compiler isn't nice enough to tell you they
> failed.

Note: If you look at our GearsES2 demo - or any other utilizing ShaderCode,
you will see that we add the GLSL version tag and other defines
at runtime depending on the used GLContext version.

Check call hierarchy on 'ShaderCode.addGLSLVersion(GL2ES2 gl)'.

Reason we do this is, b/c some GL implementation can by very picky
and refuse to run any shader code not matching the GLContext version.

~Sven




signature.asc (894 bytes) <http://forum.jogamp.org/attachment/4031568/0/signature.asc>
I did not know that, nice feature :-)
Reply | Threaded
Open this post in threaded view
|

Re: Shader does not accept the Parameters.

Vasilij
Thank you for answers.
The error was in Shader, I have not see it because the Compiler on Raspi has compile it without errors.
Reply | Threaded
Open this post in threaded view
|

Re: Shader does not accept the Parameters.

Xerxes Rånby
Take a look at the JOGL wiki where we have collected knowledge on how to write cross GLProfile compatible shaders:
http://jogamp.org/wiki/index.php/How_to_write_cross_GLProfile_compatible_shader_using_JOGL


2014-02-18 12:40 GMT+01:00 Vasilij [via jogamp] <[hidden email]>:
Thank you for answers.
The error was in Shader, I have not see it because the Compiler on Raspi has compile it without errors.


If you reply to this email, your message will be added to the discussion below:
http://forum.jogamp.org/Shader-does-not-accept-the-Parameters-tp4031551p4031625.html
To start a new topic under jogl, email [hidden email]
To unsubscribe from jogamp, click here.
NAML