diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2020-04-16 09:58:25 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2020-04-16 09:58:25 +0300 |
commit | ec263547b53477bf7e0b775c913353d897ccae1c (patch) | |
tree | 00fb121b7150643f9eefaf23a7d38dbbda669dc4 /source/blender/draw | |
parent | 0301aff28523bdbf71842f6b1c3c06e4639dc453 (diff) | |
parent | 5d9d246851082c785104388399b3766eff7d2228 (diff) |
Merge branch 'blender-v2.83-release'
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_effect_cavity.c | 8 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_extract_mesh.c | 18 |
2 files changed, 16 insertions, 10 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_effect_cavity.c b/source/blender/draw/engines/workbench/workbench_effect_cavity.c index cdf8a93fc57..4a8db65c02e 100644 --- a/source/blender/draw/engines/workbench/workbench_effect_cavity.c +++ b/source/blender/draw/engines/workbench/workbench_effect_cavity.c @@ -42,11 +42,11 @@ /* Using Hammersley distribution */ static float *create_disk_samples(int num_samples, int num_iterations) { + BLI_assert(num_samples * num_iterations <= CAVITY_MAX_SAMPLES); const int total_samples = num_samples * num_iterations; const float num_samples_inv = 1.0f / num_samples; /* vec4 to ensure memory alignment. */ float(*texels)[4] = MEM_callocN(sizeof(float[4]) * CAVITY_MAX_SAMPLES, __func__); - for (int i = 0; i < total_samples; i++) { float it_add = (i / num_samples) * 0.499f; float r = fmodf((i + 0.5f + it_add) * num_samples_inv, 1.0f); @@ -102,7 +102,7 @@ void workbench_cavity_data_update(WORKBENCH_PrivateData *wpd, WORKBENCH_UBO_Worl if (CAVITY_ENABLED(wpd)) { int cavity_sample_count_single_iteration = scene->display.matcap_ssao_samples; int cavity_sample_count_total = workbench_cavity_total_sample_count(wpd, scene); - int max_iter_count = cavity_sample_count_total / cavity_sample_count_single_iteration; + const int max_iter_count = cavity_sample_count_total / cavity_sample_count_single_iteration; int sample = wpd->taa_sample % max_iter_count; wd->cavity_sample_start = cavity_sample_count_single_iteration * sample; @@ -128,6 +128,7 @@ void workbench_cavity_samples_ubo_ensure(WORKBENCH_PrivateData *wpd) int cavity_sample_count_single_iteration = scene->display.matcap_ssao_samples; int cavity_sample_count = workbench_cavity_total_sample_count(wpd, scene); + const int max_iter_count = max_ii(1, cavity_sample_count / cavity_sample_count_single_iteration); if (wpd->vldata->cavity_sample_count != cavity_sample_count) { DRW_UBO_FREE_SAFE(wpd->vldata->cavity_sample_ubo); @@ -135,8 +136,7 @@ void workbench_cavity_samples_ubo_ensure(WORKBENCH_PrivateData *wpd) } if (wpd->vldata->cavity_sample_ubo == NULL) { - float *samples = create_disk_samples(cavity_sample_count_single_iteration, - max_ii(1, wpd->taa_sample_len)); + float *samples = create_disk_samples(cavity_sample_count_single_iteration, max_iter_count); wpd->vldata->cavity_jitter_tx = create_jitter_texture(cavity_sample_count); /* NOTE: Uniform buffer needs to always be filled to be valid. */ wpd->vldata->cavity_sample_ubo = DRW_uniformbuffer_create( diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c index fe63dec1294..4c51ed99f2c 100644 --- a/source/blender/draw/intern/draw_cache_extract_mesh.c +++ b/source/blender/draw/intern/draw_cache_extract_mesh.c @@ -1648,9 +1648,12 @@ static void extract_lnor_hq_loop_mesh( normal_float_to_short_v3(&lnor_data->x, mr->poly_normals[p]); } - /* Flag for paint mode overlay. */ - if (mpoly->flag & ME_HIDE || (mr->extract_type == MR_EXTRACT_MAPPED && (mr->v_origindex) && - mr->v_origindex[mloop->v] == ORIGINDEX_NONE)) { + /* Flag for paint mode overlay. + * Only use MR_EXTRACT_MAPPED in edit mode where it is used to display the edge-normals. In paint + * mode it will use the unmapped data to draw the wireframe. */ + if (mpoly->flag & ME_HIDE || + (mr->edit_bmesh && mr->extract_type == MR_EXTRACT_MAPPED && (mr->v_origindex) && + mr->v_origindex[mloop->v] == ORIGINDEX_NONE)) { lnor_data->w = -1; } else if (mpoly->flag & ME_FACE_SEL) { @@ -1724,9 +1727,12 @@ static void extract_lnor_loop_mesh( *lnor_data = GPU_normal_convert_i10_v3(mr->poly_normals[p]); } - /* Flag for paint mode overlay. */ - if (mpoly->flag & ME_HIDE || (mr->extract_type == MR_EXTRACT_MAPPED && (mr->v_origindex) && - mr->v_origindex[mloop->v] == ORIGINDEX_NONE)) { + /* Flag for paint mode overlay. + * Only use MR_EXTRACT_MAPPED in edit mode where it is used to display the edge-normals. In paint + * mode it will use the unmapped data to draw the wireframe. */ + if (mpoly->flag & ME_HIDE || + (mr->edit_bmesh && mr->extract_type == MR_EXTRACT_MAPPED && (mr->v_origindex) && + mr->v_origindex[mloop->v] == ORIGINDEX_NONE)) { lnor_data->w = -1; } else if (mpoly->flag & ME_FACE_SEL) { |