precision mediump float; varying vec2 vTextureCoord; varying vec3 vTransformedNormal; varying vec4 vPosition; varying float colorBlue; uniform bool uUseLighting; uniform bool uUseTextures; uniform vec3 uAmbientColor; uniform vec3 uPointLightingLocation; uniform vec3 uPointLightingColor; uniform sampler2D uSampler; void main(void) { vec3 lightWeighting; vec4 blue = vec4(0.2, 0.2, 1.0, 1.0); if (!uUseLighting) { lightWeighting = vec3(1.0, 1.0, 1.0); } else { vec3 lightDirection = normalize(uPointLightingLocation - vPosition.xyz); float directionalLightWeighting = abs(dot(normalize(vTransformedNormal), lightDirection)); lightWeighting = uAmbientColor + uPointLightingColor * directionalLightWeighting; } vec4 fragmentColor; if (uUseTextures) { fragmentColor = texture2D(uSampler, vec2(vTextureCoord.s, vTextureCoord.t)); } else { fragmentColor = vec4(1.0, 1.0, 1.0, 1.0); } if (colorBlue < 0.0) gl_FragColor = vec4(fragmentColor.rgb * lightWeighting * blue.rgb, fragmentColor.a); else gl_FragColor = vec4(fragmentColor.rgb * lightWeighting, fragmentColor.a); }