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;
9 uniform vec4 uMapInfo; /* x: min, y: max, z: iso line amount */
11 #include "light_clearskies_stddef.glsl"
12 #include "common_scene.glsl"
13 #include "motion_vectors_fs.glsl"
15 vec2 smin( float a, float b, float k ){
16 float h = max( k-abs(a-b), 0.0 )/k;
18 float s = m*k*(1.0/2.0);
23 return vec2(b-s,1.0-m);
27 vec2 ssuv = gl_FragCoord.xy;
28 vec3 vDither = vec3( dot( vec2( 171.0, 231.0 ), ssuv) );
29 float dither = fract( vDither.g / 71.0 ) - 0.5;
31 float dcam = (-8.0+distance( aCo, uCamera ))/4.0;
32 float dy0 = aCo.y - uMapInfo.x;
33 float dy1 = uMapInfo.y - aCo.y;
35 if( min(min(dy0,dy1)*0.5, dcam) + dither < 0.51 )
38 compute_motion_vectors();
40 vec3 vfrag = vec3(0.898,0.811,0.716);
41 vec3 qnorm = aNorm.xyz;
43 qnorm = normalize(floor(aNorm.xyz*4.0)*0.25);
44 qnorm += vec3(0.001,0.0,0.0);
47 vec4 vSample = texture( uTexMain, aUv );
54 vfrag = scene_compute_lighting( vfrag, qnorm, aWorldCo );
57 float d0 = distance( aCo, uPlayerPos.xyz )*2.0;
58 float d1 = distance( aCo, uSpawnPos.xyz );
60 vec2 dm = smin( d0, d1, 10.0 );
61 float dd = fract(dm.x*0.2-g_realtime*0.5) *
62 max(0.0,1.0-dm.x*0.04) *
64 vec3 emit = mix(vec3(1.0,0.0,0.0),vec3(0.0,1.0,0.0),dm.y)*dd;
67 vec3 v0 = (uSpawnPos.xyz-uPlayerPos.xyz)*uSpawnPos.w;
68 float t = clamp( dot(aCo-uPlayerPos.xyz,v0), 0.0, uPlayerPos.w );
69 vec3 p0 = uPlayerPos.xyz + v0*t;
70 float d3 = distance(p0,aCo);
71 emit += vec3(fract(t*0.2-g_realtime+d3*0.2)*max(0.0,1.0-d3*0.2));
75 if( uMapInfo.z > 0.0 ){
76 float height = fract( aCo.y * 0.1 );
77 float lg = 2.0*length(vec2(dFdx(height), dFdy(height)));
78 vfrag *= 1.0f+(lg*0.2*uMapInfo.z);
81 oColour = vec4( vfrag, 1.0 );
82 //oColour = vec4( vfrag, 1.0 );