summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorrodri <rgl@antares-labs.eu>2024-05-04 09:03:20 +0000
committerrodri <rgl@antares-labs.eu>2024-05-04 09:03:20 +0000
commit967ea9815da257e52f38af756ebd93916eaa64cd (patch)
tree9123148da7ce77f17a700f1ef1e450c4234777b0
parentdf92f606034a287ef2cbd3ca3d5ac7a2622ddb9e (diff)
downloadrenderfs-front.tar.gz
renderfs-front.tar.bz2
renderfs-front.zip
adapt to libgraphics and get rid of stage times reporting.HEADfront
-rw-r--r--fs.c29
1 files changed, 10 insertions, 19 deletions
diff --git a/fs.c b/fs.c
index 32828f6..a8562b9 100644
--- a/fs.c
+++ b/fs.c
@@ -96,12 +96,8 @@ vshader(VSparams *sp)
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 @@ fshader(FSparams *sp)
{
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 @@ fsread(Req *r)
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 @@ fsread(Req *r)
!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 @@ fswrite(Req *r)
{
Client *c;
Model *model;
+ OBJ *obj;
Entity *ent;
Framebuf *fb;
Cmdbuf *cb;
@@ -604,11 +594,12 @@ nocmd:
/* 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: