1 uniform sampler2D uTexGarbage;
2 uniform sampler2D uTexMain;
6 uniform vec4 uPlayerPos; /* w: distance to uSpawnPos */
7 uniform vec4 uSpawnPos; /* w: inverse distance to uPlayerPos */
8 uniform bool uAlphatest;
10 #include "common_scene.glsl"
11 #include "motion_vectors_fs.glsl"
13 vec2 smin( float a, float b, float k ){
14 float h = max( k-abs(a-b), 0.0 )/k;
16 float s = m*k*(1.0/2.0);
21 return vec2(b-s,1.0-m);
25 vec2 ssuv = gl_FragCoord.xy;
26 vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );
27 float dither = fract( vDither.g / 71.0 ) - 0.5;
29 if( (aWorldCo.y*0.1 + dither) > ((uPlayerPos.y+40.0)*0.1) )
32 compute_motion_vectors();
34 vec3 vfrag = vec3(0.5,0.5,0.5);
35 vec3 qnorm = aNorm.xyz;
38 vec4 vSample = texture( uTexMain, aUv );
43 if( !gl_FrontFacing ){
48 vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );
51 float d0 = distance( aWorldCo, uPlayerPos.xyz )*2.0;
52 float d1 = distance( aWorldCo, uSpawnPos.xyz );
54 vec2 dm = smin( d0, d1, 10.0 );
55 float dd = fract(dm.x*0.2-g_realtime*0.5) *
56 max(0.0,1.0-dm.x*0.04) *
58 vec3 emit = mix(vec3(1.0,0.0,0.0),vec3(0.0,1.0,0.0),dm.y)*dd;
61 vec3 v0 = (uSpawnPos.xyz-uPlayerPos.xyz)*uSpawnPos.w;
62 float t = clamp( dot(aWorldCo-uPlayerPos.xyz,v0), 0.0, uPlayerPos.w );
63 vec3 p0 = uPlayerPos.xyz + v0*t;
64 float d3 = distance(p0,aWorldCo);
65 emit += vec3(fract(t*0.2-g_realtime+d3*0.2)*max(0.0,1.0-d3*0.2));
67 oColour = vec4( vfrag+emit, 1.0 );