Cliff, I'm struggling with a shader problem you might be able to help with. I just want a texture, single point light, single directional light shader. I have this that Paul shared on your shader thread:
Pixel shader
// pixel shader
uniform sampler2D texture0;
varying vec2 uvVarying;
varying vec3 normalVarying;
varying vec3 posVarying;
uniform vec4 agk_PLightPos;
uniform vec4 agk_PLightColor;
uniform vec3 agk_DLightDir;
uniform vec4 agk_DLightColor;
uniform vec4 agk_ObjColor;
void main()
{
vec3 dir = agk_PLightPos.xyz - posVarying;
vec3 norm = normalize(normalVarying);
float atten = dot(dir,dir);
atten = clamp(agk_PLightPos.w/atten,0.0,1.0);
float intensity = dot(normalize(dir),norm);
intensity = clamp(intensity,0.0,1.0);
vec3 color = agk_PLightColor.rgb * intensity * atten;
color = color + clamp(dot(-agk_DLightDir,norm)*agk_DLightColor.rgb,0.2,1.0);
gl_FragColor = texture2D(texture0, uvVarying) * vec4(color,1) * agk_ObjColor;
}
Vertex shader
// vertex shader
attribute vec3 position;
attribute vec3 normal;
attribute vec2 uv;
varying vec2 uvVarying;
varying vec3 normalVarying;
varying vec3 posVarying;
uniform vec4 uvBounds0;
uniform mat4 agk_World;
uniform mat4 agk_ViewProj;
uniform mat3 agk_WorldNormal;
void main()
{
vec4 pos = agk_World * vec4(position,1);
gl_Position = agk_ViewProj * pos;
vec3 norm = agk_WorldNormal * normal;
posVarying = pos.xyz;
normalVarying = norm;
uvVarying = uv * uvBounds0.xy + uvBounds0.zw;
}
The problem is I get planes behind other planes showing through like this: