Fix diffuse reflection

This commit is contained in:
numzero 2025-01-03 19:50:19 +03:00
parent 946617f988
commit b69ebd80e9

View File

@ -113,7 +113,8 @@ fn trace_fragment(in: Varying) -> vec3f {
let normal = (pos - s.center) / s.radius;
if (all(s.emit_color == vec3(0.))) {
color *= s.reflect_color;
let diffuse = normal + rand_sphere();
let sp = rand_sphere();
let diffuse = sign(dot(sp, normal)) * sp;
let specular = reflect(ray, normal);
ray = normalize(mix(diffuse, specular, s.glossiness));
} else {