-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmaterial.h
75 lines (59 loc) · 1.93 KB
/
material.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
/*
* Filename : material.h
* Last Modified: 19 June 2020
* Owner : Group 20
*
* Description:
* to be updated ...
*
* Other:
* This file is formatted with a tab indent size of 4 and a character
* restriction of 80/line.
*/
#ifndef MATERIAL_H
#define MATERIAL_H
/*------------------------------Standard Headers------------------------------*/
#include <stdio.h>
#include <stdbool.h>
#include <stdlib.h>
/*----------------------------User-defined Headers----------------------------*/
#include "ray.h"
#include "vec.h"
/*-----------------------------User-defined Types-----------------------------*/
typedef enum {
DIFFUSE,
METAL,
GLASS
} mat_type;
typedef struct {
vec abdo; /* The albedo of the material */
float fuzz; /* The 'fuzziness` of the material */
float rfix; /* The refractive index of the material */
mat_type type;
} material;
typedef struct {
float t; /* The ray parameter */
vec pos; /* The position where the ray hits the surface */
vec nor; /* The surface normal at the hit position */
material mat; /* The material of the surface */
} hit_rec;
/*---------------------------Function Declarations----------------------------*/
/* Add comment here */
void mat_set(material *m, vec abdo, float fuzz, float rfix, mat_type type);
/* Add comment here */
bool scatter_diffuse(material *m, hit_rec rec, vec *att, ray *r_out);
/* Add comment here */
bool scatter_metal(material *m, ray r_in, hit_rec rec, vec *att, ray *r_out);
/* Add comment here */
bool scatter_glass(material *m, ray r_in, hit_rec rec, vec *att, ray *r_out);
/* Add comment here */
bool scatter(material *m, ray r_in, hit_rec rec, vec *att, ray *r_out);
/* Add comment here */
vec reflect(vec v, vec n);
/* Add comment here */
bool refract(vec v, vec n, float nint, vec *ref);
/* Add comment here */
float schlick(float cos, float rfix);
/* Add comment here */
vec random_point();
#endif