That phong shader is written for legacy OpenGL ( GLBase = compatible ). I suspect you changed the "gl_ModelViewProjectionMatrix" part in the fragment shader, but that's not nearly enough to convert it to a modern shader ( GLBase = GL3/ES2 ). Anyway, here's what the shader is supposed to look like. It's a per-pixel phong shader that supports a single point-light.
Code: Select all
<?xml version="1.0" encoding="iso-8859-1" ?>
<ZApplication Name="App" Caption="ZGameEditor application" AmbientLightColor="0 0 0 1" LightPosition="0 0 0" FileVersion="2">
<OnLoaded>
<SpawnModel Model="Box"/>
</OnLoaded>
<Lights>
<Light Position="2 2 4" Color="1 1 1 1" Kind="1" SpotDirection="0 0 0"/>
</Lights>
<Content>
<Model Name="Box" RotationVelocity="0.1 0.1 0">
<OnRender>
<UseMaterial Material="PhongMaterial"/>
<RenderMesh Mesh="BoxMesh"/>
</OnRender>
</Model>
<Mesh Name="BoxMesh">
<Producers>
<MeshBox/>
</Producers>
</Mesh>
<Shader Name="PhongShader">
<VertexShaderSource>
<![CDATA[//
varying vec3 N;
varying vec3 v;
void main(void)
{
v = vec3(gl_ModelViewMatrix * gl_Vertex);
N = normalize(gl_NormalMatrix * gl_Normal);
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
gl_FrontColor = gl_Color;
}]]>
</VertexShaderSource>
<FragmentShaderSource>
<![CDATA[//
varying vec3 N;
varying vec3 v;
void main (void)
{
vec3 L = normalize(gl_LightSource[0].position.xyz - v);
vec3 E = normalize(-v); // we are in Eye Coordinates, so EyePos is (0,0,0)
vec3 R = normalize(-reflect(L,N));
//calculate Ambient Term:
vec4 Iamb = gl_FrontLightProduct[0].ambient;
//calculate Diffuse Term:
vec4 Idiff = gl_Color * gl_FrontLightProduct[0].diffuse * max(dot(N,L), 0.0);
Idiff = clamp(Idiff, 0.0, 1.0);
// calculate Specular Term:
vec4 Ispec = gl_FrontLightProduct[0].specular
* pow(max(dot(R,E),0.0),0.3*gl_FrontMaterial.shininess);
Ispec = clamp(Ispec, 0.0, 1.0);
// write Total Color:
gl_FragColor = gl_FrontLightModelProduct.sceneColor + Iamb + Idiff + Ispec;
}]]>
</FragmentShaderSource>
</Shader>
<Material Name="PhongMaterial" Color="1 0.502 0.251 1" SpecularColor="1 1 0 1" Shininess="4" Shader="PhongShader"/>
</Content>
</ZApplication>
No, it's just a switch to choose between "legacy" OpenGL ( up to OpenGL 3.2 or OpenGL ES 1.1 ) or "modern" OpenGL.
Personally i'd always target the lowest version i absolutely need. When you target ES 3.2 it won't work on 30% of Android phones out there.
OpenGL ES version
K