SPPM wrong glass refraction

Component:YafaRay Core
Category:bug report
Assigned:David Bluecame


While doing some tests with SPPM I noticed the glass material refractions are strange, showing too dark refractions respect to what it should be.

I've attached a scene you can try, and I've seen this problem in v2.1.1 but also I could trace it down to old Core versions such as v0.1.2

SPPM (wrong glass refraction, darker than it should)


Also when using old Core v0.1.2:


This is the same scene but using photon maps (2M for diffuse and 5M for caustic). Here the glass refractions are normal.

sppm_glass_wrong.blend.zip86.02 KB
sppm_glass_wrong v2.1.1 (SPPM, wrong).png473.41 KB
sppm_glass_wrong v2.1.1 (photon map OK).png522.83 KB
sppm_glass_wrong old v0.1.2 (SPPM, wrong).png456.25 KB



Doing more tests I got strange and interesting results.

If I disable Initial Radius Estimation (IRE), then the glass refraction looks good.


In fact, the glass shadow looks more correct (in my opinion) than the glass shadow in the photon mapping. That's strange and interesting, maybe a bug in Photon Mapping?   Also the light distribution looks quite different in Photon Mapping and SPPM. Something weird is going on here.

sppm_glass_wrong v2.1.1 (SPPM without IRE OK, better than photon map maybe).png 511.5 KB


Photon map with FG seems to give a "similar" result to SPPM without IRE, in both glass shadow and overall illumination.

I'm a bit confused now, it seems each combination is giving different results for some reason. I wonder if that's normal or not?  (does not look normal to me but maybe I'm wrong??)

sppm_glass_wrong v2.1.1 (photon+FG seems OK).png 525.73 KB


Hi guys :)

Here the result with PathTracing method ( unbiased and physically correct I guess)

Best regards

PT_render.jpg 91.37 KB

Olivier Boscournu __ riofranco design  Montpellier _ France   http://www.olivier-boscournu.com/


Hello, Olivier.

Thank you for your test. However, I'm afraid that path tracing may not be the best method to check this, as Path Tracing is not very good with caustics and requires far too many samples to get them right. For example, your test shows quite a significant shadow from the glass, which I believe should not be there (the glass shadow should be non existant or very faint in my opinion)

The best algorithm to check this would be bidirectional path tracing, but the bidir in YafaRay is not very good :-(


Hi David

I made other tests with and without " fake shadow" in Glass material panel ( and transparent shadow enabled too in Render Settings), using PathTracing and Bidirectional PathTracing, here the results. Bidirectional is, in this case of Cornell Box, faster than PT.

Just think about something... Bidirectional PT can be used for realtime preview like Cycles ?

BiPT_render.jpg 99.49 KB
BiPT_fake_shadow.jpg 43.04 KB
PT_fake_shadow.jpg 33.15 KB

Olivier Boscournu __ riofranco design  Montpellier _ France   http://www.olivier-boscournu.com/



I'm not sure about YafaRay Bidirectional, in my tests I found it gives strange results. I'll try to do some tests with LuxRender Metropolis Bidirectional, which has given me quite realistic results in the past, although slow.

About realtime preview, that would require mamy changes in the code, such as ability to add and remove objects/materials/etc in runtime to the YafaRay engine. Right now that's not implemented yet... Also we have to deal with the Blender API limitations about getting information about modified objects, etc.

However, is in my to-do list for the medium-long term.


I've done a test with LuxRender Bidirectional Metropolis, 500 samples/pixel and a glass with 0xFFFFFF color in both reflection and refraction, IOR 1.52 and this is the result, which is what I would expect from a thin glass (very faint shadow, almost nothing)

sppm_glass_wrong.blend-luxrender 500 samples-pixel - glass 0xFFFFFF reflection refraction ior 1.52.png 120.04 KB


Luxrender and mitsuba have an sppm engine, you can check and get some ideas if needed.


Status:active» postponed

I will postpone for now any potential integrator improvements to focus on materials for the next months.