I guess I must do it slightly different then, because I just tested mine with MIS and MIS + 3 light RIS (or whatever warped self-rolled version of RIS I'm using) and there is no difference. I don't scale the PDF though when evaluating multiple light sources. I simply leave the light PDF as is and scale the contribution of the final selected light. That way my MIS weights should be fairly safe and independent of RIS.

The code looks like this

Code:

` LightSample light_sample = sample_single_light(material, world_shading_tbn);`

for (int s = 1; s < light_samples; ++s) {

LightSample new_light_sample = sample_single_light(material, world_shading_tbn);

float light_weight = sum(light_sample.radiance);

float new_light_weight = sum(new_light_sample.radiance);

float new_light_probability = new_light_weight / (light_weight + new_light_weight);

if (rng.sample1f() < new_light_probability) {

light_sample = new_light_sample;

light_sample.radiance /= new_light_probability;

} else

light_sample.radiance /= 1.0f - new_light_probability;

}

light_sample.radiance /= light_samples;

Statistics: Posted by papaboo — Wed Jul 19, 2017 1:50 pm

]]>

rtpt wrote:

if you want to combine ris/mis have a look at the work of j. talbot and refs.

if you want to combine ris/mis have a look at the work of j. talbot and refs.

I am aware of his work, but I don't think he solved this issue, and in fact, I don't think it's possible.

Statistics: Posted by jbikker — Wed Jul 19, 2017 10:46 am

]]>

papaboo wrote:

Out of curiosity, because it sounds like I'm doing something very similar and back when I was investigating it I saw no bias issues, what is the RIS trap? Is RIS conceptually flawed or is it a reoccurring 'gotcha' that you keep forgetting?

Out of curiosity, because it sounds like I'm doing something very similar and back when I was investigating it I saw no bias issues, what is the RIS trap? Is RIS conceptually flawed or is it a reoccurring 'gotcha' that you keep forgetting?

if you want to combine ris/mis have a look at the work of j. talbot and refs.

Statistics: Posted by rtpt — Wed Jul 19, 2017 10:08 am

]]>

papaboo wrote:

Out of curiosity, because it sounds like I'm doing something very similar and back when I was investigating it I saw no bias issues, what is the RIS trap? Is RIS conceptually flawed or is it a reoccurring 'gotcha' that you keep forgetting?

Out of curiosity, because it sounds like I'm doing something very similar and back when I was investigating it I saw no bias issues, what is the RIS trap? Is RIS conceptually flawed or is it a reoccurring 'gotcha' that you keep forgetting?

I used RIS for my light sources in the past: out of e.g. 1k lights, select 4 based on view independent information (i.e. brightness and area), then evaluate those four in more detail (including distance and orientation). This works like a charm until you need MIS. It is simply not possible to reproduce the probability of sampling a light explicitly when an implicit path reaches the light.

Statistics: Posted by jbikker — Tue Jul 18, 2017 1:59 pm

]]>

]]>

ingenious wrote:

You can easily test whether this indeed is the problem by using a light selection probability that is only a function of deterministically known things at the shading point (i.e. every time you land at this point you will compute the exact same light selection probability).

You can easily test whether this indeed is the problem by using a light selection probability that is only a function of deterministically known things at the shading point (i.e. every time you land at this point you will compute the exact same light selection probability).

That is indeed correct: if I use a fixed probability for sampling the light or the sky, everything is OK.

You are correct that the light sampling / sky sampling probability itself became a random variable... So I am basically falling in the 'Resampled Importance Sampling' trap again.

- Jacco.

Statistics: Posted by jbikker — Fri Jul 14, 2017 1:31 pm

]]>

You can easily test whether this indeed is the problem by using a light selection probability that is only a function of deterministically known things at the shading point (i.e. every time you land at this point you will compute the exact same light selection probability).

Statistics: Posted by ingenious — Tue Jul 11, 2017 4:30 pm

]]>

stefan wrote:

Just to be sure, the sample you're taking to calculate the probabilities is being discarded right after that and not being reused?

