layout (location=0) in vec4 a_co; layout (location=1) in vec4 a_colour; #include "motion_vectors_vs.glsl" uniform mat4x3 uMdl; uniform mat3 uNormMtx; uniform mat4 uPv; uniform mat4 uPvmPrev; uniform vec4 uAnim; out vec4 aColour; out vec3 aWorldCo; out vec3 aCo; vec2 rand_hash22( vec2 p ) { vec3 p3 = fract(vec3(p.xyx) * 213.8976123); p3 += dot(p3, p3.yzx+19.19); return fract(vec2((p3.x + p3.y)*p3.z, (p3.x+p3.z)*p3.y)); } vec3 gridify( vec3 p, float s, float t ) { vec3 co = p*s; vec2 r2 = rand_hash22(p.xz); vec3 grid = (vec3(floor(co.x),co.y,floor(co.z))+vec3(0.5,0.0,0.5)) * (1.0/s); float t1 = 1.0-t; t1 = 1.0-t1*t1; float t2 = t*t; return mix( p, grid, t1 ) + t2*vec3(0.0,r2.y*r2.y*0.2,0.0); } void main() { vec3 co = gridify( a_co.xyz, uAnim.x, uAnim.y ); vec3 world_pos0 = uMdl * vec4( co, 1.0 ); vec4 vproj0 = uPv * vec4( world_pos0, 1.0 ); vec4 vproj1 = uPvmPrev * vec4( co, 1.0 ); float scaler = smoothstep(0.6,0.58,length(co.xz)); vs_motion_out( vproj0, vproj1 ); gl_Position = vproj0; gl_PointSize = (9.0*scaler) / (gl_Position.z + 0.01); aWorldCo = world_pos0; aColour = a_colour*scaler*(1.0-uAnim.y*uAnim.y); aCo = co; }