0
109 Apr 28, 2012 at 15:01

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.

#### 6 Replies

0
101 Apr 28, 2012 at 18:06

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.

0
109 Apr 29, 2012 at 04:04

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!

0
101 Apr 29, 2012 at 05:44

Yes, less random directions would make it look less grainy. But you would instead get banding. There’s really no way around this.

0
109 Apr 29, 2012 at 06:04

I know what you mean. So how do some renders produce super fast shadows that are so smooth??

0
101 Apr 29, 2012 at 14:17

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.

0
109 Apr 29, 2012 at 16:37

I see what you mean. I’ll give that a try, thanks!