f
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / character.fs
index d3c2bea75cc0b55ad80857069f45e4ac7094b387..2b13d764be0f2a048355d31b9bebd2287b60e4db 100644 (file)
@@ -2,15 +2,30 @@ out vec4 FragColor;
 
 uniform sampler2D uTexMain;
 uniform vec4 uColour;
+uniform vec3 uCamera;
 
 in vec4 aColour;
 in vec2 aUv;
 in vec3 aNorm;
 in vec3 aCo;
+in vec3 aWorldCo;
 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 - aWorldCo;
+   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);
 }