-
-
Notifications
You must be signed in to change notification settings - Fork 247
/
Copy pathao.h
75 lines (58 loc) · 1.23 KB
/
ao.h
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <assert.h>
#include <math.h>
#define WIDTH 256
#define HEIGHT 256
#define NSUBSAMPLES 2
#define NAO_SAMPLES 8
typedef struct _vec
{
double x;
double y;
double z;
} vec;
typedef struct _Isect
{
double t;
vec p;
vec n;
int hit;
} Isect;
typedef struct _Sphere
{
vec center;
double radius;
} Sphere;
typedef struct _Plane
{
vec p;
vec n;
} Plane;
typedef struct _Ray
{
vec org;
vec dir;
} Ray;
extern Sphere spheres[3];
extern Plane plane;
// ao_helpers.c
double vdot(vec v0, vec v1);
void vcross(vec *c, vec v0, vec v1);
void vnormalize(vec *c);
unsigned char clamp(double f);
void saveppm(const char *fname, int w, int h, unsigned char *img);
// ao_intersect.c
void ray_sphere_intersect(Isect *isect, const Ray *ray, const Sphere *sphere);
void ray_plane_intersect(Isect *isect, const Ray *ray, const Plane *plane);
// ao_orthoBasis.c
void orthoBasis(vec *basis, vec n);
// ao_occlusion.c
void ambient_occlusion(vec *col, const Isect *isect);
// ao_render.c
void render(unsigned char *img, int w, int h, int nsubsamples);
// ao_init.c
void init_scene();
// ao.c
//int ao_bench();