Lambertian reflections implemented

This commit is contained in:
Luxdragon 2024-02-29 14:50:33 +01:00
parent 6cf0166f89
commit 311be99d95
2 changed files with 68042 additions and 68041 deletions

136080
image.ppm

File diff suppressed because it is too large Load diff

View file

@ -366,7 +366,8 @@ func Ray_color(r Ray, depth int, world *Hittable) Vec3 {
return NewColor(0,0,0)
}
if (world.Hit(&r, *NewInterval(0.001, float32(math.Inf(1))), &rec)) {
direction := RandomOnHemisphere(rec.normal)
//direction := RandomOnHemisphere(rec.normal)
direction := rec.normal.Add(RandomUnitVector())
return Ray_color(*((NewRay(rec.p, direction))), depth-1, world).Mult(0.5)
}
unit_direction := Unit_vector(r.Direction())