Very basic Shader crash

Hi,
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;
}

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

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

Thanks!

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.
    but
  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.

Ok, I’m very sad ;(.
Had a projet that rely on it.
I read that it was ok on kronos specs (chapter 8.7)
http://www.khronos.org/registry/gles/specs/2.0/GLSL_ES_Specification_1.0.17.pdf#page32

Thanks anyway.

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

"OpenGL ES 2.0 on the PowerVR SGX

Limits

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