respawn UI
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / scene_override.fs
diff --git a/shaders/scene_override.fs b/shaders/scene_override.fs
new file mode 100644 (file)
index 0000000..a182654
--- /dev/null
@@ -0,0 +1,67 @@
+uniform sampler2D uTexGarbage;
+uniform sampler2D uTexMain;
+uniform vec3 uCamera;
+uniform vec4 uPlane;
+
+uniform vec4 uPlayerPos;
+uniform vec4 uSpawnPos;
+
+#include "common_scene.glsl"
+#include "motion_vectors_fs.glsl"
+
+vec2 smin( float a, float b, float k )
+{
+   float h = max( k-abs(a-b), 0.0 )/k;
+   float m = h*h*0.5;
+   float s = m*k*(1.0/2.0);
+
+   if( a < b )
+      return vec2(a-s,m);
+   else
+      return vec2(b-s,1.0-m);
+}
+
+void main()
+{
+   vec2 ssuv = gl_FragCoord.xy;
+   vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );
+   float dither = fract( vDither.g / 71.0 ) - 0.5;
+
+   if( (aWorldCo.y*0.1 + dither) > ((uPlayerPos.y+40.0)*0.1) )
+      discard;
+
+   compute_motion_vectors();
+
+   vec3 vfrag = vec3(0.5,0.5,0.5);
+   vec3 qnorm = aNorm.xyz;
+
+   if( !gl_FrontFacing ){
+      qnorm *= -1.0;
+   }
+
+   vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );
+
+   float d0 = distance( aWorldCo, uPlayerPos.xyz )*2.0;
+   float d1 = distance( aWorldCo, uSpawnPos.xyz );
+
+   vec2 dm = smin( d0, d1, 10.0 );
+   float dd = fract(dm.x*0.2-g_realtime*0.5)*max(0.0,1.0-dm.x*0.04)*max(0.0,qnorm.y);
+
+   vec3 emit = mix(vec3(1.0,0.0,0.0),vec3(0.0,1.0,0.0),dm.y)*dd;
+
+
+
+
+   vec3 v0 = normalize(uSpawnPos.xyz-uPlayerPos.xyz);
+   float t = min(max(dot(aWorldCo-uPlayerPos.xyz,v0),0.0),
+   distance(uSpawnPos.xyz,uPlayerPos.xyz));
+
+   vec3 p0 = uPlayerPos.xyz + v0*t;
+   float d3 = distance(p0,aWorldCo);
+
+   float lp = fract(t*0.2-g_realtime+d3*0.2)*max(0.0,1.0-d3*0.2);
+
+   emit += vec3(lp);
+
+   oColour = vec4( vfrag+emit, 1.0 );
+}