Alex Sakhartchouk a7a211b8a6 Sample scene graph
Change-Id: I65b210b770121ac02c5857b48d2ec0d053133dd6
2011-12-08 11:39:14 -08:00

24 lines
705 B
GLSL

varying vec3 varWorldPos;
varying vec3 varWorldNormal;
varying vec2 varTex0;
void main() {
vec3 V = normalize(UNI_cameraPos.xyz - varWorldPos.xyz);
vec3 worldNorm = normalize(varWorldNormal);
vec3 light0Vec = V;
vec3 light0R = reflect(light0Vec, worldNorm);
float light0_Diffuse = clamp(dot(worldNorm, light0Vec), 0.0, 1.0);
float light0Spec = clamp(dot(-light0R, V), 0.001, 1.0);
float light0_Specular = pow(light0Spec, 15.0) * 0.5;
vec2 t0 = varTex0.xy;
lowp vec4 col = texture2D(UNI_Tex0, t0).rgba;
col.xyz = col.xyz * (textureCube(UNI_Tex1, worldNorm).rgb * 0.5 + vec3(light0_Diffuse));
col.xyz += light0_Specular * vec3(0.8, 0.8, 1.0);
gl_FragColor = col;
}