• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#ifdef GL_ES
2precision lowp float;
3#endif
4
5uniform sampler2D u_sampler;
6uniform vec3 u_projectorPos;
7
8varying vec3 v_color;
9varying vec4 v_texcoords;
10varying vec3 v_normal;
11varying vec3 v_position;
12
13void main() {
14	// phong
15	vec3 lightDir = normalize(u_projectorPos - v_position);
16	vec3 normal = normalize(v_normal);
17	float dotProduct = dot(normal, lightDir);
18
19	dotProduct = max(dotProduct, 0.0);
20
21	vec3 texcoords = (v_texcoords.xyz / v_texcoords.w + 1.0) * 0.5;
22	vec4 color;
23	float factor = ceil(sign(texcoords.z));
24	color = texture2D(u_sampler, texcoords.st) * factor * vec4(v_color, 1.0);
25	gl_FragColor = color * dotProduct;
26}