Use true Lambertian diffusion
This commit is contained in:
parent
204180b1a7
commit
e397ee9ad9
2
main.c
2
main.c
@ -18,7 +18,7 @@ Color ray_color(Ray r, Hittable world, int depth) {
|
|||||||
HitRecord record;
|
HitRecord record;
|
||||||
if (hittable_hit(&world, r, 0.001, DBL_MAX, &record)) {
|
if (hittable_hit(&world, r, 0.001, DBL_MAX, &record)) {
|
||||||
Point3 target = point3_add(
|
Point3 target = point3_add(
|
||||||
record.p, vec3_add(record.normal, vec3_random_in_unit_sphere()));
|
record.p, vec3_add(record.normal, vec3_random_unit_vector()));
|
||||||
return color_mul(0.5,
|
return color_mul(0.5,
|
||||||
ray_color((Ray){record.p, point3_sub(target, record.p)},
|
ray_color((Ray){record.p, point3_sub(target, record.p)},
|
||||||
world, depth - 1));
|
world, depth - 1));
|
||||||
|
|||||||
4
vec3.c
4
vec3.c
@ -59,3 +59,7 @@ Vec3 vec3_random_in_unit_sphere(void) {
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Vec3 vec3_random_unit_vector(void) {
|
||||||
|
return vec3_normalize(vec3_random_in_unit_sphere());
|
||||||
|
}
|
||||||
|
|||||||
1
vec3.h
1
vec3.h
@ -22,5 +22,6 @@ Vec3 vec3_cross(Vec3 v1, Vec3 v2);
|
|||||||
Vec3 vec3_random(void);
|
Vec3 vec3_random(void);
|
||||||
Vec3 vec3_random_in_range(double min, double max);
|
Vec3 vec3_random_in_range(double min, double max);
|
||||||
Vec3 vec3_random_in_unit_sphere(void);
|
Vec3 vec3_random_in_unit_sphere(void);
|
||||||
|
Vec3 vec3_random_unit_vector(void);
|
||||||
|
|
||||||
#endif /* INCLUDED_VEC3_H */
|
#endif /* INCLUDED_VEC3_H */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user