Bridge OpenGL delegate is returning a_normal as (0. , 0. , 0.)


#1

I am facing an issue when using the OpenGL shader with Bridge engine delegate. For some reason I am not being able to get the vertex normal value at the fragment shader. Following is the way its implemented(using the Bridget demo):

On ScanEnvironmentShader.mm

#include <OpenGLES/ES2/gl.h>

const int NUM_ATTRIBS =  **2** ;

// Vertex and Normal Layout

GLuint attributeIds[NUM_ATTRIBS] = {GLKVertexAttribPosition, GLKVertexAttribNormal};

const char *attributeNames[NUM_ATTRIBS] = {  **"a_position"** ,  **"a_normal"**  };

self .glProgram = BEShaderLoadProgramFromString ([ self vertexShaderSource],

                                  [ **self**  fragmentShaderSource],

                                  NUM_ATTRIBS,

                                  attributeIds,

                                  attributeNames);

On scanEnvironmentShader.vsh

attribute vec4 a_position;

attribute vec3 a_normal;

uniform mat4 u_perspective_projection;

uniform mat4 u_modelview;

varying vec3 v_worldPos;

varying vec3 v_a_normal;

void main()

{

v_worldPos = [a_position.xyz](http://a_position.xyz/);

v_a_normal = a_normal;

gl_Position = u_perspective_projection * u_modelview * a_position;

}

On scanEnvironmentShader.fsh

varying vec3 v_a_normal;

void main()

{

if ((v_a_normal.x == 0. && v_a_normal.y == 0. && v_a_normal.z == 0.)){

gl_FragColor = vec4 (zeroColor,1.);

}else{

gl_FragColor = vec4 (nonColor,1.);

}

}

I am always getting v_a_normal as (0. , 0. , 0.)