Add reflective material

This commit is contained in:
Camden Dixie O'Brien
2025-09-21 19:00:34 +01:00
parent d7667fa266
commit c0d7f106ee
3 changed files with 31 additions and 0 deletions

View File

@@ -10,6 +10,12 @@
.params = { .lambertian = { .albedo = { r, g, b } } }, \
}
#define REFLECTIVE(r, g, b) \
{ \
.scatter = scatter_reflective, \
.params = { .reflective = { .tint = { r, g, b } } }, \
}
typedef struct {
vec3_t point, normal;
double t;
@@ -20,8 +26,13 @@ typedef struct {
vec3_t albedo;
} lambertian_params_t;
typedef struct {
vec3_t tint;
} reflective_params_t;
typedef union {
lambertian_params_t lambertian;
reflective_params_t reflective;
} material_params_t;
typedef bool scatter_fn_t(
@@ -36,5 +47,8 @@ typedef struct {
bool scatter_lambertian(
material_params_t params, hit_t hit, rng_t *rng, ray_t *ray,
vec3_t *atten_out);
bool scatter_reflective(
material_params_t params, hit_t hit, rng_t *rng, ray_t *ray,
vec3_t *atten_out);
#endif