summaryrefslogtreecommitdiff
path: root/terrain_fragment.glsl
diff options
context:
space:
mode:
authorJon Bergli Heier <snakebite@jvnv.net>2011-04-02 15:52:24 +0200
committerJon Bergli Heier <snakebite@jvnv.net>2011-04-02 15:52:24 +0200
commitfe2df4b280ecd8417cc267b8fc05ec050054ec4c (patch)
tree92500ef700f14c6bd0ca0840c9c98d3b20e72415 /terrain_fragment.glsl
parente172cde8c082fa3e338b3eb11079b36952874936 (diff)
Finished terrain lighting.
Diffstat (limited to 'terrain_fragment.glsl')
-rw-r--r--terrain_fragment.glsl36
1 files changed, 2 insertions, 34 deletions
diff --git a/terrain_fragment.glsl b/terrain_fragment.glsl
index 9c354c5..774bfd3 100644
--- a/terrain_fragment.glsl
+++ b/terrain_fragment.glsl
@@ -1,43 +1,11 @@
-varying vec3 normal, light_pos, V, N;
-varying vec4 diffuse, ambient;
+varying vec3 normal, light_pos;
uniform sampler2D tex;
void main() {
- //gl_FragColor = gl_Color * diffuse_value;
- //vec4 color = ambient;
- //vec3 n = normalize(normal);
- /*vec3 n = normal;
- vec3 hv;
- float dotL = max(dot(n, vec3(0, 1, 0)), 0.0);
- color += diffuse * dotL;
- hv = normalize(halfvector);
- float dotHV = max(dot(n, hv), 0.0);*/
- //color += gl_FrontMaterial.specular * gl_LightSource[0].specular * pow(dotHV, gl_FrontMaterial.shininess);
-
vec3 n = normalize(normal);
-
- float NdotL = max(dot(light_pos, n), 0.0);
float diffuse = max(dot(n, light_pos), 0.0);
-
- gl_FragColor = vec4(n, 0.0);
-
- //gl_FragColor = texture2D(tex, gl_TexCoord[0].st) /* diffuse_value*/ * diffuse;
- //gl_FragColor = gl_Color * diffuse;
-
- //gl_FragColor = NdotL * diffuse + ambient;
-
- return;
-
- vec3 L = normalize(light_pos - V);
- vec3 E = normalize(-V);
- vec3 R = normalize(-reflect(L, N));
-
- vec4 Iamb = gl_FrontLightProduct[0].ambient;
- vec4 Idiff = gl_FrontLightProduct[0].diffuse * max(dot(N, L), 0.0);
- vec4 Ispec = gl_FrontLightProduct[0].specular * pow(max(dot(R, E), 0.0), 0.3 * gl_FrontMaterial.shininess);
-
- gl_FragColor = gl_FrontLightModelProduct.sceneColor + Iamb + Idiff + Ispec;
+ gl_FragColor = texture2D(tex, gl_TexCoord[0].st) * diffuse;
}
/* vim: set syn=glsl: */