checkin
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / character.fs
index d3c2bea75cc0b55ad80857069f45e4ac7094b387..cf62679587bb9ee47ab2c42c25de9f9176c0b18a 100644 (file)
@@ -2,6 +2,7 @@ out vec4 FragColor;
 
 uniform sampler2D uTexMain;
 uniform vec4 uColour;
+uniform vec3 uCamera;
 
 in vec4 aColour;
 in vec2 aUv;
@@ -9,8 +10,21 @@ in vec3 aNorm;
 in vec3 aCo;
 in float aOpacity;
 
+#include "common_world.glsl"
+
 void main()
 {
-   vec3 diffuse = texture( uTexMain, aUv ).rgb;
-   FragColor = vec4(pow(diffuse,vec3(1.0)),aOpacity);
+   vec3 vfrag = texture( uTexMain, aUv ).rgb;
+
+   // Lighting
+   vec3 halfview = uCamera - aCo;
+   float fdist = length( halfview );
+   halfview /= fdist;
+
+   //vfrag = do_light_diffuse( vfrag, aNorm );
+   vfrag = do_light_spec( vfrag, aNorm, halfview, 0.1 );
+   vfrag = do_light_shadowing( vfrag );
+   //vfrag = apply_fog( vfrag, fdist );
+
+   FragColor = vec4(vfrag,aOpacity);
 }