diff options
Diffstat (limited to 'main.c')
-rw-r--r-- | main.c | 21 |
1 files changed, 19 insertions, 2 deletions
@@ -394,7 +394,7 @@ vertshader(VSparams *sp) } Memimage * -fragshader(FSparams *sp) +gouraudshader(FSparams *sp) { double intens; @@ -409,6 +409,23 @@ fragshader(FSparams *sp) return sp->frag; } +Memimage * +toonshader(FSparams *sp) +{ + double intens; + + intens = sp->su->var_intensity[0]*sp->bc.x; + intens += sp->su->var_intensity[1]*sp->bc.y; + intens += sp->su->var_intensity[2]*sp->bc.z; + intens = intens > 0.85? 1: intens > 0.60? 0.80: intens > 0.45? 0.60: intens > 0.30? 0.45: intens > 0.15? 0.30: 0; + sp->cbuf[1] = 0; + sp->cbuf[2] = 155*intens; + sp->cbuf[3] = 255*intens; + memfillcolor(sp->frag, *(ulong*)sp->cbuf); + + return sp->frag; +} + void rasterize(SUparams *params, Triangle3 st, Triangle2 tt, Memimage *frag) { @@ -746,7 +763,7 @@ render(void) uvlong t0, t1; t0 = nanosec(); - shade(fb, vertshader, fragshader); + shade(fb, vertshader, toonshader); t1 = nanosec(); fprint(2, "shader took %lludns\n", t1-t0); } |