Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Very basic Shader crash

edited March 2013 in Shaders Posts: 24

I'm trying to do a very simple vertex shader deforming a mesh according to a texture.
I got a black picture or codea crash with this simple example ( just trying to read color value from texture within vertex shader)

Thanks for your help!

Here is the code:

// // A basic vertex shader // //This is the current model * view * projection matrix // Codea sets it automatically uniform mat4 modelViewProjection; uniform sampler2D texture; //This is the current mesh vertex position, color and tex coord // Set automatically attribute vec4 position; attribute vec4 color; attribute vec2 texCoord; //This is an output variable that will be passed to the fragment shader varying lowp vec4 vColor; varying highp vec2 vTexCoord; void main() {     //Pass the mesh color to the fragment shader     vColor = color;     vTexCoord = texCoord;     // if I remove the comment from the line below image goes black or codea crash     //vec4 colo=texture2D( texture, texCoord );          //Multiply the vertex position by our combined transform     gl_Position = modelViewProjection * position; }


  • Posts: 2,161

    You can't access the texture from within the vertex shader, only from within the fragment shader.

  • Posts: 24

    Arrrg! Is it a codea limitation? Opengl es limitation?
    Is there any tricks to do that?


  • Posts: 455

    Simple answer, it's not able to do it.

    Complex answer:
    1) OpenGL ES sets out minimum standards and textures in vertex shader is a non mandatory capability.
    2) Apples implementation doesn't support it.
    3) Apples solution did support it back in iOS 4.2 but then removed it.

    My guess is apple originally put it in and it notionally works in the hardware, but it was unstable or something so they disabled it in the driver.

  • Posts: 24

    Ok, I'm very sad ;(.
    Had a projet that rely on it.
    I read that it was ok on kronos specs (chapter 8.7)

    Thanks anyway.

  • Posts: 489

    Hello @Bendiben. The platform notes for OpenGL ES Programming Guide for iOS are here:

    "OpenGL ES 2.0 on the PowerVR SGX



    You can use up to 8 textures in a fragment shader. You cannot use texture lookups in a vertex shader.

Sign In or Register to comment.