PDA

View Full Version : GLES shader won't compile on iphone

mlfarrell
02-09-2010, 02:00 PM
This makes no sense. My shader won't build on the iphone, citing a link error that is wrong. See below:

Log contents:

precision mediump float;

void main()
{
}

//precision mediump float;

void main()
{
}

//#version 120

precision mediump float;

uniform mat4 ModelViewMatrix;
uniform mat4 ModelViewProjMatrix;
uniform mat4 NormalMatrix;
uniform vec4 Color;

attribute vec4 Vertex;
attribute vec4 Normal;

varying vec4 out_color;

/************************************************** *****
* Fixed.vert Fixed Function Equivalent Vertex Shader *
* Automatically Generated by 3Dlabs GLSL ShaderGen *
* http://developer.3dlabs.com *
************************************************** *****/
vec4 Ambient;
vec4 Diffuse;
vec4 Specular;

void pointLight(in int i, in vec3 normal, in vec3 eye, in vec3 ecPosition3)
{
float nDotVP; // normal . light direction
float nDotHV; // normal . light half vector
float pf; // power factor
float attenuation; // computed attenuation factor
float d; // distance from surface to light source
vec3 VP; // direction from surface to light position
vec3 halfVector; // direction of maximum highlights

// Compute vector from surface to light position
VP = vec3 (0,0,1) - ecPosition3;

// Compute distance between surface and light position
d = length(VP);

// Normalize the vector from surface to light position
VP = normalize(VP);

// Compute attenuation
attenuation = 1.0;

halfVector = normalize(VP + eye);

nDotVP = max(0.0, dot(normal, VP));
nDotHV = max(0.0, dot(normal, halfVector));

if (nDotVP == 0.0)
{
pf = 0.0;
}
else
{
pf = pow(nDotHV, 100.0);
}
Ambient += vec4(0);
Diffuse += vec4(1,1,1,1) * nDotVP;
Specular += vec4(1,1,1,1) * pf;
}

vec3 fnormal(void)
{
//Compute the normal
vec3 normal = (NormalMatrix * Normal).xyz;
normal = normalize(normal);
return normal;
}

void flight(in vec3 normal, in vec4 ecPosition, float alphaFade)
{
vec4 color;
vec3 ecPosition3;
vec3 eye;

ecPosition3 = (vec3 (ecPosition)) / ecPosition.w;
eye = vec3 (0.0, 0.0, 1.0);

// Clear the light intensity accumulators
Ambient = vec4 (0.0);
Diffuse = vec4 (0.0);
Specular = vec4 (0.0);

pointLight(0, normal, eye, ecPosition3);

color = Ambient*vec4(0.2, 0.2, 0.2, 1.0) +
Diffuse*Color;
color += Specular;
color = clamp( color, 0.0, 1.0 );
out_color = color;

}

{
vec3 transformedNormal;

// Eye-coordinate position of vertex, needed in various calculations
vec4 ecPosition = ModelViewMatrix * Vertex;

// Do fixed functionality vertex transform
transformedNormal = fnormal();
return ModelViewProjMatrix * Vertex;
}

//#version 120

precision mediump float;
varying vec4 out_color;

/************************************************** *****
* Fixed.frag Fixed Function Equivalent Fragment Shader *
* Automatically Generated by 3Dlabs GLSL ShaderGen *
* http://developer.3dlabs.com *
************************************************** *****/

{
return out_color;
}

Did apple screw up the OpenGLES 2.0 implementation on the iphone simulator?

mlfarrell
02-09-2010, 02:43 PM