alienizer at April 28th, 2012 11:01 — #1
Is it possible to create a "random" direction on the hemisphere based on the point position on a surface, rather than using frand()? So that it is not so random locally, but in overall, it appear random enough?
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.
geon at April 28th, 2012 14:06 — #2
You could create a grid of evenly spread directions, then jitter each one based on some Perlin noise function.
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.
alienizer at April 29th, 2012 00:04 — #3
I was thinking of doing this for my render, because, when a ray hit a glossy surface, it shoot a random ray, so now it looks grainy like a photon or path tracer! I don't know how to make it otherwise!
geon at April 29th, 2012 01:44 — #4
Yes, less random directions would make it look less grainy. But you would instead get banding. There's really no way around this.
alienizer at April 29th, 2012 02:04 — #5
I know what you mean. So how do some renders produce super fast shadows that are so smooth??
smile_ at April 29th, 2012 10:17 — #6
I think you can try following method.
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*= normalize(N + M * defRay*), 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.
alienizer at April 29th, 2012 12:37 — #7
I see what you mean. I'll give that a try, thanks!