• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#ifdef GL_ES
2precision mediump float;
3#endif
4
5#ifdef texturedFlag
6uniform sampler2D u_diffuseTexture;
7uniform sampler2D u_specularTexture;
8uniform sampler2D u_normalTexture;
9#endif
10
11in vec3 v_normal;
12in vec3 v_position;
13
14#ifdef texturedFlag
15in vec3 v_tangent;
16in vec3 v_binormal;
17in vec2 v_texCoords;
18#else
19in vec4 v_color;
20#endif
21
22layout(location = 0) out vec4 diffuseOut;
23layout(location = 1) out vec3 normalOut;
24layout(location = 2) out vec3 positionOut;
25
26void main() {
27    #ifdef texturedFlag
28        vec4 diffuse = texture(u_diffuseTexture, v_texCoords);
29        vec4 specular = texture(u_specularTexture, v_texCoords);
30        vec3 normal = normalize(2.0 * texture(u_normalTexture, v_texCoords).xyz - 1.0);
31    #else
32        vec4 diffuse = v_color;
33        vec4 specular = vec4(1.0);
34    #endif
35
36    diffuseOut.rgb = diffuse.rgb;
37    diffuseOut.a = specular.r;
38
39    #ifdef texturedFlag
40        vec3 finnormal = normalize((v_tangent * normal.x) + (v_binormal * normal.y) + (v_normal * normal.z));
41        normalOut = finnormal;
42    #else
43        normalOut = v_normal;
44    #endif
45
46    positionOut = v_position;
47}
48