Fix for bugs #6709 and #7005:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 23 Nov 2007 14:10:05 +0000 (14:10 +0000)
committerBrecht Van Lommel <brechtvanlommel@pandora.be>
Fri, 23 Nov 2007 14:10:05 +0000 (14:10 +0000)
- SSS not working with negative scale objects.
- Fluids + SSS not always rendering smooth normals correct.

source/blender/render/intern/source/convertblender.c
source/blender/render/intern/source/rendercore.c

index 29b48413ca730bb55ef86e096fc2d8baacf3a0d2..ca9c7652441bc241f486bcd242ad0cec5e80a274 100644 (file)
@@ -1883,9 +1883,10 @@ static void init_render_mesh(Render *re, Object *ob, Object *par, int only_verts
                                MTC_Mat4MulVecfl(mat, ver->co);
 
                        if(useFluidmeshNormals) {
-                               xn = mvert->no[0]/ 32767.0;
-                               yn = mvert->no[1]/ 32767.0;
-                               zn = mvert->no[2]/ 32767.0;
+                               /* normals are inverted in render */
+                               xn = -mvert->no[0]/ 32767.0;
+                               yn = -mvert->no[1]/ 32767.0;
+                               zn = -mvert->no[2]/ 32767.0;
                                /* transfor to cam  space */
                                ver->n[0]= imat[0][0]*xn+imat[0][1]*yn+imat[0][2]*zn;
                                ver->n[1]= imat[1][0]*xn+imat[1][1]*yn+imat[1][2]*zn;
index b12d6094f2b925d0ae813500e43f7ac0d8d63693..0f91a92fe9c1c7f37a3c6d55d3cdba5819dd9342 100644 (file)
@@ -1182,11 +1182,8 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, VlakRen *vlr, in
                shade_input_set_triangle_i(shi, vlr, 0, 1, 2);
 
        /* we don't want flipped normals, they screw up back scattering */
-       if(vlr->noflag & R_FLIPPED_NO) {
-               shi->facenor[0]= -shi->facenor[0];
-               shi->facenor[1]= -shi->facenor[1];
-               shi->facenor[2]= -shi->facenor[2];
-       }
+       if(vlr->noflag & R_FLIPPED_NO)
+               VecMulf(shi->facenor, -1.0f);
 
        /* center pixel */
        x += 0.5f;
@@ -1214,6 +1211,12 @@ static void shade_sample_sss(ShadeSample *ssamp, Material *mat, VlakRen *vlr, in
        shade_input_set_uv(shi);
        shade_input_set_normals(shi);
 
+       /* not a pretty solution, but fixes common cases */
+       if(vlr->ob && vlr->ob->transflag & OB_NEG_SCALE) {
+               VecMulf(shi->vn, -1.0f);
+               VecMulf(shi->vno, -1.0f);
+       }
+
        /* if nodetree, use the material that we are currently preprocessing
           instead of the node material */
        if(shi->mat->nodetree && shi->mat->use_nodes)