void gouraud_shade(Hpoly *c, Hpoly *p, Hpoly *n, Vector3 v, RContext *rc, Material *m) { int i; for (i = 0; i < p->n; i++) c->v[i] = v4_v3conv((*m->luminance)(rc_set(rc, v3_unit(v3_sub(v, v3_v4conv(p->v[i]))), v3_v4conv(p->v[i]), v3_v4conv(n->v[i]), m))); }
void phong_shadepaint(Vector4 p, int n, int lv, Real lt, int rv, Real rt, Real st, void *data) { PhongData *d = data; Vector3 pv = v3_v4conv(seg_bilerp(d->pnts, n, st, lv, lt, rv, rt)); Vector3 pn = v3_unit(v3_v4conv(seg_bilerp(d->norms, n, st, lv, lt, rv, rt))); Color c = point_shade(pv, pn, d->v, d->rc, d->rc->m); img_putc(d->rc->img, p.x, p.y, col_dpymap(c)); }
Ray ray_view(int u, int v) { Vector4 w = v4_m4mult(v4_make(u, v,s->view->sc.ur.z, 1), mdpy); return ray_make(v3_v4conv(v4_m4mult(v4_make(0, 0, 1, 0), mdpy)), v3_make(w.x, w.y, w.z)); }
void gouraud_paint(Vector4 p, int n, int lv, Real lt, int rv, Real rt, Real st,void *data) { GouraudData *d = data; Vector3 c = v3_v4conv(seg_bilerp(d->cols, n, st, lv, lt, rv, rt)); img_putc(d->img, p.x, p.y, col_dpymap(c)); }