summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2023-12-18 10:59:30 +0000
committerrodri <rgl@antares-labs.eu>2023-12-18 10:59:30 +0000
commitd8aaf562ad18d9401ca839ecea1866707d614686 (patch)
tree8f20f766b99a81b3986f72d9a5c7b885fec760e0
parent3c74a293451cb8e2992332e2d275823c2a0cb01e (diff)
downloadtinyrend-d8aaf562ad18d9401ca839ecea1866707d614686.tar.gz
tinyrend-d8aaf562ad18d9401ca839ecea1866707d614686.tar.bz2
tinyrend-d8aaf562ad18d9401ca839ecea1866707d614686.zip
remove unnecessary matrix xforms from the vertex shaders.
-rw-r--r--main.c17
1 files changed, 5 insertions, 12 deletions
diff --git a/main.c b/main.c
index e4e5c8d..1c40cb5 100644
--- a/main.c
+++ b/main.c
@@ -420,19 +420,14 @@ vertshader(VSparams *sp)
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 @@ shade(Memimage *dst, Shader *s)
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 @@ threadmain(int argc, char *argv[])
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);