diff options
author | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-07-30 15:50:00 +0400 |
---|---|---|
committer | Brecht Van Lommel <brechtvanlommel@pandora.be> | 2010-07-30 15:50:00 +0400 |
commit | 5251a9b3bf39c1520bdad4c8aa3f6273def76c77 (patch) | |
tree | afa12bb87827eb73ffffc437cff3a13b1b77eb91 /source/blender | |
parent | 9e45fa7f2fb7b7044340c8a9b28b9a3dcc2e4300 (diff) |
2.5: remove vertex normal flip option, this is more harmful than helpful
in many cases, and also gave incorrect rim lighting.
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/blenkernel/intern/mesh.c | 1 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_curve_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesdna/DNA_mesh_types.h | 2 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_curve.c | 5 | ||||
-rw-r--r-- | source/blender/makesrna/intern/rna_mesh.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/include/render_types.h | 16 | ||||
-rw-r--r-- | source/blender/render/intern/include/renderdatabase.h | 2 | ||||
-rw-r--r-- | source/blender/render/intern/source/convertblender.c | 43 | ||||
-rw-r--r-- | source/blender/render/intern/source/rayshade.c | 4 | ||||
-rw-r--r-- | source/blender/render/intern/source/renderdatabase.c | 28 | ||||
-rw-r--r-- | source/blender/render/intern/source/shadeinput.c | 25 |
11 files changed, 20 insertions, 112 deletions
diff --git a/source/blender/blenkernel/intern/mesh.c b/source/blender/blenkernel/intern/mesh.c index cd8b2eb0a8e..66e8c10206c 100644 --- a/source/blender/blenkernel/intern/mesh.c +++ b/source/blender/blenkernel/intern/mesh.c @@ -697,7 +697,6 @@ void mball_to_mesh(ListBase *lb, Mesh *me) if(dl==0) return; if(dl->type==DL_INDEX4) { - me->flag= ME_NOPUNOFLIP; me->totvert= dl->nr; me->totface= dl->parts; diff --git a/source/blender/makesdna/DNA_curve_types.h b/source/blender/makesdna/DNA_curve_types.h index c13cb08badd..283c810a1f6 100644 --- a/source/blender/makesdna/DNA_curve_types.h +++ b/source/blender/makesdna/DNA_curve_types.h @@ -245,7 +245,7 @@ typedef struct Curve { #define CU_PATH 8 #define CU_FOLLOW 16 #define CU_UV_ORCO 32 -#define CU_NOPUNOFLIP 64 +#define CU_DEPRECATED 64 #define CU_STRETCH 128 #define CU_OFFS_PATHDIST 256 #define CU_FAST 512 /* Font: no filling inside editmode */ diff --git a/source/blender/makesdna/DNA_mesh_types.h b/source/blender/makesdna/DNA_mesh_types.h index 68b05dd6595..4e41309cff4 100644 --- a/source/blender/makesdna/DNA_mesh_types.h +++ b/source/blender/makesdna/DNA_mesh_types.h @@ -129,7 +129,7 @@ typedef struct TFace { /* me->flag */ /* #define ME_ISDONE 1 */ -#define ME_NOPUNOFLIP 2 +#define ME_DEPRECATED 2 #define ME_TWOSIDED 4 #define ME_UVEFFECT 8 #define ME_VCOLEFFECT 16 diff --git a/source/blender/makesrna/intern/rna_curve.c b/source/blender/makesrna/intern/rna_curve.c index e006f3444b0..d10aed1595a 100644 --- a/source/blender/makesrna/intern/rna_curve.c +++ b/source/blender/makesrna/intern/rna_curve.c @@ -706,11 +706,6 @@ static void rna_def_nurbs(BlenderRNA *brna, StructRNA *srna) RNA_def_property_boolean_sdna(prop, NULL, "flag", CU_UV_ORCO); RNA_def_property_ui_text(prop, "Map Along Length", "Generate texture mapping coordinates following the curve direction, rather than the local bounding box"); RNA_def_property_update(prop, 0, "rna_Curve_update_data"); - - prop= RNA_def_property(srna, "vertex_normal_flip", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", CU_NOPUNOFLIP); - RNA_def_property_ui_text(prop, "Vertex Normal Flip", "Flip vertex normals towards the camera during render"); - RNA_def_property_update(prop, 0, "rna_Curve_update_data"); } static void rna_def_font(BlenderRNA *brna, StructRNA *srna) diff --git a/source/blender/makesrna/intern/rna_mesh.c b/source/blender/makesrna/intern/rna_mesh.c index 6e172e3bdd0..37d6b2b93de 100644 --- a/source/blender/makesrna/intern/rna_mesh.c +++ b/source/blender/makesrna/intern/rna_mesh.c @@ -1748,10 +1748,6 @@ static void rna_def_mesh(BlenderRNA *brna) RNA_def_property_range(prop, 1, 80); RNA_def_property_ui_text(prop, "Auto Smooth Angle", "Defines maximum angle between face normals that 'Auto Smooth' will operate on"); - prop= RNA_def_property(srna, "vertex_normal_flip", PROP_BOOLEAN, PROP_NONE); - RNA_def_property_boolean_negative_sdna(prop, NULL, "flag", ME_NOPUNOFLIP); - RNA_def_property_ui_text(prop, "Vertex Normal Flip", "Flip vertex normals towards the camera during render"); - prop= RNA_def_property(srna, "double_sided", PROP_BOOLEAN, PROP_NONE); RNA_def_property_boolean_sdna(prop, NULL, "flag", ME_TWOSIDED); RNA_def_property_ui_text(prop, "Double Sided", "Render/display the mesh with double or single sided lighting"); diff --git a/source/blender/render/intern/include/render_types.h b/source/blender/render/intern/include/render_types.h index 2b0de46f2e6..c75ae594daf 100644 --- a/source/blender/render/intern/include/render_types.h +++ b/source/blender/render/intern/include/render_types.h @@ -587,23 +587,21 @@ typedef struct LampRen { #define R_HALO 2 #define R_SEC_FIELD 4 #define R_LAMPHALO 8 -#define R_GLOB_NOPUNOFLIP 16 -#define R_NEED_TANGENT 32 -#define R_BAKE_TRACE 128 -#define R_BAKING 256 +#define R_NEED_TANGENT 16 +#define R_BAKE_TRACE 32 +#define R_BAKING 64 /* vlakren->flag (vlak = face in dutch) char!!! */ #define R_SMOOTH 1 #define R_HIDDEN 2 /* strand flag, means special handling */ #define R_STRAND 4 -#define R_NOPUNOFLIP 8 -#define R_FULL_OSA 16 -#define R_FACE_SPLIT 32 +#define R_FULL_OSA 8 +#define R_FACE_SPLIT 16 /* Tells render to divide face other way. */ -#define R_DIVIDE_24 64 +#define R_DIVIDE_24 32 /* vertex normals are tangent or view-corrected vector, for hair strands */ -#define R_TANGENT 128 +#define R_TANGENT 64 /* strandbuffer->flag */ #define R_STRAND_BSPLINE 1 diff --git a/source/blender/render/intern/include/renderdatabase.h b/source/blender/render/intern/include/renderdatabase.h index 2a0086b436c..76e7fe7b4f3 100644 --- a/source/blender/render/intern/include/renderdatabase.h +++ b/source/blender/render/intern/include/renderdatabase.h @@ -115,7 +115,7 @@ struct MCol *RE_vlakren_get_mcol(struct ObjectRen *obr, VlakRen *ren, int n, cha float *RE_vlakren_get_surfnor(struct ObjectRen *obr, VlakRen *ren, int verify); float *RE_vlakren_get_nmap_tangent(struct ObjectRen *obr, VlakRen *ren, int verify); RadFace **RE_vlakren_get_radface(struct ObjectRen *obr, VlakRen *ren, int verify); -int RE_vlakren_get_normal(struct Render *re, struct ObjectInstanceRen *obi, struct VlakRen *vlr, float *nor); +void RE_vlakren_get_normal(struct Render *re, struct ObjectInstanceRen *obi, struct VlakRen *vlr, float *nor); float *RE_strandren_get_surfnor(struct ObjectRen *obr, struct StrandRen *strand, int verify); float *RE_strandren_get_uv(struct ObjectRen *obr, struct StrandRen *strand, int n, char **name, int verify); diff --git a/source/blender/render/intern/source/convertblender.c b/source/blender/render/intern/source/convertblender.c index c5d69e69586..6564dd09864 100644 --- a/source/blender/render/intern/source/convertblender.c +++ b/source/blender/render/intern/source/convertblender.c @@ -356,17 +356,6 @@ static void split_v_renderfaces(ObjectRen *obr, int startvlak, int startvert, in } /* ------------------------------------------------------------------------- */ - -static int check_vnormal(float *n, float *veno) -{ - float inp; - - inp=n[0]*veno[0]+n[1]*veno[1]+n[2]*veno[2]; - if(inp < -FLT_EPSILON10) return 1; - return 0; -} - -/* ------------------------------------------------------------------------- */ /* Stress, tangents and normals */ /* ------------------------------------------------------------------------- */ @@ -536,9 +525,6 @@ static void calc_vertexnormals(Render *re, ObjectRen *obr, int do_tangent, int d float n1[3], n2[3], n3[3], n4[3]; float fac1, fac2, fac3, fac4=0.0f; - if(re->flag & R_GLOB_NOPUNOFLIP) - vlr->flag |= R_NOPUNOFLIP; - sub_v3_v3v3(n1, v2->co, v1->co); normalize_v3(n1); sub_v3_v3v3(n2, v3->co, v2->co); @@ -562,21 +548,11 @@ static void calc_vertexnormals(Render *re, ObjectRen *obr, int do_tangent, int d fac3= saacos(-n2[0]*n3[0]-n2[1]*n3[1]-n2[2]*n3[2]); fac4= saacos(-n3[0]*n4[0]-n3[1]*n4[1]-n3[2]*n4[2]); - if(!(vlr->flag & R_NOPUNOFLIP)) { - if( check_vnormal(vlr->n, v4->n) ) fac4= -fac4; - } - v4->n[0] +=fac4*vlr->n[0]; v4->n[1] +=fac4*vlr->n[1]; v4->n[2] +=fac4*vlr->n[2]; } - if(!(vlr->flag & R_NOPUNOFLIP)) { - if( check_vnormal(vlr->n, v1->n) ) fac1= -fac1; - if( check_vnormal(vlr->n, v2->n) ) fac2= -fac2; - if( check_vnormal(vlr->n, v3->n) ) fac3= -fac3; - } - v1->n[0] +=fac1*vlr->n[0]; v1->n[1] +=fac1*vlr->n[1]; v1->n[2] +=fac1*vlr->n[2]; @@ -1021,7 +997,7 @@ static void static_particle_strand(Render *re, ObjectRen *obr, Material *ma, Par else width= 1.0f; if(ma->mode & MA_TANGENT_STR) - flag= R_SMOOTH|R_NOPUNOFLIP|R_TANGENT; + flag= R_SMOOTH|R_TANGENT; else flag= R_SMOOTH; @@ -2431,7 +2407,7 @@ static void init_render_mball(Render *re, ObjectRen *obr) normal_tri_v3( vlr->n,vlr->v3->co, vlr->v2->co, vlr->v1->co); vlr->mat= ma; - vlr->flag= ME_SMOOTH+R_NOPUNOFLIP; + vlr->flag= ME_SMOOTH; vlr->ec= 0; /* mball -too bad- always has triangles, because quads can be non-planar */ @@ -2460,10 +2436,8 @@ static void init_render_mball(Render *re, ObjectRen *obr) /* returns amount of vertices added for orco */ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, float *orco, float mat[4][4]) { - Object *ob= obr->ob; VertRen *v1, *v2, *v3, *v4, *ver; VlakRen *vlr, *vlr1, *vlr2, *vlr3; - Curve *cu= ob->data; float *data, n1[3]; int u, v, orcoret= 0; int p1, p2, p3, p4, a; @@ -2543,9 +2517,6 @@ static int dl_surf_to_renderdata(ObjectRen *obr, DispList *dl, Material **matar, vlr->mat= matar[ dl->col]; vlr->ec= ME_V1V2+ME_V2V3; vlr->flag= dl->rt; - if( (cu->flag & CU_NOPUNOFLIP) ) { - vlr->flag |= R_NOPUNOFLIP; - } add_v3_v3(v1->n, n1); add_v3_v3(v2->n, n1); @@ -2694,9 +2665,6 @@ static void init_render_dm(DerivedMesh *dm, Render *re, ObjectRen *obr, vlr->mat= ma; vlr->flag= flag; - if(cu &&(cu->flag & ME_NOPUNOFLIP)) { - vlr->flag |= R_NOPUNOFLIP; - } vlr->ec= 0; /* mesh edges rendered separately */ if(len==0) obr->totvlak--; @@ -2904,9 +2872,6 @@ static void init_render_curve(Render *re, ObjectRen *obr, int timeoffset) vlr->mat= matar[ dl->col ]; vlr->flag= 0; - if( (cu->flag & CU_NOPUNOFLIP) ) { - vlr->flag |= R_NOPUNOFLIP; - } vlr->ec= 0; } } @@ -3391,9 +3356,6 @@ static void init_render_mesh(Render *re, ObjectRen *obr, int timeoffset) vlr->mat= ma; vlr->flag= flag; - if((me->flag & ME_NOPUNOFLIP) ) { - vlr->flag |= R_NOPUNOFLIP; - } vlr->ec= 0; /* mesh edges rendered separately */ if(len==0) obr->totvlak--; @@ -5612,7 +5574,6 @@ void RE_Database_Baking(Render *re, Scene *scene, unsigned int lay, int type, Ob RE_init_threadcount(re); - re->flag |= R_GLOB_NOPUNOFLIP; re->flag |= R_BAKING; re->excludeob= actob; if(actob) diff --git a/source/blender/render/intern/source/rayshade.c b/source/blender/render/intern/source/rayshade.c index b4a43373ef4..724fd9a3110 100644 --- a/source/blender/render/intern/source/rayshade.c +++ b/source/blender/render/intern/source/rayshade.c @@ -531,10 +531,6 @@ void shade_ray(Isect *is, ShadeInput *shi, ShadeResult *shr) shade_input_set_normals(shi); - /* point normals to viewing direction */ - if(INPR(shi->facenor, shi->view) < 0.0f) - shade_input_flip_normals(shi); - shade_input_set_shade_texco(shi); if (shi->mat->material_type == MA_TYPE_VOLUME) { if(ELEM(is->mode, RE_RAY_SHADOW, RE_RAY_SHADOW_TRA)) { diff --git a/source/blender/render/intern/source/renderdatabase.c b/source/blender/render/intern/source/renderdatabase.c index 2bfc8f6c1ef..ce55935d392 100644 --- a/source/blender/render/intern/source/renderdatabase.c +++ b/source/blender/render/intern/source/renderdatabase.c @@ -440,10 +440,9 @@ VlakRen *RE_vlakren_copy(ObjectRen *obr, VlakRen *vlr) return vlr1; } -int RE_vlakren_get_normal(Render *re, ObjectInstanceRen *obi, VlakRen *vlr, float *nor) +void RE_vlakren_get_normal(Render *re, ObjectInstanceRen *obi, VlakRen *vlr, float *nor) { - float v1[3], (*nmat)[3]= obi->nmat; - int flipped= 0; + float (*nmat)[3]= obi->nmat; if(obi->flag & R_TRANSFORMED) { VECCOPY(nor, vlr->n); @@ -453,29 +452,6 @@ int RE_vlakren_get_normal(Render *re, ObjectInstanceRen *obi, VlakRen *vlr, floa } else VECCOPY(nor, vlr->n); - - if((vlr->flag & R_NOPUNOFLIP)==0) { - if(re->r.mode & R_ORTHO) { - if(nor[2] > 0.0f) - flipped= 1; - } - else { - VECCOPY(v1, vlr->v1->co); - if(obi->flag & R_TRANSFORMED) - mul_m4_v3(obi->mat, v1); - if(INPR(v1, nor) < 0.0f) { - flipped= 1; - } - } - - if(flipped) { - nor[0]= -nor[0]; - nor[1]= -nor[1]; - nor[2]= -nor[2]; - } - } - - return flipped; } void RE_set_customdata_names(ObjectRen *obr, CustomData *data) diff --git a/source/blender/render/intern/source/shadeinput.c b/source/blender/render/intern/source/shadeinput.c index fc9aba20870..56ab56d0411 100644 --- a/source/blender/render/intern/source/shadeinput.c +++ b/source/blender/render/intern/source/shadeinput.c @@ -273,7 +273,8 @@ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen shi->mode= shi->mat->mode_l; /* or-ed result for all nodes */ /* facenormal copy, can get flipped */ - shi->flippednor= RE_vlakren_get_normal(&R, obi, vlr, shi->facenor); + shi->flippednor= 0; + RE_vlakren_get_normal(&R, obi, vlr, shi->facenor); /* calculate vertexnormals */ if(vlr->flag & R_SMOOTH) { @@ -286,24 +287,6 @@ void shade_input_set_triangle_i(ShadeInput *shi, ObjectInstanceRen *obi, VlakRen mul_m3_v3(obi->nmat, shi->n2); mul_m3_v3(obi->nmat, shi->n3); } - - if(!(vlr->flag & (R_NOPUNOFLIP|R_TANGENT))) { - if(INPR(shi->facenor, shi->n1) < 0.0f) { - shi->n1[0]= -shi->n1[0]; - shi->n1[1]= -shi->n1[1]; - shi->n1[2]= -shi->n1[2]; - } - if(INPR(shi->facenor, shi->n2) < 0.0f) { - shi->n2[0]= -shi->n2[0]; - shi->n2[1]= -shi->n2[1]; - shi->n2[2]= -shi->n2[2]; - } - if(INPR(shi->facenor, shi->n3) < 0.0f) { - shi->n3[0]= -shi->n3[0]; - shi->n3[1]= -shi->n3[1]; - shi->n3[2]= -shi->n3[2]; - } - } } } @@ -826,6 +809,10 @@ void shade_input_set_normals(ShadeInput *shi) /* used in nodes */ VECCOPY(shi->vno, shi->vn); + /* flip normals to viewing direction */ + if(!(shi->vlr->flag & R_TANGENT)) + if(dot_v3v3(shi->facenor, shi->view) < 0.0f) + shade_input_flip_normals(shi); } /* use by raytrace, sss, bake to flip into the right direction */ |