summaryrefslogtreecommitdiff
path: root/test/raytracer/light.h
blob: 9a1d3e2aaf7bf354518bb596b1c7c257b0b73603 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
struct light {
  enum { Directional, Pointlight, Spot } kind;
  union {
    struct {
      struct point dir;
      struct point col;
    } directional;
    struct {
      struct point orig;
      struct point col;
    } point;
    struct {
      struct point orig;
      struct point at;
      struct point col;
      flt cutoff, exponent;
      struct vector unit;
    } spot;
  } u;
};

struct light * dirlight(struct point * dir, struct point * c);
struct light * pointlight(struct point * orig, struct point * c);
struct light * spotlight(struct point * pos, struct point * at,
                         struct point * c, flt a, flt cutoff);

void color_from_lights(struct object * obj,
                       struct point * p,
                       struct vector * v,
                       struct vector * n,
                       flt kd, flt ks, flt phong,
                       struct light ** lights,
                       /*out*/ struct point * il);