Just to be sure, the sample you're taking to calculate the probabilities is being discarded right after that and not being reused?

Correct.

stefan wrote:

Out of curiosity, how do you notice that there's bias?

Well the setup is a simple box with a single-sided quad light well below the ceiling. One side of the box is open, letting in illumination from the skydome. The walls can thus 'see' the light up to a certain height. With the reference path tracer, the transition from 'below light level' to 'above light level' is somewhat fuzzy. The approach where lights or the sky are sampled with a custom probability causes this line to be unnaturally hard. Apart from that the overall energy level appears to be correct.

Statistics: Posted by jbikker — Tue Jul 11, 2017 2:45 pm

]]>

jbikker wrote:

Obviously, some parts of the scene benefit more from lights than the skydome. So, I want to change the probability of sampling the light or the sky depending on potential contribution. So I evaluate a random point on the skydome (importance sampled) and a random point on a random light. Based on these 'potential contributions' I determine the probability of sampling a light or the sky. This probability is recorded, so that when I stumble upon a light or the sky I can use it like I used the 0.5 in the previous scenario.

Obviously, some parts of the scene benefit more from lights than the skydome. So, I want to change the probability of sampling the light or the sky depending on potential contribution. So I evaluate a random point on the skydome (importance sampled) and a random point on a random light. Based on these 'potential contributions' I determine the probability of sampling a light or the sky. This probability is recorded, so that when I stumble upon a light or the sky I can use it like I used the 0.5 in the previous scenario.

Just to be sure, the sample you're taking to calculate the probabilities is being discarded right after that and not being reused?

Sadly, this introduces bias, although subtle, and I can't figure out what I am doing wrong.

Out of curiosity, how do you notice that there's bias?

Statistics: Posted by stefan — Tue Jul 11, 2017 9:21 am

]]>

]]>

patlefort wrote:

When your ray stumble upon a light source and you want to do MIS, you need to know the probability of it being selected. It's impossible to know if that probability without having sampled random points on all other light sources in your sampling method. I'm not sure if doing that make sense and will converge to a correct result.

Currently all lights have an equal probability of being selected. So when I stumble upon a light I have two options:

1. The last vertex was specular, so there is no other strategy to sample the light, so the contribution is simply throughput * light color.

2. The last vertex was not specular, so we now have a second strategy, so MIS is used. For that I calculate the light pdf = dist^2 / solid angle, and the brdf pdf, which I stored when I did the diffuse bounce. The combined pdf is then simply the sum of these.

This part is working, and agrees with a reference renderer (not using next event estimation).

What also works is IBL by itself: I can sample it with next event estimation and importance sampling, and MIS works too (similar to what I just described). But when I want to combine IBL and lights things get tricky:

1. If I either sample a light *or* the skydome everything is clear; the probability of sampling the sky is now e.g. 50% of what it was, which causes no problems in MIS. Same for the lights. Any other probability also works just fine.

2. If however I chose a probability based on some heuristic (in my case: 'potential contribution') things go bad, even when I can reproduce that exact probability when I apply MIS, and even when it's never zero for a light or the skydome. That's the part that is puzzling me...

javor wrote:

This sounds like you are mixing up the sampling probability with the contribution of the light source. If you have selected the light source without taking the visibility (or being infront/to the back of the point being shaded) into account, then the probability of this sampling strategy should be non-zero (and the sky probability < 1).

But isn't any (non-zero) probability fine, in principle? I am not skipping any lights, nor any part of the skydome.

Conformance to reference is checked by the way by averaging the energy for each pixel and reporting this value. This quickly converges (even if there's tons of noise) and gives a very good indication of the accuracy of an approach.

Statistics: Posted by jbikker — Mon Jul 10, 2017 6:23 pm

]]>

jbikker wrote:

One thing that I realized is that when the random selected light happens to be behind the point that is being evaluated the potential contribution is 0, and therefore the sky will be selected with a probability of 1.

