Re: A better way to sample a sphere (w.r.t. solid angle) back
Board:
Home
Board index
Raytracing
General Development
(L) [2015/08/26] [akalin] [Re: A better way to sample a sphere (w.r.t. solid angle)] Wayback!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 non-visible 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!
(L) [2016/02/04] [koiava] [Re: A better way to sample a sphere (w.r.t. solid angle)] Wayback!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 [SMILEY :)]
(L) [2016/02/21] [XMAMan] [Re: A better way to sample a sphere (w.r.t. solid angle)] Wayback!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 shadow-ray from the hitpoint to the sampled disc-point.
It sounds very easy but It works in my render
Code: [LINK # 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);
}
(L) [2016/02/22] [friedlinguini] [Re: A better way to sample a sphere (w.r.t. solid angle)] Wayback!>> 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 shadow-ray from the hitpoint to the sampled disc-point.
It probably gives decent-looking 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 45-degree 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?
(L) [2016/02/22] [XMAMan] [Re: A better way to sample a sphere (w.r.t. solid angle)] Wayback!Ok, here is a picture, that shows the sampled points on the disc and the resulting points on the light-source, which are used for the direct-light-calculation.
The only problem is the calculation of the solid-angle/PdfA (area from the left to the right light-point).
[IMG #1 Image]
Where get I problems with the sampling-density / accuracy? In my sample-picture, I use a uniform-disc-sampling (not shown in the code)
[IMG #1]:Not scraped:
https://web.archive.org/web/20160319031308im_/http://s28.postimg.org/5ic2ealdl/Disc_Sampling_on_Sphere.jpg
(L) [2016/02/23] [friedlinguini] [Re: A better way to sample a sphere (w.r.t. solid angle)] Wayback!>> XMAMan wrote:The only problem is the calculation of the solid-angle/PdfA (area from the left to the right light-point).
Well, yes, but that's a big "only". It's potentially a large fraction of your solid angle..
 >> Where get I problems with the sampling-density / accuracy? In my sample-picture, I use a uniform-disc-sampling (not shown in the code)
This looks like it's supposed to be disk sampling:
Code: [LINK # 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 disk-shaped luminaire), almost all of the sampled points would be at the "horizon", as seen from the hit point, and almost none would be "overhead".
(L) [2016/04/26] [tby Paleos] [Re: A better way to sample a sphere (w.r.t. solid angle)] Wayback!How would one go about importance sampling the sphere with respect to [LINK https://en.wikipedia.org/wiki/View_factor#/media/File:Nusselt_analog.svg 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?
back