forked from bartvdbraak/blender
Fix error in normal flipping commit, that showed wrong result especially
with ray transparency + normals pointing away from the camera.
This commit is contained in:
parent
67367a22cf
commit
aff24bdc07
@ -793,10 +793,26 @@ void shade_input_set_normals(ShadeInput *shi)
|
|||||||
float u= shi->u, v= shi->v;
|
float u= shi->u, v= shi->v;
|
||||||
float l= 1.0f+u+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 */
|
/* calculate vertexnormals */
|
||||||
if(shi->vlr->flag & R_SMOOTH) {
|
if(shi->vlr->flag & R_SMOOTH) {
|
||||||
float *n1= shi->n1, *n2= shi->n2, *n3= shi->n3;
|
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[0]= l*n3[0]-u*n1[0]-v*n2[0];
|
||||||
shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1];
|
shi->vn[1]= l*n3[1]-u*n1[1]-v*n2[1];
|
||||||
shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2];
|
shi->vn[2]= l*n3[2]-u*n1[2]-v*n2[2];
|
||||||
|
Loading…
Reference in New Issue
Block a user