Add reflective material

This commit is contained in:
Camden Dixie O'Brien
2025-09-23 15:35:26 +01:00
parent 7f1103a179
commit 3b6bc953b5
3 changed files with 31 additions and 0 deletions

View File

@@ -10,3 +10,17 @@ bool scatter_lambertian(
*atten_out = params.lambertian.albedo;
return true;
}
bool scatter_reflective(
material_params_t params, hit_t hit, rng_t *rng, ray_t *ray,
vec3_t *atten_out)
{
(void)rng;
const vec3_t dn
= vec3_scale(hit.normal, -2 * vec3_dot(hit.normal, ray->dir));
ray->orig = hit.point;
ray->dir = vec3_unit(vec3_add(ray->dir, dn));
*atten_out = params.reflective.tint;
return true;
}