[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [43187] trunk/blender/source/blender/ render/intern/source/rayshade.c: Fix #29723: wrong IOR for raytraced refraction after reflection inside mesh,

Brecht Van Lommel brechtvanlommel at pandora.be
Thu Jan 5 23:41:56 CET 2012


Revision: 43187
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=43187
Author:   blendix
Date:     2012-01-05 22:41:56 +0000 (Thu, 05 Jan 2012)
Log Message:
-----------
Fix #29723: wrong IOR for raytraced refraction after reflection inside mesh,
patch by Juha Maki-Kanto.

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	2012-01-05 22:41:46 UTC (rev 43186)
+++ trunk/blender/source/blender/render/intern/source/rayshade.c	2012-01-05 22:41:56 UTC (rev 43187)
@@ -780,7 +780,10 @@
 				tracol[3]= col[3];	// we pass on and accumulate alpha
 				
 				if((shi.mat->mode & MA_TRANSP) && (shi.mat->mode & MA_RAYTRANSP)) {
-					if(traflag & RAY_INSIDE) {
+					/* don't overwrite traflag, it's value is used in mirror reflection */
+					int new_traflag = traflag;
+					
+					if(new_traflag & RAY_INSIDE) {
 						/* inside the material, so use inverse normal */
 						float norm[3];
 						norm[0]= - shi.vn[0];
@@ -789,7 +792,7 @@
 
 						if (refraction(refract, norm, shi.view, shi.ang)) {
 							/* ray comes out from the material into air */
-							traflag &= ~RAY_INSIDE;
+							new_traflag &= ~RAY_INSIDE;
 						}
 						else {
 							/* total internal reflection (ray stays inside the material) */
@@ -799,14 +802,14 @@
 					else {
 						if (refraction(refract, shi.vn, shi.view, shi.ang)) {
 							/* ray goes in to the material from air */
-							traflag |= RAY_INSIDE;
+							new_traflag |= RAY_INSIDE;
 						}
 						else {
 							/* total external reflection (ray doesn't enter the material) */
 							reflection(refract, shi.vn, shi.view, shi.vn);
 						}
 					}
-					traceray(origshi, origshr, depth-1, shi.co, refract, tracol, shi.obi, shi.vlr, traflag);
+					traceray(origshi, origshr, depth-1, shi.co, refract, tracol, shi.obi, shi.vlr, new_traflag);
 				}
 				else
 					traceray(origshi, origshr, depth-1, shi.co, shi.view, tracol, shi.obi, shi.vlr, 0);
@@ -840,7 +843,7 @@
 				float ref[3];
 				
 				reflection_simple(ref, shi.vn, shi.view);
-				traceray(origshi, origshr, depth-1, shi.co, ref, mircol, shi.obi, shi.vlr, 0);
+				traceray(origshi, origshr, depth-1, shi.co, ref, mircol, shi.obi, shi.vlr, traflag);
 			
 				f1= 1.0f-f;
 



More information about the Bf-blender-cvs mailing list