Add reflective material

This commit is contained in:
2025-09-23 15:36:08 +01:00
parent ce45c57662
commit 187876c3f2
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;
}