diff options
author | rodri <rgl@antares-labs.eu> | 2024-09-13 13:16:06 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-09-13 13:16:06 +0000 |
commit | f89e4e8e5ddcbf7de6aa8310f11204e5e019f7cb (patch) | |
tree | 18f39bdec0a5c74bdf4b3ed6dff5d002765016b0 | |
parent | be27f4dff3e949b012d7fac9b872fc911123cf3a (diff) | |
download | libgraphics-f89e4e8e5ddcbf7de6aa8310f11204e5e019f7cb.tar.gz libgraphics-f89e4e8e5ddcbf7de6aa8310f11204e5e019f7cb.tar.bz2 libgraphics-f89e4e8e5ddcbf7de6aa8310f11204e5e019f7cb.zip |
render: discard non-colors.
-rw-r--r-- | render.c | 34 |
1 files changed, 19 insertions, 15 deletions
@@ -196,15 +196,16 @@ rasterize(Rastertask *task) p = Pt(prim->v[0].p.x, prim->v[0].p.y); z = fclamp(prim->v[0].p.z, 0, 1); - if(params->camera->enabledepth){ - if(z <= getdepth(zr, p)) - break; - putdepth(zr, p, z); - } + if(params->camera->enabledepth && z <= getdepth(zr, p)) + break; fsp.v = &prim->v[0]; fsp.p = p; c = params->fshader(&fsp); + if(c.a == 0) /* discard non-colors */ + break; + if(params->camera->enabledepth) + putdepth(zr, p, z); if(params->camera->enableAbuff) pushtoAbuf(params->fb, p, c, z); else @@ -245,11 +246,9 @@ rasterize(Rastertask *task) z = flerp(prim->v[0].p.z, prim->v[1].p.z, perc); /* TODO get rid of the bounds check and make sure the clipping doesn't overflow */ - if(params->camera->enabledepth){ - if(!ptinrect(p, params->fb->r) || z <= getdepth(zr, p)) - goto discard; - putdepth(zr, p, z); - } + if(params->camera->enabledepth && + !ptinrect(p, params->fb->r) || z <= getdepth(zr, p)) + goto discard; /* interpolate z⁻¹ and get actual z */ pcz = flerp(prim->v[0].p.w, prim->v[1].p.w, perc); @@ -261,6 +260,10 @@ rasterize(Rastertask *task) fsp.p = p; c = params->fshader(&fsp); + if(c.a == 0) /* discard non-colors */ + goto discard; + if(params->camera->enabledepth) + putdepth(zr, p, z); if(params->camera->enableAbuff) pushtoAbuf(params->fb, p, c, z); else @@ -288,11 +291,8 @@ discard: continue; z = fberp(prim->v[0].p.z, prim->v[1].p.z, prim->v[2].p.z, bc); - if(params->camera->enabledepth){ - if(z <= getdepth(zr, p)) - continue; - putdepth(zr, p, z); - } + if(params->camera->enabledepth && z <= getdepth(zr, p)) + continue; /* interpolate z⁻¹ and get actual z */ pcz = fberp(prim->v[0].p.w, prim->v[1].p.w, prim->v[2].p.w, bc); @@ -306,6 +306,10 @@ discard: fsp.p = p; c = params->fshader(&fsp); + if(c.a == 0) /* discard non-colors */ + continue; + if(params->camera->enabledepth) + putdepth(zr, p, z); if(params->camera->enableAbuff) pushtoAbuf(params->fb, p, c, z); else |