[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [34622] trunk/blender/source/blender/ render/intern/source/rayshade.c: Fix for [#25899] Renderer can' t trace successive total internal reflection

Janne Karhu jhkarh at gmail.com
Wed Feb 2 13:04:24 CET 2011


Revision: 34622
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=34622
Author:   jhk
Date:     2011-02-02 12:04:23 +0000 (Wed, 02 Feb 2011)
Log Message:
-----------
Fix for [#25899] Renderer can't trace successive total internal reflection
* This was wrong since 2006!
* Raytrace code assumed refractions to go "air -> glass -> air -> glass -> air.." so actually only the first total internal reflection was calculated correctly, but everything after that was wrong.
* Now after a total internal reflection there needs to be an actual refraction before the ray escapes the "glass" object.

Modified Paths:
--------------
    trunk/blender/source/blender/render/intern/source/rayshade.c

Modified: trunk/blender/source/blender/render/intern/source/rayshade.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/rayshade.c	2011-02-02 10:33:29 UTC (rev 34621)
+++ trunk/blender/source/blender/render/intern/source/rayshade.c	2011-02-02 12:04:23 UTC (rev 34622)
@@ -779,12 +779,18 @@
 						norm[0]= - shi.vn[0];
 						norm[1]= - shi.vn[1];
 						norm[2]= - shi.vn[2];
-						if (!refraction(refract, norm, shi.view, shi.ang))
+						if (!refraction(refract, norm, shi.view, shi.ang)) {
 							reflection(refract, norm, shi.view, shi.vn);
+							/* for total internal reflection the ray stays inside the material, so don't flip the normal (double flip) */
+							traflag ^= RAY_TRAFLIP;
+						}
 					}
 					else {
-						if (!refraction(refract, shi.vn, shi.view, shi.ang))
+						if (!refraction(refract, shi.vn, shi.view, shi.ang)) {
 							reflection(refract, shi.vn, shi.view, shi.vn);
+							/* same reason as above */
+							traflag ^= RAY_TRAFLIP;
+						}
 					}
 					traflag |= RAY_TRA;
 					traceray(origshi, origshr, depth-1, shi.co, refract, tracol, shi.obi, shi.vlr, traflag ^ RAY_TRAFLIP);




More information about the Bf-blender-cvs mailing list