• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1uniform sampler2D sTexture;
2uniform sampler2D sNormalMap;
3uniform bool bUseDot3;
4
5varying mediump vec2 TexCoord;
6varying mediump vec3 Light;
7
8void main()
9{
10	if(bUseDot3)
11	{
12		/*
13			Note:
14			In the normal map red = y, green = x, blue = z which is why when we get the normal
15			from the texture we use the swizzle .grb so the colours are mapped to the correct
16			co-ordinate variable.
17		*/
18
19		mediump vec3 fNormal = texture2D(sNormalMap, TexCoord).grb;
20		mediump float fNDotL = dot((fNormal - 0.5) * 2.0, Light);
21
22		gl_FragColor = texture2D(sTexture, TexCoord) * fNDotL;
23    }
24    else
25		gl_FragColor = texture2D(sTexture, TexCoord) * Light.x;
26}
27