One thing that I realized is that when the random selected light happens to be behind the point that is being evaluated the potential contribution is 0, and therefore the sky will be selected with a probability of 1.

This sounds like you are mixing up the sampling probability with the contribution of the light source. If you have selected the light source without taking the visibility (or being infront/to the back of the point being shaded) into account, then the probability of this sampling strategy should be non-zero (and the sky probability < 1).

Otherwise, if your sampling strategy only samples lights that are visible (or in the upper hemisphere), this should be reflected in the algorithm, e.g. by discarding the sampled light source until a valid one is found or all are discarded. In this scenario the probability of sampling the sky would be 1, only if none of the remaining light sources are "visible".

Statistics: Posted by javor — Mon Jul 10, 2017 3:36 pm

]]>

One thing that I realized is that when the random selected light happens to be behind the point that is being evaluated the potential contribution is 0, and therefore the sky will be selected with a probability of 1. However, another light may in fact be visible, so when I stumble upon it the MIS probability for sampling it explicitly is wrongly set to 0. So I clamped the light/sky probability to the range of 0.1..0.9 to ensure that both at least have a chance of being selected, but this feels wrong, bias remains (although the situation is better) and it looks like I am not understanding something here.

If you have 3 lights, then you need to consider all 3 when weighting them for selection. How exactly are you generating your weights? The simplest way is just using the (luminous) power of each light, then you can just normalize them to get probabilities, but obviously you have to consider all the lights.

More complex schemes would approximate the irradiance, e.g. by calculating the solid angle subtended by the lights' shape (this would naturally handle your case of a light being behind the current vertex's hemisphere).

Even more complex schemes take into account the BSDF of the surface.

The tradeoff is of course, the more accurate your approximation when selecting a light, the lower your variance, but the more expensive each event is to find. You're trading poor performance with small numbers of lights for high performance with large numbers of lights.

Statistics: Posted by andersll — Sun Jul 09, 2017 8:48 pm

]]>

However, another light may in fact be visible, so when I stumble upon it the MIS probability for sampling it explicitly is wrongly set to 0.

I don't understand that part, if you have say 3 lights and one is behind the point, you'd be left selecting between 2 lights. The probability being I assume derived from some weighted sum.

Statistics: Posted by patlefort — Sat Jul 08, 2017 11:04 pm

]]>

I have a question about something that I can't seem to wrap my head around.

Here's the situation:

In a unidirectional path tracer with next event estimation and MIS lights can be reached by a random bounce and by explicitly sampling the light source. For MIS I thus take both pdfs into consideration, both when I stumble upon the light and when I sample it explicitly. So far so good.

Now, I add in IBL. In my first implementation, I randomly select either the skydome or one of the lights for next event estimation (50/50). When I stumble upon the light, I use the pdf for sampling a light scaled by 0.5 to account for the fact that I could have sampled it with 50% probability. Same for the sky. This produces a correct image, so I believe this method is correct and unbiased. Any other probability for light/sky works, including 0 and 100%.

Obviously, some parts of the scene benefit more from lights than the skydome. So, I want to change the probability of sampling the light or the sky depending on potential contribution. So I evaluate a random point on the skydome (importance sampled) and a random point on a random light. Based on these 'potential contributions' I determine the probability of sampling a light or the sky. This probability is recorded, so that when I stumble upon a light or the sky I can use it like I used the 0.5 in the previous scenario.

Sadly, this introduces bias, although subtle, and I can't figure out what I am doing wrong.

One thing that I realized is that when the random selected light happens to be behind the point that is being evaluated the potential contribution is 0, and therefore the sky will be selected with a probability of 1. However, another light may in fact be visible, so when I stumble upon it the MIS probability for sampling it explicitly is wrongly set to 0. So I clamped the light/sky probability to the range of 0.1..0.9 to ensure that both at least have a chance of being selected, but this feels wrong, bias remains (although the situation is better) and it looks like I am not understanding something here.

Any ideas?

Statistics: Posted by jbikker — Thu Jul 06, 2017 10:51 am

]]>