summaryrefslogtreecommitdiff
path: root/terrain_fragment.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'terrain_fragment.glsl')
-rw-r--r--terrain_fragment.glsl43
1 files changed, 43 insertions, 0 deletions
diff --git a/terrain_fragment.glsl b/terrain_fragment.glsl
new file mode 100644
index 0000000..9c354c5
--- /dev/null
+++ b/terrain_fragment.glsl
@@ -0,0 +1,43 @@
+varying vec3 normal, light_pos, V, N;
+varying vec4 diffuse, ambient;
+
+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;
+}
+
+/* vim: set syn=glsl: */