shithub: tinyrend

Download patch

ref: d8aaf562ad18d9401ca839ecea1866707d614686
parent: 3c74a293451cb8e2992332e2d275823c2a0cb01e
author: rodri <rgl@antares-labs.eu>
date: Mon Dec 18 05:59:30 EST 2023

remove unnecessary matrix xforms from the vertex shaders.

--- a/main.c
+++ b/main.c
@@ -420,19 +420,14 @@
 		0, 1, 0, 0,
 		sin(θ+fmod(ω*sp->su->uni_time/1e9, 2*PI)), 0, cos(θ+fmod(ω*sp->su->uni_time/1e9, 2*PI)), 0,
 		0, 0, 0, 1,
-	}, M, T, V;
+	}, M, V;
 
 	identity3(M);
-	identity3(T);
 	identity3(V);
 	mulm3(M, rota);
 	mulm3(M, yrot);
-	mulm3(V, M);
-	mulm3(T, proj);
-	mulm3(T, V);
-	identity3(V);
 	mulm3(V, view);
-	mulm3(V, T);
+	mulm3(V, M);
 
 	*sp->n = xform3(*sp->n, M);
 	sp->su->var_intensity[sp->idx] = fmax(0, dotvec3(*sp->n, light));
@@ -681,16 +676,13 @@
 Point3
 ivshader(VSparams *sp)
 {
-	Matrix3 M, D, V;
+	Matrix3 M, V;
 
 	identity3(M);
-	identity3(D);
 	identity3(V);
 	mulm3(M, rota);
-	mulm3(D, proj);
 	mulm3(V, view);
-	mulm3(D, M);
-	mulm3(V, D);
+	mulm3(V, M);
 
 	return xform3(*sp->p, V);
 }
@@ -1058,6 +1050,7 @@
 	projection(-1.0/vec3len(subpt3(camera, center)));
 	identity3(rota);
 	lookat(camera, center, up);
+	mulm3(view, proj);
 	light = normvec3(subpt3(light, center));
 
 	drawc = chancreate(sizeof(void*), 1);