Random direction not so random
Posted 28 April 2012 - 03:01 PM
I'm trying to make it so that if a ray hit a point (or within a radius) the random hemisphere reflected ray will be the same everytime.
Posted 28 April 2012 - 06:06 PM
Bu I don't think it sounds like a great idea. If you use it for sampling in a raytracer, you'll get weird artifacts.
Posted 29 April 2012 - 04:04 AM
Posted 29 April 2012 - 05:44 AM
Posted 29 April 2012 - 06:04 AM
Posted 29 April 2012 - 02:17 PM
First, pregenerate array of evenly distributed rays in full unit sphere, defRay[N].xyz.
Second, generate random rotation matrix M. For that you must generate true random point on 4D sphere (quaternion), it might be tricky but quite doable.
Third, spawn rays with directions dir[i] = normalize(N + M * defRay[i]), where N is unit surface normal.
That way you have rays distributed in hemisphere with density proportional to cos(N^dir) which is ideal for diffuse surfaces. True random rotation on every ray hit ensures mathematic correctness and reduces banding.
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users