From 87c28badb511549fc211324a47e18cd7f2b0e0d0 Mon Sep 17 00:00:00 2001 From: rodri Date: Mon, 30 Sep 2024 13:51:46 +0000 Subject: vis: add a specular raster view. --- shaders.inc | 8 ++++++++ vis.c | 6 ++++++ 2 files changed, 14 insertions(+) diff --git a/shaders.inc b/shaders.inc index 0e0d0fe..8b6f670 100644 --- a/shaders.inc +++ b/shaders.inc @@ -162,6 +162,10 @@ phongshader(Shaderparams *sp) c = addpt3(ambient, addpt3(diffuse, specular)); c.a = m.diffuse.a; + + specular.a = 1; + sp->toraster(sp, "specular", &specular); + return c; } @@ -237,6 +241,10 @@ blinnshader(Shaderparams *sp) c = addpt3(ambient, addpt3(diffuse, specular)); c.a = m.diffuse.a; + + specular.a = 1; + sp->toraster(sp, "specular", &specular); + return c; } diff --git a/vis.c b/vis.c index 7a61602..71384a7 100644 --- a/vis.c +++ b/vis.c @@ -285,6 +285,7 @@ mmb(void) TSBILINEAR, SP1, SHOWNORMALS, + SHOWSPECULAR, SHOWZBUFFER, SP2, SETCLRCOL, @@ -304,6 +305,7 @@ mmb(void) [TSBILINEAR] "use bilinear sampler", "", [SHOWNORMALS] "show normals", + [SHOWSPECULAR] "show specular", [SHOWZBUFFER] "show z-buffer", "", [SETCLRCOL] "set clear color", @@ -344,6 +346,9 @@ mmb(void) case SHOWNORMALS: curraster = curraster && strcmp(curraster, "normals") == 0? nil: "normals"; break; + case SHOWSPECULAR: + curraster = curraster && strcmp(curraster, "specular") == 0? nil: "specular"; + break; case SHOWZBUFFER: curraster = curraster && strcmp(curraster, "z-buffer") == 0? nil: "z-buffer"; break; @@ -708,6 +713,7 @@ fprint(2, "screen %R\n", screenb->r); v = mkviewport(fbw == 0 || fbh == 0? screenb->r: Rect(0,0,fbw,fbh)); v->setscale(v, scale, scale); v->createraster(v, "normals", COLOR32); + v->createraster(v, "specular", COLOR32); v->p.x = (Dx(screenb->r) - v->getwidth(v))/2; v->p.y = (Dy(screenb->r) - v->getheight(v))/2; if(scale == 2) -- cgit v1.2.3