Mesh: Add viewport normals simplify option #5

Closed
Hans Goudey wants to merge 1 commits from mesh-normals-simplify-option into refactor-mesh-corner-normals-lazy

When changing the target branch, be careful to rebase the branch in your fork to match. See documentation.
8 changed files with 24 additions and 7 deletions
Showing only changes of commit 15143b0eb1 - Show all commits

View File

@ -2271,6 +2271,7 @@ class CYCLES_RENDER_PT_simplify_viewport(CyclesButtonsPanel, Panel):
col.prop(rd, "simplify_child_particles", text="Child Particles")
col.prop(cscene, "texture_limit", text="Texture Limit")
col.prop(rd, "simplify_volumes", text="Volume Resolution")
col.prop(rd, "use_simplify_normals", text="Normals")
class CYCLES_RENDER_PT_simplify_render(CyclesButtonsPanel, Panel):

View File

@ -1197,6 +1197,9 @@ class RENDER_PT_simplify_viewport(RenderButtonsPanel, Panel):
col = flow.column()
col.prop(rd, "simplify_shadows", text="Shadow Resolution")
col = flow.column()
col.prop(rd, "use_simplify_normals", text="Normals")
class RENDER_PT_simplify_render(RenderButtonsPanel, Panel):
bl_label = "Render"

View File

@ -4652,7 +4652,7 @@ void blo_do_versions_280(FileData *fd, Library * /*lib*/, Main *bmain)
R_MODE_UNUSED_5 | R_MODE_UNUSED_6 | R_MODE_UNUSED_7 | R_MODE_UNUSED_8 |
R_MODE_UNUSED_10 | R_MODE_UNUSED_13 | R_MODE_UNUSED_16 |
R_MODE_UNUSED_17 | R_MODE_UNUSED_18 | R_MODE_UNUSED_19 |
R_MODE_UNUSED_20 | R_MODE_UNUSED_21 | R_MODE_UNUSED_27);
R_MODE_UNUSED_20 | R_MODE_UNUSED_21 | R_SIMPLIFY_NORMALS);
scene->r.scemode &= ~(R_SCEMODE_UNUSED_8 | R_SCEMODE_UNUSED_11 | R_SCEMODE_UNUSED_13 |
R_SCEMODE_UNUSED_16 | R_SCEMODE_UNUSED_17 | R_SCEMODE_UNUSED_19);

View File

@ -686,6 +686,7 @@ void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
mr->use_hide = use_hide;
mr->use_subsurf_fdots = mr->me && !mr->me->runtime->subsurf_face_dot_tags.is_empty();
mr->use_final_mesh = do_final;
mr->use_simplify_normals = (scene->r.mode & R_SIMPLIFY) && (scene->r.mode & R_SIMPLIFY_NORMALS);
#ifdef DEBUG_TIME
double rdata_end = PIL_check_seconds_timer();

View File

@ -413,9 +413,10 @@ void mesh_render_data_update_normals(MeshRenderData &mr, const eMRDataType data_
if (data_flag & (MR_DATA_POLY_NOR | MR_DATA_LOOP_NOR | MR_DATA_TAN_LOOP_NOR)) {
mr.face_normals = mr.me->face_normals();
}
if (((data_flag & MR_DATA_LOOP_NOR) && ELEM(mr.me->normals_domain(),
blender::bke::MeshNormalDomain::Corner,
blender::bke::MeshNormalDomain::Face)) ||
if (((data_flag & MR_DATA_LOOP_NOR) && !mr.use_simplify_normals &&
ELEM(mr.me->normals_domain(),
blender::bke::MeshNormalDomain::Corner,
blender::bke::MeshNormalDomain::Face)) ||
(data_flag & MR_DATA_TAN_LOOP_NOR))
{
mr.loop_normals = mr.me->corner_normals();

View File

@ -51,6 +51,7 @@ struct MeshRenderData {
bool use_subsurf_fdots;
bool use_final_mesh;
bool hide_unmapped_edges;
bool use_simplify_normals;
/** Use for #MeshStatVis calculation which use world-space coords. */
float obmat[4][4];

View File

@ -2114,9 +2114,9 @@ enum {
R_NO_OVERWRITE = 1 << 22, /* Skip existing files. */
R_TOUCH = 1 << 23, /* Touch files before rendering. */
R_SIMPLIFY = 1 << 24,
R_EDGE_FRS = 1 << 25, /* R_EDGE reserved for Freestyle */
R_PERSISTENT_DATA = 1 << 26, /* Keep data around for re-render. */
R_MODE_UNUSED_27 = 1 << 27, /* cleared */
R_EDGE_FRS = 1 << 25, /* R_EDGE reserved for Freestyle */
R_PERSISTENT_DATA = 1 << 26, /* Keep data around for re-render. */
R_SIMPLIFY_NORMALS = 1 << 27, /* cleared */
Review

How are these flags assigned? I don't know the usage and history, but why not use the lower bits? Or add a new one if they are somehow reserved? Seems kind of arbitrary.

How are these flags assigned? I don't know the usage and history, but why not use the lower bits? Or add a new one if they are somehow reserved? Seems kind of arbitrary.
};
/** #RenderData::seq_flag */

View File

@ -7049,6 +7049,16 @@ static void rna_def_scene_render_data(BlenderRNA *brna)
prop, "Simplify Volumes", "Resolution percentage of volume objects in viewport");
RNA_def_property_update(prop, 0, "rna_Scene_simplify_update");
prop = RNA_def_property(srna, "use_simplify_normals", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_sdna(prop, nullptr, "mode", R_SIMPLIFY_NORMALS);
RNA_def_property_ui_text(
prop,
"Mesh Normals",
"Skip computing custom normals and face corner normals for the viewport");
/* Note: Unlike other simplify properties, this doesn't recalculate objects, since it just
* affects viewport drawing. */
RNA_def_property_update(prop, NC_SCENE | ND_RENDER_OPTIONS, nullptr);
/* EEVEE - Simplify Options */
prop = RNA_def_property(srna, "simplify_shadows_render", PROP_FLOAT, PROP_FACTOR);
RNA_def_property_float_default(prop, 1.0);