diff options
author | rodri <rgl@antares-labs.eu> | 2024-05-17 14:47:12 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2024-05-17 14:47:12 +0000 |
commit | 6e461add61d35d23f733cffb5064a286419b79b0 (patch) | |
tree | a6fc066813b67c0d28d2c1fb6a25835ff55d1602 | |
parent | 086d2bb276e55f81bd13d03c15d9325db4d2bd4f (diff) | |
download | libgraphics-6e461add61d35d23f733cffb5064a286419b79b0.tar.gz libgraphics-6e461add61d35d23f733cffb5064a286419b79b0.tar.bz2 libgraphics-6e461add61d35d23f733cffb5064a286419b79b0.zip |
render: improve line raster (not fixed yet). also tag jobs with an id.
-rw-r--r-- | graphics.h | 3 | ||||
-rw-r--r-- | render.c | 13 |
2 files changed, 9 insertions, 7 deletions
@@ -195,6 +195,7 @@ struct Rendertime struct Renderjob { Ref; + uvlong id; Framebuf *fb; Scene *scene; Shadertab *shaders; @@ -248,7 +249,7 @@ struct Camera struct { double n, f; /* near and far clipping planes */ } clip; - Matrix3 proj; /* VCS to NDC xform */ + Matrix3 proj; /* VCS to clip space xform */ Projection projtype; struct { @@ -226,19 +226,16 @@ rasterize(Rastertask *task) e = 0; Δy = p1.y > p0.y? 1: -1; - /* TODO find out why sometimes lines go invisible depending on their location */ - for(p = p0; p.x <= p1.x; p.x++){ Δp = subpt(p, p0); dplen = hypot(dp.x, dp.y); perc = dplen == 0? 0: hypot(Δp.x, Δp.y)/dplen; - if(steep) swapi(&p.x, &p.y); - + /* TODO it seems depth testing messes with the output. find out why */ z = flerp(prim.v[0].p.z, prim.v[1].p.z, perc); depth = fclamp(z, 0, 1); if(depth <= params->fb->zb[p.x + p.y*Dx(params->fb->r)]) - break; + continue; params->fb->zb[p.x + p.y*Dx(params->fb->r)] = depth; /* interpolate z⁻¹ and get actual z */ @@ -249,6 +246,8 @@ rasterize(Rastertask *task) perc *= prim.v[0].p.w * z; lerpvertex(&fsp.v, &prim.v[0], &prim.v[1], perc); + if(steep) swapi(&p.x, &p.y); + fsp.p = p; c = params->fshader(&fsp); memfillcolor(params->frag, col2ul(c)); @@ -639,11 +638,12 @@ renderer(void *arg) Entity *ent; SUparams *params; Channel *paramsc; - uvlong time; + uvlong time, lastid; threadsetname("renderer"); jobc = arg; + lastid = 0; paramsc = chancreate(sizeof(SUparams*), 8); proccreate(entityproc, paramsc, mainstacksize); @@ -651,6 +651,7 @@ renderer(void *arg) while((job = recvp(jobc)) != nil){ time = nanosec(); job->times.R.t0 = time; + job->id = lastid++; sc = job->scene; if(sc->nents < 1){ nbsend(job->donec, nil); |