mardi 23 décembre 2014

Reflection Mapping in OpenGL ES

I am trying to implement the reflection mapping in OpenGL ES 2.0 for 'sphere'. I have done the skybox. For sphere rendering, the reflection shaders i have used are:


Environment mapping (Sphere) vertex shader::



precision highp float;
uniform mat4 u_mvMatrix; // ModelView Matrix
uniform mat4 u_mvpMatrix; // ModelViewProjection Matrix

attribute vec4 a_position;
attribute vec3 a_envmapNormal;

varying vec3 v_eyecoordEyeReflection;

vec3 v_eyecoordPosition;
vec3 v_eyecoordNormal;

void main()
{
// position and normal in model coordinates
vec4 modelCoordPosition = a_position;
vec3 modelCoordNormal = a_envmapNormal;

// Calculate position in eye space
v_eyecoordPosition = vec3(u_mvMatrix * modelCoordPosition);

// Calculate and normalize eye space normal
vec3 eyecoordNormal = vec3(u_mvMatrix * vec4(modelCoordNormal, 0.0));
v_eyecoordNormal = normalize(eyecoordNormal);
// Calculate reflection vector
v_eyecoordEyeReflection = reflect(v_eyecoordPosition, v_eyecoordNormal);

gl_Position = u_mvpMatrix * a_position;
}


Environment mapping (Sphere) Fragment shader



precision highp float;
uniform lowp samplerCube baseCubeMapTexture;
varying vec3 v_eyecoordEyeReflection;

void main()
{
vec4 environmentColor = textureCube(baseCubeMapTexture, v_eyecoordEyeReflection);
gl_FragColor = environmentColor;
}


But i am not getting any output. what is the error in the shader?






Aucun commentaire:

Enregistrer un commentaire