From 735119dd0f91b60c827278947afc8544446a7658 Mon Sep 17 00:00:00 2001 From: Jacques Lucke Date: Wed, 27 May 2020 16:15:06 +0200 Subject: [PATCH 1/3] Fix T75096: Crash when using liquid simulation as dynamic paint brush Reviewers: sergey Differential Revision: https://developer.blender.org/D7853 --- source/blender/blenkernel/intern/dynamicpaint.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/blender/blenkernel/intern/dynamicpaint.c b/source/blender/blenkernel/intern/dynamicpaint.c index a704e199007..79f0aacc3f8 100644 --- a/source/blender/blenkernel/intern/dynamicpaint.c +++ b/source/blender/blenkernel/intern/dynamicpaint.c @@ -2701,15 +2701,16 @@ static void dynamic_paint_find_island_border(const DynamicPaintCreateUVSurfaceDa } } + const int final_tri_index = tempPoints[final_index].tri_index; /* If found pixel still lies on wrong face ( mesh has smaller than pixel sized faces) */ - if (tempPoints[final_index].tri_index != target_tri) { + if (final_tri_index != target_tri && final_tri_index != -1) { /* Check if it's close enough to likely touch the intended triangle. Any triangle * becomes thinner than a pixel at its vertices, so robustness requires some margin. */ const float final_pt[2] = {((final_index % w) + 0.5f) / w, ((final_index / w) + 0.5f) / h}; const float threshold = square_f(0.7f) / (w * h); - if (dist_squared_to_looptri_uv_edges( - mlooptri, mloopuv, tempPoints[final_index].tri_index, final_pt) > threshold) { + if (dist_squared_to_looptri_uv_edges(mlooptri, mloopuv, final_tri_index, final_pt) > + threshold) { continue; } } From 79e529c5ec16d644693c1a71790819e020a293cd Mon Sep 17 00:00:00 2001 From: Brecht Van Lommel Date: Wed, 27 May 2020 18:00:59 +0200 Subject: [PATCH 2/3] Fix T77109: Cycles viewport render crash after object add and undo --- intern/cycles/blender/blender_session.cpp | 4 ++++ intern/cycles/blender/blender_sync.cpp | 8 ++++++++ intern/cycles/blender/blender_sync.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/intern/cycles/blender/blender_session.cpp b/intern/cycles/blender/blender_session.cpp index 5ea96d6bdfd..ed90d054d73 100644 --- a/intern/cycles/blender/blender_session.cpp +++ b/intern/cycles/blender/blender_session.cpp @@ -168,9 +168,13 @@ void BlenderSession::create_session() void BlenderSession::reset_session(BL::BlendData &b_data, BL::Depsgraph &b_depsgraph) { + /* Update data, scene and depsgraph pointers. These can change after undo. */ this->b_data = b_data; this->b_depsgraph = b_depsgraph; this->b_scene = b_depsgraph.scene_eval(); + if (sync) { + sync->reset(this->b_data, this->b_scene); + } if (preview_osl) { PointerRNA cscene = RNA_pointer_get(&b_scene.ptr, "cycles"); diff --git a/intern/cycles/blender/blender_sync.cpp b/intern/cycles/blender/blender_sync.cpp index e8031be7dd1..90736b7630d 100644 --- a/intern/cycles/blender/blender_sync.cpp +++ b/intern/cycles/blender/blender_sync.cpp @@ -78,6 +78,14 @@ BlenderSync::~BlenderSync() { } +void BlenderSync::reset(BL::BlendData &b_data, BL::Scene &b_scene) +{ + /* Update data and scene pointers in case they change in session reset, + * for example after undo. */ + this->b_data = b_data; + this->b_scene = b_scene; +} + /* Sync */ void BlenderSync::sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d) diff --git a/intern/cycles/blender/blender_sync.h b/intern/cycles/blender/blender_sync.h index 650b4f5bb4e..f0ea5194c29 100644 --- a/intern/cycles/blender/blender_sync.h +++ b/intern/cycles/blender/blender_sync.h @@ -61,6 +61,8 @@ class BlenderSync { Progress &progress); ~BlenderSync(); + void reset(BL::BlendData &b_data, BL::Scene &b_scene); + /* sync */ void sync_recalc(BL::Depsgraph &b_depsgraph, BL::SpaceView3D &b_v3d); void sync_data(BL::RenderSettings &b_render, From ff1040c6fefc4c54fef243635a915edf3f40355a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Thu, 28 May 2020 13:36:24 +0200 Subject: [PATCH 3/3] GPencil: Reduce aliasing for subpixel lines --- .../engines/gpencil/shaders/gpencil_common_lib.glsl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl index fb5073b3dc7..1e75f6dd5bb 100644 --- a/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl +++ b/source/blender/draw/engines/gpencil/shaders/gpencil_common_lib.glsl @@ -317,7 +317,7 @@ vec2 safe_normalize_len(vec2 v, out float len) } } -float stroke_thickness_modulate(float thickness) +float stroke_thickness_modulate(float thickness, out float opacity) { /* Modify stroke thickness by object and layer factors.-*/ thickness *= thicknessScale; @@ -333,6 +333,11 @@ float stroke_thickness_modulate(float thickness) /* World space point size. */ thickness *= thicknessWorldScale * ProjectionMatrix[1][1] * sizeViewport.y; } + /* To avoid aliasing artifact, we clamp the line thickness and reduce its opacity. */ + float min_thickness = gl_Position.w * 1.3; + opacity = smoothstep(0.0, gl_Position.w * 1.0, thickness); + thickness = max(min_thickness, thickness); + return thickness; } @@ -414,8 +419,9 @@ void stroke_vertex() vec2 line = safe_normalize_len(ss2 - ss1, line_len); vec2 line_adj = safe_normalize((use_curr) ? (ss1 - ss_adj) : (ss_adj - ss2)); + float small_line_opacity; float thickness = abs((use_curr) ? thickness1 : thickness2); - thickness = stroke_thickness_modulate(thickness); + thickness = stroke_thickness_modulate(thickness, small_line_opacity); finalUvs = vec2(x, y) * 0.5 + 0.5; strokeHardeness = decode_hardness(use_curr ? hardness1 : hardness2); @@ -505,7 +511,7 @@ void stroke_vertex() vec4 stroke_col = MATERIAL(m).stroke_color; float mix_tex = MATERIAL(m).stroke_texture_mix; - color_output(stroke_col, vert_col, vert_strength, mix_tex); + color_output(stroke_col, vert_col, vert_strength * small_line_opacity, mix_tex); matFlag = MATERIAL(m).flag & ~GP_FILL_FLAGS; # endif