[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [32031] trunk/blender/source/blender/ render/intern/source/shadeinput.c: Fix error in normal flipping commit, that showed wrong result especially

Brecht Van Lommel brechtvanlommel at pandora.be
Mon Sep 20 21:57:14 CEST 2010


Revision: 32031
          http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=32031
Author:   blendix
Date:     2010-09-20 21:57:14 +0200 (Mon, 20 Sep 2010)

Log Message:
-----------
Fix error in normal flipping commit, that showed wrong result especially
with ray transparency + normals pointing away from the camera.

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

Modified: trunk/blender/source/blender/render/intern/source/shadeinput.c
===================================================================
--- trunk/blender/source/blender/render/intern/source/shadeinput.c	2010-09-20 15:12:53 UTC (rev 32030)
+++ trunk/blender/source/blender/render/intern/source/shadeinput.c	2010-09-20 19:57:14 UTC (rev 32031)
@@ -792,10 +792,26 @@
 {
 	float u= shi->u, v= shi->v;
 	float l= 1.0f+u+v;
+
+	shi->flippednor = 0;
+
+	/* test flip normals to viewing direction */
+	if(!(shi->vlr->flag & R_TANGENT)) {
+		if(dot_v3v3(shi->facenor, shi->view) < 0.0f) {
+			negate_v3(shi->facenor);
+			shi->flippednor= 1;
+		}
+	}
 	
 	/* calculate vertexnormals */
 	if(shi->vlr->flag & R_SMOOTH) {
 		float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3;
+
+		if(shi->flippednor) {
+			negate_v3(n1);
+			negate_v3(n2);
+			negate_v3(n3);
+		}
 		
 		shi->vn[0]= l*n3[0]-u*n1[0]-v*n2[0];
 		shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1];





More information about the Bf-blender-cvs mailing list