I'm working on a raytracer with diffuse reflections (with say 64 or 128 samples per reflection).
For example, a material may be 75% reflective which means the reflected rays need to deviate from "perfect" reflection by 25%.
I've been trying to sort this out by calculating the reflected ray's right and up vectors and using percentages to multiply all three to combine into a deviated vector.
right = cross(intersectionNormal, ray)
up = cross(right, ray)
ray' = (ray * w) + (up * u) + (right * v)
I can't seem to get the math right. I've tried generating multipliers for each component based on spherical coordinates (random inclination at a random angle around the perfect reflection) but my math isn't working properly. The results never look like a semi-diffuse reflection. They look wrong. I'm using Random.NextDouble() to get random spherical coordinates within the material's reflectivity range.
Given a reflectivity between 1.0 (perfect) and 0.0 (diffuse), an intersection normal and a perfect reflection ray, how would I deviate this by the reflectivity percentage?