shithub: renderfs

Download patch

ref: 967ea9815da257e52f38af756ebd93916eaa64cd
parent: df92f606034a287ef2cbd3ca3d5ac7a2622ddb9e
author: rodri <[email protected]>
date: Sat May 4 05:03:20 EDT 2024

adapt to libgraphics and get rid of stage times reporting.

--- a/fs.c
+++ b/fs.c
@@ -96,12 +96,8 @@
 	lightdir = normvec3(subpt3(light.p, pos));
 	intens = fmax(0, dotvec3(sp->v->n, lightdir));
 	addvattr(sp->v, "intensity", VANumber, &intens);
-	if(sp->v->mtl != nil){
-		sp->v->c.r = sp->v->mtl->Kd.r;
-		sp->v->c.g = sp->v->mtl->Kd.g;
-		sp->v->c.b = sp->v->mtl->Kd.b;
-		sp->v->c.a = 1;
-	}
+	if(sp->v->mtl != nil)
+		sp->v->c = sp->v->mtl->diffuse;
 	return world2clip(c->cam, pos);
 }
 
@@ -110,14 +106,14 @@
 {
 	Color tc, c;
 
-	if(sp->v.mtl != nil && sp->v.mtl->map_Kd != nil && sp->v.uv.w != 0)
-		tc = texture(sp->v.mtl->map_Kd, sp->v.uv, neartexsampler);
+	if(sp->v.mtl != nil && sp->v.mtl->diffusemap != nil && sp->v.uv.w != 0)
+		tc = texture(sp->v.mtl->diffusemap, sp->v.uv, neartexsampler);
 	else if(sp->su->entity->mdl->tex != nil && sp->v.uv.w != 0)
 		tc = texture(sp->su->entity->mdl->tex, sp->v.uv, neartexsampler);
 	else
 		tc = Pt3(1,1,1,1);
 
-	c.a = fclamp(sp->v.c.a*tc.a, 0, 1);
+	c.a = 1;
 	c.b = fclamp(sp->v.c.b*tc.b, 0, 1);
 	c.g = fclamp(sp->v.c.g*tc.g, 0, 1);
 	c.r = fclamp(sp->v.c.r*tc.r, 0, 1);
@@ -397,7 +393,7 @@
 	char buf[1024], cbuf[30], *t;
 	uvlong path;
 	ulong off, cnt;
-	int n, i;
+	int n;
 
 	path = r->fid->qid.path;
 	off = r->ifcall.offset;
@@ -427,13 +423,6 @@
 			!c->cam->stats.avg? 0: 1e9/c->cam->stats.avg,
 			!c->cam->stats.min? 0: 1e9/c->cam->stats.min,
 			!c->cam->stats.v? 0: 1e9/c->cam->stats.v);
-		n += snprint(buf+n, sizeof(buf)-n, "times\n");
-		for(i = 0; i < c->cam->times.cur; i++)
-			n += snprint(buf+n, sizeof(buf)-n, "%d\tR\t[%llud %llud] (%.0f µs)\n\tE\t[%llud %llud] (%.0f µs)\n\tTn\t[%llud %llud] (%.0f µs)\n\tRn\t[%llud %llud] (%.0f µs)\n",
-				i, c->cam->times.R[i].t0, c->cam->times.R[i].t1, (c->cam->times.R[i].t1-c->cam->times.R[i].t0)/1e3,
-				c->cam->times.E[i].t0, c->cam->times.E[i].t1, (c->cam->times.E[i].t1-c->cam->times.E[i].t0)/1e3,
-				c->cam->times.Tn[i].t0, c->cam->times.Tn[i].t1, (c->cam->times.Tn[i].t1-c->cam->times.Tn[i].t0)/1e3,
-				c->cam->times.Rn[i].t0, c->cam->times.Rn[i].t1, (c->cam->times.Rn[i].t1-c->cam->times.Rn[i].t0)/1e3);
 		snprint(buf+n, sizeof(buf)-n, "frame #%llud\n", c->cam->stats.nframes);
 		readstr(r, buf);
 		respond(r, nil);
@@ -499,6 +488,7 @@
 {
 	Client *c;
 	Model *model;
+	OBJ *obj;
 	Entity *ent;
 	Framebuf *fb;
 	Cmdbuf *cb;
@@ -604,11 +594,12 @@
 
 		/* TODO load an actual scene (format tbd) */
 		model = newmodel();
-		if((model->obj = objparse(f[0])) == nil){
+		if((obj = objparse(f[0])) == nil){
 			delmodel(model);
 			goto noscene;
 		}
-		refreshmodel(model);
+		loadobjmodel(model, obj);
+		objfree(obj);
 		ent = newentity(model);
 		c->cam->s->addent(c->cam->s, ent);
 noscene: