I can generate a ray on the surface of a hemisphere pointing toward a random location on a distant sphere fairly simply: you sample over a circle on the surface of the hemisphere corresponding to the projected sphere. The sampling itself can be achieved by e.g. this.
However, if the sphere is transformed by a linear transform (e.g. a nonuniform scaling and a rotation), then the method doesn't work. Is there a nice way to handle that?
Sampling Distorted Spheres

 Posts: 29
 Joined: Sun Jul 28, 2013 6:53 pm
 Contact:
Re: Sampling Distorted Spheres
I don't know if this is the correct way to do it, but what I've been doing in Psychopath is sampling in the local space of the sphere, and then transforming the resulting vector into world space after the fact.
I can imagine this may be incorrect, though, since for nonuniform scaling, shearing, etc. the surface area is distorted nonuniformally (I think?).
I'll be curious if someone smarter knows how to handle this. It would be great if there were a general way to handle this (e.g. given a sampling strategy for shape X, how to conduct that strategy when the shape is distorted by matrix M).
I can imagine this may be incorrect, though, since for nonuniform scaling, shearing, etc. the surface area is distorted nonuniformally (I think?).
I'll be curious if someone smarter knows how to handle this. It would be great if there were a general way to handle this (e.g. given a sampling strategy for shape X, how to conduct that strategy when the shape is distorted by matrix M).

 Posts: 29
 Joined: Sun Jul 28, 2013 6:53 pm
 Contact:
Re: Sampling Distorted Spheres
Not sure exactly what you mean for your sampling strategy, but surface area certainly will be distorted nonuniformly. One way to see this is to think about each different normal as being a different point on the sphere. Scale the sphere by <0.001,1.0,1.0>, and you'll see that suddenly there are a lot more normals pointing left/right than otherwise.cessen wrote:I don't know if this is the correct way to do it, but what I've been doing in Psychopath is sampling in the local space of the sphere, and then transforming the resulting vector into world space after the fact.
I can imagine this may be incorrect, though, since for nonuniform scaling, shearing, etc. the surface area is distorted nonuniformally (I think?).
My plan is to sample a bounding sphere around the transformed sphere. Some of the samples will be wasted in general, but it should work.
Re: Sampling Distorted Spheres
I do not have a closedform answer (which most likely exists, certainly involving determinants of jacobian matrices), just an intuitive idea: Consider the definition of the area measure on the surface at point p dA(p) = magnitude(dx(p) ^dy(p)), where dx and dy are tangent vectors obtained as the derivative of p with respect to a system of coordinates (surface > 2 coordinates > 2 vectors), the area measure on the distorted shape obtained from the original one via a distortion function D can be obtained by computing the differential vectors in the distorted shape for the distorted point D(p).

 Posts: 160
 Joined: Mon Nov 28, 2011 7:28 pm