Fix for bugs #6709 and #7005:

- SSS not working with negative scale objects.
- Fluids + SSS not always rendering smooth normals correct.
This commit is contained in:
2007-11-23 14:10:05 +00:00
parent 45a53c4749
commit 885593ca21
2 changed files with 12 additions and 8 deletions

View 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;

View 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)