Create material abstraction

This commit is contained in:
Camden Dixie O'Brien
2025-09-23 15:35:26 +01:00
parent 219219ce64
commit 7f1103a179
8 changed files with 84 additions and 26 deletions

12
src/material.c Normal file
View File

@@ -0,0 +1,12 @@
#include "material.h"
bool scatter_lambertian(
material_params_t params, hit_t hit, rng_t *rng, ray_t *ray,
vec3_t *atten_out)
{
const vec3_t dir = vec3_unit(vec3_add(hit.normal, rng_vec3(rng)));
ray->orig = hit.point;
ray->dir = vec3_len(dir) == 0 ? hit.normal : dir;
*atten_out = params.lambertian.albedo;
return true;
}