diff options
author | rodri <rgl@antares-labs.eu> | 2024-08-29 19:27:26 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-08-29 19:27:26 +0000 |
commit | 799c2a25df4283ba46747864dc669c8905b540fc (patch) | |
tree | 1fba24ffa31f0681d66c166f32a5323df65b75f1 | |
parent | 3b06ad551d6706907b0d6cbf25807e1ef7e62ca9 (diff) | |
download | 3dee-799c2a25df4283ba46747864dc669c8905b540fc.tar.gz 3dee-799c2a25df4283ba46747864dc669c8905b540fc.tar.bz2 3dee-799c2a25df4283ba46747864dc669c8905b540fc.zip |
use the new raster interface.
-rw-r--r-- | med.c | 6 | ||||
-rw-r--r-- | procgen.c | 12 | ||||
-rw-r--r-- | solar.c | 2 | ||||
-rw-r--r-- | vis.c | 26 |
4 files changed, 29 insertions, 17 deletions
@@ -100,7 +100,7 @@ RFrame3 ONF3 = { /* default orthonormal rframe */ 0,1,0,0, 0,0,1,0 }; -LightSource light; /* global point light */ +LightSource light; /* global point light */ static int doprof; static int showhud; @@ -515,8 +515,8 @@ renderproc(void *) Δt = nsec() - t0; if(Δt > HZ2MS(60)*1000000ULL){ lockdisplay(display); - cam->view->draw(cam->view, screenb); - compass.cam->view->draw(compass.cam->view, screenb); + cam->view->draw(cam->view, screenb, nil); + compass.cam->view->draw(compass.cam->view, screenb, nil); unlockdisplay(display); nbsend(drawc, nil); t0 += Δt; @@ -100,7 +100,7 @@ tree(double x, double h) static Point3 vs(VSparams *sp) { - return vcs2clip(sp->su->camera, sp->v->p); + return sp->v->p; } static Color @@ -175,18 +175,18 @@ threadmain(int argc, char *argv[]) placecamera(cam, scn, Pt3(0,0,0,1), Vec3(0,0,-1), Vec3(0,1,0)); quad[0].type = quad[1].type = PTriangle; - quad[0].v[0].p = viewport2vcs(cam, Pt3(out->r.min.x, out->r.max.y, 1, 1)); - quad[0].v[1].p = viewport2vcs(cam, Pt3(out->r.max.x, out->r.min.y, 1, 1)); - quad[0].v[2].p = viewport2vcs(cam, Pt3(out->r.min.x, out->r.min.y, 1, 1)); + quad[0].v[0].p = vcs2clip(cam, viewport2vcs(cam, Pt3(out->r.min.x, out->r.max.y, 1, 1))); + quad[0].v[1].p = vcs2clip(cam, viewport2vcs(cam, Pt3(out->r.max.x, out->r.min.y, 1, 1))); + quad[0].v[2].p = vcs2clip(cam, viewport2vcs(cam, Pt3(out->r.min.x, out->r.min.y, 1, 1))); quad[1].v[0].p = quad[0].v[0].p; - quad[1].v[1].p = viewport2vcs(cam, Pt3(out->r.max.x, out->r.max.y, 1, 1)); + quad[1].v[1].p = vcs2clip(cam, viewport2vcs(cam, Pt3(out->r.max.x, out->r.max.y, 1, 1))); quad[1].v[2].p = quad[0].v[1].p; mdl->addprim(mdl, quad[0]); mdl->addprim(mdl, quad[1]); scn->addent(scn, ent); do shootcamera(cam, &shaders); while(skip--); - cam->view->memdraw(cam->view, out); + cam->view->memdraw(cam->view, out, nil); writememimage(1, out); threadexitsall(nil); @@ -573,7 +573,7 @@ renderproc(void *) Δt = nsec() - t0; if(Δt > HZ2MS(60)*1000000ULL){ lockdisplay(display); - camera->view->draw(camera->view, screenb); + camera->view->draw(camera->view, screenb, nil); unlockdisplay(display); nbsend(drawc, nil); t0 += Δt; @@ -166,6 +166,8 @@ gouraudshader(FSparams *sp) else tc = Pt3(1,1,1,1); + sp->toraster(sp, "normals", &sp->v.n); + return modulapt3(sp->v.c, tc); } @@ -264,6 +266,8 @@ phongshader(FSparams *sp) specular = mulpt3(lightc, spec*Ks); specular = modulapt3(specular, m.specular); + sp->toraster(sp, "normals", &sp->v.n); + c = addpt3(ambient, addpt3(diffuse, specular)); c.a = m.diffuse.a; return c; @@ -336,6 +340,8 @@ blinnshader(FSparams *sp) specular = mulpt3(lightc, spec*Ks); specular = modulapt3(specular, m.specular); + sp->toraster(sp, "normals", &sp->v.n); + c = addpt3(ambient, addpt3(diffuse, specular)); c.a = m.diffuse.a; return c; @@ -371,6 +377,8 @@ toonshader(FSparams *sp) intens > 0.30? 0.45: intens > 0.15? 0.30: 0.15; + sp->toraster(sp, "normals", &sp->v.n); + return Pt3(intens, 0.6*intens, 0, 1); } @@ -394,6 +402,8 @@ identshader(FSparams *sp) else tc = Pt3(1,1,1,1); + sp->toraster(sp, "normals", &sp->v.n); + return modulapt3(sp->v.c, tc); } @@ -601,10 +611,7 @@ renderproc(void *) Δt = nsec() - t0; if(Δt > HZ2MS(60)*1000000ULL){ lockdisplay(display); - if(shownormals) - maincam->view->fbctl->drawnormals(maincam->view->fbctl, screenb); - else - maincam->view->draw(maincam->view, screenb); + maincam->view->draw(maincam->view, screenb, shownormals? "normals": nil); unlockdisplay(display); nbsend(drawc, nil); t0 += Δt; @@ -659,6 +666,7 @@ lmb(void) } }else{ /* DBG only */ Framebuf *fb; + Raster *cr, *zr, *nr; Point2 p₂; Point p; Color c, n; @@ -675,9 +683,12 @@ lmb(void) return; qlock(maincam->view->fbctl); fb = maincam->view->getfb(maincam->view); - c = ul2col(fb->cb[p.y*Dx(fb->r) + p.x]); - n = ul2col(fb->nb[p.y*Dx(fb->r) + p.x]); - z = fb->zb[p.y*Dx(fb->r) + p.x]; + cr = fb->rasters; + zr = cr->next; + nr = maincam->view->fetchraster(maincam->view, "normals"); + c = ul2col(cr->data[p.y*Dx(fb->r) + p.x]); + n = nr != nil? ul2col(nr->data[p.y*Dx(fb->r) + p.x]): Vec3(0,0,0); + z = *(float*)&zr->data[p.y*Dx(fb->r) + p.x]; // abuf = &fb->abuf; // if(abuf->stk != nil){ // astk = &abuf->stk[p.y*Dx(fb->r) + p.x]; @@ -1112,6 +1123,7 @@ fprint(2, "screen %R\n", screenb->r); sysfatal("Cam: %r"); placecamera(cams[i], scene, camcfgs[i].p, camcfgs[i].lookat, camcfgs[i].up); cams[i]->view->setscale(cams[i]->view, scale, scale); + cams[i]->view->createraster(cams[i]->view, "normals", COLOR32); if(scale == 2) cams[i]->view->setscalefilter(cams[i]->view, UFScale2x); |