Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2010-09-20 23:57:14 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2010-09-20 23:57:14 +0400
commitaff24bdc077c36945db22e2c3f88d6d6302a172d (patch)
treec71903bf9e51507fa3e9ae134adf325803c79d9c /source/blender/render
parent67367a22cf12f678d30079f4b1d8b8ff23aecd49 (diff)
Fix error in normal flipping commit, that showed wrong result especially
with ray transparency + normals pointing away from the camera.
Diffstat (limited to 'source/blender/render')
-rw-r--r--source/blender/render/intern/source/shadeinput.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c
index 56ab56d0411..4754e0d15f1 100644
--- a/source/blender/render/intern/source/shadeinput.c
+++ b/source/blender/render/intern/source/shadeinput.c
@@ -792,10 +792,26 @@ void shade_input_set_normals(ShadeInput *shi)
{
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];