Current stable version: 0.1.1

Absorption color error on overlapping glass objects

Project:YafaRay
Version:0.1.1
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

To create realistic liquid-in-a-glass renders, the liquid needs to intersect the glass for correct refraction, but yafaray doest render the absorption color when i do this.

I've attached an example. The top of the liquid is correct, but the sides (faces that are actually inside the glass object) have no color.

AttachmentSize
AbsorptionComparison.png152.53 KB

Comments

#1

I've come up with a solution to this problem. The changes include changes to the intersect function so that two meshes may exist in the same place. This means that 2 objects, e.g. a glass and the water inside can both have completely closed meshes. Along the interface surface between the two objects the meshes must be in the same place. This means that the intersect function detects both meshes along this interface.

This means aborption can work correctly because the entry in to each closed mesh is always detected. It also means that is no longer necessary to manually calculate the effective refractive index of the surface between the glass and the water. Each closed mesh just has one IOR over the whole surface, including the interface with any other object. The code will do the calculation itself at the interface to get the correct effective refractive index.

This is the patch file.


example.blend for this image.

AttachmentSize
example.png 275.1 KB

#2

The above patch was intended to be applied to the mainline. This patch is a modified version, which may be applied to the dt_dev branch.

 

Also, just to demonstrate the point of this patch, this is the same blend file as the one used to generate the image above, but rendered without the patch.

 

Obviously it's a mess, because without the patch Yafaray can't handle surfaces in the same place. But this isn't a fair comparison because this isn't the recommended way to create model glass - liquid interfaces. The following image is the same scene but modified so that there is only one mesh at the liquid-glass interface. The technique of dividing one IOR by the other to obtain the IOR at the interface has been applied.

The most obvious problem with this however is that refraction effect it too strong. This is because, for the absorption to work correctly the interface mesh normal must face out of the glass.However this means that the effective IOR is the recipricol of what it should be. A solution to this would be to allow IOR less than 1, then the glass-liquid interface mesh IOR could be set correctly while still having the normals pointing out. However this would not solve the problem, because if the glass itself also had an absorption color, then the normals of the glass-liquid interface would need to point in to the glass for the absorption to be correct, obviously the normals of a single mesh cannot point in two directions at once.

This problem is solved by this patch, because it allows two meshes to exist in the same place, so this issue of which way the normal should point is eliminated, meaning aborption for both materials is correct. Plus, as an added bonus, it is no longer necessary to do the manual calculation of effective IORs at the interface.

AttachmentSize
example_orig_code.png 333.99 KB
example_orig_code_w_hack.png 321.35 KB

#3

I've put together a third version of this patch. Note that archive attached below contains two patches, one for the yafaray tree and one for the yafaray-blender tree. The changes in this patch, are a toggle button on the yafaray gui, to turn on and off this feature (called "Dual Interface Meshes", not sure if this most enlightening name), and an optimization which has dramatically sped up rendering of scenes modelled in this closed mesh way.

Here is a comparison, of the scene rendered with and without the patch, and with the feature enabled and disabled. Three different scenes are rendered, one with closed meshes, one with one mesh per interface, and finally a scene with no glass at all. In the glass scenes, no absorption colors have been used, so that the same scene could be modelled with and without the patch.

Timing results (s) :

  Patched - Feature Enabled Patched - Feature Disabled Unpatched
One mesh per interface 529.3 527.3 514.1
Closed Meshes 519.0 339.9 * 341.1 *
No glass 153.5 151.4 152.0
  Patched - Feature Enabled Patched - Feature Disabled Unpatched
One mesh per interface
Closed Meshes
No glass

 

* - The times for rendering the closed mesh model with the feature disabled can not be compared with the other because the image produced is completely wrong. The quicker time is simply due to the fact the less and refraction and internal reflection occurs due to the errors at the interfaces.

 

The relevant timings are the 'one mesh per interface' model times, and the closed mesh with the feature on timing. For the 'one mesh per interface' timing, the patch slows down the code 2.5%. Turning the feature on and off then makes very little difference. With the closed mesh model the timing is actually slightly quicker.

AttachmentSize
yafaray_double_intersect.zip 7.18 KB
cb.png 84.9 KB
cf.png 85.58 KB
co.png 77.71 KB
hb.png 77.59 KB
hf.png 77.59 KB
ho.png 77.59 KB
nb.png 128.18 KB
nf.png 128.19 KB
no.png 128.2 KB

#4

For comparison the closed mesh model with absorbtion turned on looks like this:

And took 434 seconds to render. I'm not 100% sure why its quicker, I can only assume it's either due to paths being cut short due to some upper limit on the amount absorbtion allowed. Or due to less photons landing on the back panel due to some of them being absorbed by the absorbtion of the liquid.

Note that example render in my first post is actually incorrectly modelled, here is a corrected version:

AttachmentSize
coa.png 78.54 KB
example_with_surface_fix.png 282.13 KB