<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /></head><body style='font-size: 10pt; font-family: Verdana,Geneva,sans-serif'>
<p>Thanks to everyone for answering, I'm now looking at Lukas Stockner's work to see what could be used for my needs.</p>
<p>Now regarding the following remarks:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<p>I would avoid discarding samples as you will waste compute power, just find a way to reduce samples from the start</p>
</blockquote>
<div>&nbsp;</div>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0">
<div>It's difficult to tell without implementation details, what is the exact reason samples must be discarded? Transporting rays to another surface sounds pretty similar to BSDF scattering, where we use importance sampling and divide the throughput by the probability density function (pdf). Basically rather than counting the number of valid samples, we increase the weight of the valid samples to compensate for the invalid ones.</div>
</blockquote>
<div>&nbsp;</div>
<div>Sadly I can't delve too much into implementation details (it's part of an internship and I don't own the code), neither can I be too explicit about the transportation work.</div>
<div>&nbsp;</div>
<div>But in a more abstract manner, imagine a setting in which paths that intersect an arbitrary object are allowed to exist only if the end of such a path obeys a specific pattern (... -&gt; diffuse -&gt; light for example). At the intersection with said object, during path construction, I have no other option than to keep building the path until I know for sure such a path is valid or not.</div>
<div>&nbsp;</div>
<div>The difference with BSDF sampling is that in the latter we try to avoid unlikely paths, yet when they still occur, they are valid i.e physically correct. In my <strong>&ndash;</strong> I admit very specific&nbsp;<strong>&ndash;</strong> case, when we have constructed a path that does not match the end constraint, it is not unlikely per se, it simply shouldn't exist.</div>
<div>&nbsp;</div>
<div>Again, sorry for not being able to explain much about the justification for wanting to discard paths.</div>
<p>Lucas Escot.</p>
<p>Le 2017-06-23 20:33, Brecht Van Lommel a &eacute;crit&nbsp;:</p>
<blockquote type="cite" style="padding: 0 0.4em; border-left: #1010ff 2px solid; margin: 0"><!-- html ignored --><!-- head ignored --><!-- meta ignored -->
<div dir="ltr">
<div>Storing the number of samples is usually not needed, and often impractical to combine with other sampling decisions taken along the path.</div>
<div>&nbsp;</div>
<div>It's difficult to tell without implementation details, what is the exact reason samples must be discarded? Transporting rays to another surface sounds pretty similar to BSDF scattering, where we use importance sampling and divide the throughput by the probability density function (pdf). Basically rather than counting the number of valid samples, we increase the weight of the valid samples to compensate for the invalid ones.</div>
<div>&nbsp;</div>
<div class="gmail_extra"><br />
<div class="gmail_quote">On Fri, Jun 23, 2017 at 6:59 PM, Mohamed Sakr <span>&lt;<a href="mailto:3dsakr@gmail.com">3dsakr@gmail.com</a>&gt;</span> wrote:<br />
<blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;">
<div dir="ltr">Hey,<br /><br />the easiest approach is: store the number of samples per pixel in an image, divide the final image by the samples image.<br />I would avoid discarding samples as you will waste compute power, just find a way to reduce samples from the start (it needs a redesign to change how the kernel works), Lukas Stockner may have more idea about this as he tried to do an adaptive sampler before I guess.<br /><br />cheers,<br />Mohamed Sakr</div>
<div class="gmail_extra"><br />
<div class="gmail_quote">
<div>
<div class="m_-8657494346709016256h5">On Fri, Jun 23, 2017 at 1:51 PM, Escot Lucas <span>&lt;<a href="mailto:lucas.escot@ens-lyon.fr">lucas.escot@ens-lyon.fr</a>&gt;</span> wrote:</div>
</div>
<blockquote class="gmail_quote" style="margin: 0 0 0 .8ex; border-left: 1px #ccc solid; padding-left: 1ex;">
<div>
<div class="m_-8657494346709016256h5">
<div style="font-size: 10pt; font-family: Verdana,Geneva,sans-serif;">
<p>Hello everyone,</p>
<p>I originally asked the following question on the #blendercoders IRC but was advised to send it here.</p>
<p><em>Context</em>: I am currently working on a modified version of Cycles, in which the user have control over how light paths behave: they are able to transport/move rays hitting a specific surface to another one.</p>
<p>Such a modification implies that during the path tracing process, <strong>some paths/samples must be discarded</strong> (to do that I simply don't add their contribution to the final image, in kernel_path.h/kernel_path_trac<wbr />e()).</p>
<p>It means some pixels are downsampled since some of their samples might be discarded, however Cycles still divides for each pixel the total contribution by <em>the total number of samples</em> which is assumed to be constant over the entire image.</p>
<p>Hence my question: is there a simple way to make this last operation (averaging pixel samples) rely on a local number of samples, for each pixel, rather than a constant amount of samples for the entire image?</p>
<p>I hope this is the right place to ask such a question, and that some of you will have an answer.</p>
<p>Regards.</p>
<div>-- <br />
<p id="m_-8657494346709016256m_-7356900228592876713m_-7509738023783480948signature" style="font-size: smaller; color: 595959;"><span style="font-weight: bold;">Lucas Escot</span><br />L3 Informatique Fondamentale<br /><span style="font-weight: bold;">ENS de Lyon</span><br /><span>Telephone: 06 88 62 63 86</span></p>
</div>
</div>
</div>
</div>
______________________________<wbr />_________________<br /> Bf-cycles mailing list<br /> <a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br /> <a href="https://lists.blender.org/mailman/listinfo/bf-cycles">https://lists.blender.org/mail<wbr />man/listinfo/bf-cycles</a><br /> </blockquote>
</div>
</div>
<br />______________________________<wbr />_________________<br /> Bf-cycles mailing list<br /> <a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br /> <a href="https://lists.blender.org/mailman/listinfo/bf-cycles">https://lists.blender.org/mail<wbr />man/listinfo/bf-cycles</a><br /> </blockquote>
</div>
</div>
</div>
<br />
<div class="pre" style="margin: 0; padding: 0; font-family: monospace">_______________________________________________<br /> Bf-cycles mailing list<br /> <a href="mailto:Bf-cycles@blender.org">Bf-cycles@blender.org</a><br /> <a href="https://lists.blender.org/mailman/listinfo/bf-cycles">https://lists.blender.org/mailman/listinfo/bf-cycles</a></div>
</blockquote>
</body></html>