DonkeyKong64 grind crash
[carveJwlIkooP6JGAAIwe30JlM.git] / shaders / cloud.vs
1 layout (location=0) in vec4 a_co;
2 layout (location=1) in vec4 a_colour;
3
4 #include "motion_vectors_vs.glsl"
5
6 uniform mat4x3 uMdl;
7 uniform mat3 uNormMtx;
8 uniform mat4 uPv;
9 uniform mat4 uPvmPrev;
10 uniform vec4 uAnim;
11
12 out vec4 aColour;
13 out vec3 aWorldCo;
14 out vec3 aCo;
15
16 vec2 rand_hash22( vec2 p )
17 {
18 vec3 p3 = fract(vec3(p.xyx) * 213.8976123);
19 p3 += dot(p3, p3.yzx+19.19);
20 return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y));
21 }
22
23 vec3 gridify( vec3 p, float s, float t )
24 {
25 vec3 co = p*s;
26 vec2 r2 = rand_hash22(p.xz);
27 vec3 grid = (vec3(floor(co.x),co.y,floor(co.z))+vec3(0.5,0.0,0.5)) * (1.0/s);
28
29 float t1 = 1.0-t;
30 t1 = 1.0-t1*t1;
31 float t2 = t*t;
32
33 return mix( p, grid, t1 ) + t2*vec3(0.0,r2.y*r2.y*0.2,0.0);
34 }
35
36 void main()
37 {
38 vec3 co = gridify( a_co.xyz, uAnim.x, uAnim.y );
39
40 vec3 world_pos0 = uMdl * vec4( co, 1.0 );
41 vec4 vproj0 = uPv * vec4( world_pos0, 1.0 );
42 vec4 vproj1 = uPvmPrev * vec4( co, 1.0 );
43
44 float scaler = smoothstep(0.6,0.58,length(co.xz));
45
46 vs_motion_out( vproj0, vproj1 );
47
48 gl_Position = vproj0;
49 gl_PointSize = (9.0*scaler) / (gl_Position.z + 0.01);
50 aWorldCo = world_pos0;
51 aColour = a_colour*scaler*(1.0-uAnim.y*uAnim.y);
52 aCo = co;
53 }