Fix/change in normal computation, now the viewport uses the same angle
weighted normals as the render engine, and the render engine will copy normals from the mesh rather than always recalculating them. Subsurf/multires still use regular vertex normals, but they are expected to be sufficiently high resolution to not need this. This means that normal maps displayed in the viewport actually match the render engine exactly and don't have artifacts due to this discrepancy. It of course also avoids unexpected surprises where your render normals look different than your viewport normals. Subversion bumped to 4 for version patch to recalculate normals. Patch by Morten Mikkelsen, with some small changes.
This commit is contained in:
@@ -2010,21 +2010,34 @@ void recalc_editnormals(EditMesh *em)
|
||||
if(efa->v4) {
|
||||
normal_quad_v3( efa->n,efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co);
|
||||
cent_quad_v3(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co, efa->v4->co);
|
||||
add_v3_v3(efa->v4->no, efa->n);
|
||||
}
|
||||
else {
|
||||
normal_tri_v3( efa->n,efa->v1->co, efa->v2->co, efa->v3->co);
|
||||
cent_tri_v3(efa->cent, efa->v1->co, efa->v2->co, efa->v3->co);
|
||||
}
|
||||
add_v3_v3(efa->v1->no, efa->n);
|
||||
add_v3_v3(efa->v2->no, efa->n);
|
||||
add_v3_v3(efa->v3->no, efa->n);
|
||||
|
||||
if((efa->flag&ME_SMOOTH)!=0) {
|
||||
float *n4= (efa->v4)? efa->v4->no: NULL;
|
||||
float *c4= (efa->v4)? efa->v4->co: NULL;
|
||||
|
||||
accumulate_vertex_normals(efa->v1->no, efa->v2->no, efa->v3->no, n4,
|
||||
efa->n, efa->v1->co, efa->v2->co, efa->v3->co, c4);
|
||||
}
|
||||
}
|
||||
|
||||
for(efa= em->faces.first; efa; efa=efa->next) {
|
||||
if((efa->flag&ME_SMOOTH)==0) {
|
||||
if(is_zero_v3(efa->v1->no)) copy_v3_v3(efa->v1->no, efa->n);
|
||||
if(is_zero_v3(efa->v2->no)) copy_v3_v3(efa->v2->no, efa->n);
|
||||
if(is_zero_v3(efa->v3->no)) copy_v3_v3(efa->v3->no, efa->n);
|
||||
if(efa->v4 && is_zero_v3(efa->v4->no)) copy_v3_v3(efa->v4->no, efa->n);
|
||||
}
|
||||
}
|
||||
|
||||
/* following Mesh convention; we use vertex coordinate itself for normal in this case */
|
||||
for(eve= em->verts.first; eve; eve=eve->next) {
|
||||
if (normalize_v3(eve->no)==0.0) {
|
||||
VECCOPY(eve->no, eve->co);
|
||||
if(normalize_v3(eve->no) == 0.0f) {
|
||||
copy_v3_v3(eve->no, eve->co);
|
||||
normalize_v3(eve->no);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user