From ddbb3d673c802bf6d3f65cc606456db3e08d88ab Mon Sep 17 00:00:00 2001 From: Christophe Hery Date: Thu, 2 Jan 2025 15:20:57 +0100 Subject: [PATCH] Cycles: Optimize out default normals setups in case of OPENSUBDIV Catmull-Clark Simple local optimization: not doing the rather expensive normals setups (face and vertex) for Catmull-Clark subsivisions (which do not make use of these normals and regenerate them internally). Pull Request: https://projects.blender.org/blender/blender/pulls/132469 --- intern/cycles/scene/geometry.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/intern/cycles/scene/geometry.cpp b/intern/cycles/scene/geometry.cpp index 359ebfb7f08..f4e28873afe 100644 --- a/intern/cycles/scene/geometry.cpp +++ b/intern/cycles/scene/geometry.cpp @@ -734,17 +734,26 @@ void GeometryManager::device_update(Device *device, if (geom->is_mesh() || geom->is_volume()) { Mesh *mesh = static_cast(geom); - /* Update normals. */ - mesh->add_face_normals(); - mesh->add_vertex_normals(); - if (mesh->need_attribute(scene, ATTR_STD_POSITION_UNDISPLACED)) { mesh->add_undisplaced(); } - /* Test if we need tessellation. */ + /* Test if we need tessellation and setup normals if required. */ if (mesh->need_tesselation()) { total_tess_needed++; + /* OPENSUBDIV Catmull-Clark does not make use of input normals and will overwrite them. + */ +#ifdef WITH_OPENSUBDIV + if (mesh->get_subdivision_type() != Mesh::SUBDIVISION_CATMULL_CLARK) +#endif + { + mesh->add_face_normals(); + mesh->add_vertex_normals(); + } + } + else { + mesh->add_face_normals(); + mesh->add_vertex_normals(); } /* Test if we need displacement. */