summaryrefslogtreecommitdiffstats
path: root/src/de/gamezock/metacraft/resources/shaders/default.frag
blob: c87f14fe634112204f8fcea6d9295325bbf17152 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
uniform sampler2D tex;

varying vec4 diffuse, ambient, globalAmbient;
varying vec3 normal, pos;


void main() {
  vec3 n, l;
  float NdotL;
  vec4 specularColor;
  float dist, distSq, att, specularFactor;
  
  n = normalize(normal);
  
  l = gl_LightSource[0].position.xyz - pos;
  
  distSq = dot(l, l);
  
  NdotL = dot(n, l);

  if (NdotL > 0.0) {
    dist = sqrt(distSq);
    
    att = 1.0 / (gl_LightSource[0].quadraticAttenuation * distSq);
    gl_FragColor = att * (diffuse * NdotL / dist + ambient + globalAmbient) /* * texture2D(tex, gl_TexCoord[0].st)*/;
  }
  else {
    gl_FragColor = vec4(0, 0, 0, 1);
  }
}