One more thing. (Sorry, I haven't thought about this stuff for a while, so it's all coming back to me in pieces.) Your method *could* be made to work, by adjusting the pdf like so: you start with the uniform cone PDF based on the projected interior solid angle, then convert to a PDF over the visible surface, then convert to a PDF based on projected solid angle from the exterior point. This is better than sampling the whole sphere because you avoid wasting effort on the nonvisible parts, but it's worse than methods that sample with respect to projected solid angle from the exterior point, because most of the time the lighting integral is with respect to projected solid angle from the exterior point, so sampling with a distribution different from that introduces more variance. (The Shirley/Wang paper from my original post talks about this a bit.)
Hope this helps!
A better way to sample a sphere (w.r.t. solid angle)
Re: A better way to sample a sphere (w.r.t. solid angle)
Useful conversion from Theta to Alpha. I also used this for cylindrical lights and good thing is that angle at light sample is Alpha+Theta and you can use it easily to calculate pdfs
Colibri Renderer
Re: A better way to sample a sphere (w.r.t. solid angle)
What do you think about Discsampling?
There is a disk with the radius from the sphere and his center is the same as the sphere. The normal from the disc shows to the point, that you want to illuminate (hitpoint). You sample than the disc and shoot a shadowray from the hitpoint to the sampled discpoint.
It sounds very easy but It works in my render
There is a disk with the radius from the sphere and his center is the same as the sphere. The normal from the disc shows to the point, that you want to illuminate (hitpoint). You sample than the disc and shoot a shadowray from the hitpoint to the sampled discpoint.
It sounds very easy but It works in my render
Code: Select all
//r1 = 2 * Math.PI * rand.NextDouble()
//r2 = rand.NextDouble()
public static Vektor SampleDirectionThatShowsFromHitpointToLightSource(float r1, float r2, Vektor hitPointPosition, Vektor lightSourceCenter, float lightSourceRadius)
{
Vektor w = Vektor.Normiere(hitPointPosition  lightSourceCenter),
u = Vektor.Normiere(Vektor.Kreuzprodukt((Math.Abs(w.x) > 0.1f ? new Vektor(0, 1, 0) : new Vektor(1, 0, 0)), w)),
v = Vektor.Kreuzprodukt(w, u);
r2 *= lightSourceRadius;
Vektor lightPoint = lightSourceCenter + (u * (float)Math.Cos(r1) * r2 + v * (float)Math.Sin(r1) * r2);
return Vektor.Normiere(lightPoint  hitPointPosition);
}

 Posts: 79
 Joined: Thu Apr 11, 2013 5:15 pm
Re: A better way to sample a sphere (w.r.t. solid angle)
XMAMan wrote:There is a disk with the radius from the sphere and his center is the same as the sphere. The normal from the disc shows to the point, that you want to illuminate (hitpoint). You sample than the disc and shoot a shadowray from the hitpoint to the sampled discpoint.
It probably gives decentlooking results, but the accuracy breaks down as the light source becomes large and/or close to the illuminated point. Imagine that the surface of the sphere is very close to the hit point. In the limit, the sphere becomes the only thing visible in the entire hemisphere over the hit point (i.e., it subtends a cone where the surface approaches 90 degrees from the axis). A disk in the same configuration would only subtend a 45degree cone. Also, I'm not sure about the sampling density. It's not uniform disc sampling (picking more points closer to the center), but uniform sampling would give an angular density that is higher closer to the edge of the disk. Do these two cancel out?
Re: A better way to sample a sphere (w.r.t. solid angle)
Ok, here is a picture, that shows the sampled points on the disc and the resulting points on the lightsource, which are used for the directlightcalculation.
The only problem is the calculation of the solidangle/PdfA (area from the left to the right lightpoint).
Where get I problems with the samplingdensity / accuracy? In my samplepicture, I use a uniformdiscsampling (not shown in the code)
The only problem is the calculation of the solidangle/PdfA (area from the left to the right lightpoint).
Where get I problems with the samplingdensity / accuracy? In my samplepicture, I use a uniformdiscsampling (not shown in the code)

 Posts: 79
 Joined: Thu Apr 11, 2013 5:15 pm
Re: A better way to sample a sphere (w.r.t. solid angle)
XMAMan wrote:The only problem is the calculation of the solidangle/PdfA (area from the left to the right lightpoint).
Well, yes, but that's a big "only". It's potentially a large fraction of your solid angle..
Where get I problems with the samplingdensity / accuracy? In my samplepicture, I use a uniformdiscsampling (not shown in the code)
This looks like it's supposed to be disk sampling:
Code: Select all
r2 *= lightSourceRadius;
Vektor lightPoint = lightSourceCenter + (u * (float)Math.Cos(r1) * r2 + v * (float)Math.Sin(r1) * r2);
You're sampling the radius with a linear distribution, but that's not a uniform density across the disk. For a unit disk, r2 in the range [0, 0.5) covers an area of pi / 4 (pi * 0.5^2), but r2 in the range[0.5, 1) covers an area of 3 * pi / 4 (pi * 1^2  pi * 0.5^2).
Also, the terms don't cancel out. If you had a very large disc that was very close to your hitpoint (a situation that might not be relevant for a spherical luminaire, but useful for checking a diskshaped luminaire), almost all of the sampled points would be at the "horizon", as seen from the hit point, and almost none would be "overhead".
Re: A better way to sample a sphere (w.r.t. solid angle)
How would one go about importance sampling the sphere with respect to projected solid angle instead of just the solid angle,
in order to importance sample the product of both the lambertian brdf and a spherical light source?
in order to importance sample the product of both the lambertian brdf and a spherical light source?
Return to “General Development”
Who is online
Users browsing this forum: No registered users and 2 guests