 }
 
 void main() {
-	vec2 uv = gl_FragCoord / u_resolution.xy;
+	vec2 uv = gl_FragCoord.xy / u_resolution.xy;
 
-	vec2 ndc = 2*uv-1;
+	vec2 ndc = 2.*uv-1.;
 	ndc.x *= u_resolution.x/u_resolution.y;
 	vec3 ro = u_view_to_world[3].xyz;
-	vec3 rd = mat3(u_view_to_world)*normalize(vec3(ndc,-1.3));
+	vec3 rd = (u_view_to_world*vec4(normalize(vec3(ndc,-1.3)),0.)).xyz;
 
 	vec3 col;
 
-	float t = 0, d = 0;
+	float t = 0., d = 0.;
 	for (int i = 0; i < 80; i++) {
 		d = sdScene(ro + t * rd);
 		if (d<1e-4) break;
-		if (t>10) break;
+		if (t>10.) break;
 		t += 0.7 * d;
 	}
 	if (t > 9.999) discard;

	vec3 p = ro + t * rd;
	vec3 n = sceneNormal(p);

	vec3 diffuse = 0.5 + 0.5*dot(-LIGHT_DIR, n);

	col += diffuse;

	gl_FragColor = vec4(pow(col, vec3(1.0/2.2)), 1.0);
}

}

float sdScene(vec3 p) {
	float t = mod(.5*u_time,1.);
	t = abs(2.*t-1.);
	t = 2.*t-t*t;

	p.z += 2.;
	pR(p.xz, u_time);

	p.xy += .5+.1*t;
	float t0 = max(max(max(abs(p.z)-0.04, -p.y), -p.x), p.x+p.y-1.);
	p.xy -= .2*t;
	p = vec3(-p.x+1., -p.y+1., p.z);
	float t1 = max(max(max(abs(p.z)-0.04, -p.y), -p.x), p.x+p.y-1.);
	return min(t0, t1);
}

