diff options
3 files changed, 15 insertions, 3 deletions
diff --git a/source/blender/blenkernel/intern/mesh_convert.c b/source/blender/blenkernel/intern/mesh_convert.c index a4ad4e1096e..1ec3b6a1cbf 100644 --- a/source/blender/blenkernel/intern/mesh_convert.c +++ b/source/blender/blenkernel/intern/mesh_convert.c @@ -1065,6 +1065,7 @@ static void curve_to_mesh_eval_ensure(Object *object) Curve *curve = (Curve *)object->data; Curve remapped_curve = *curve; Object remapped_object = *object; + remapped_object.runtime.bb = NULL; remapped_object.data = &remapped_curve; /* Clear all modifiers for the bevel object. @@ -1077,6 +1078,7 @@ static void curve_to_mesh_eval_ensure(Object *object) Object bevel_object = {{NULL}}; if (remapped_curve.bevobj != NULL) { bevel_object = *remapped_curve.bevobj; + bevel_object.runtime.bb = NULL; BLI_listbase_clear(&bevel_object.modifiers); remapped_curve.bevobj = &bevel_object; } @@ -1085,6 +1087,7 @@ static void curve_to_mesh_eval_ensure(Object *object) Object taper_object = {{NULL}}; if (remapped_curve.taperobj != NULL) { taper_object = *remapped_curve.taperobj; + taper_object.runtime.bb = NULL; BLI_listbase_clear(&taper_object.modifiers); remapped_curve.taperobj = &taper_object; } @@ -1107,6 +1110,10 @@ static void curve_to_mesh_eval_ensure(Object *object) BKE_object_eval_assign_data(&remapped_object, &mesh_eval->id, true); } + MEM_SAFE_FREE(remapped_object.runtime.bb); + MEM_SAFE_FREE(taper_object.runtime.bb); + MEM_SAFE_FREE(bevel_object.runtime.bb); + BKE_object_free_curve_cache(&bevel_object); BKE_object_free_curve_cache(&taper_object); } diff --git a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl index bf5b63cba65..cdc453eed40 100644 --- a/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl +++ b/source/blender/draw/engines/eevee/shaders/ambient_occlusion_lib.glsl @@ -210,14 +210,14 @@ void occlusion_eval(OcclusionData data, bool early_out = (inverted != 0.0) ? (max_v4(abs(data.horizons)) == 0.0) : (min_v4(abs(data.horizons)) == M_PI); if (early_out) { - visibility = dot(N, Ng) * 0.5 + 0.5; + visibility = saturate(dot(N, Ng) * 0.5 + 0.5); visibility = min(visibility, data.custom_occlusion); if ((int(aoSettings) & USE_BENT_NORMAL) == 0) { bent_normal = N; } else { - bent_normal = normalize(N + Ng); + bent_normal = safe_normalize(N + Ng); } return; } @@ -283,7 +283,9 @@ void occlusion_eval(OcclusionData data, bent_normal = N; } else { - bent_normal = normalize(mix(bent_normal, N, sqr(sqr(sqr(visibility))))); + /* Note: using pow(visibility, 6.0) produces NaN (see T87369). */ + float tmp = saturate(pow6(visibility)); + bent_normal = normalize(mix(bent_normal, N, tmp)); } } diff --git a/source/blender/draw/intern/shaders/common_math_lib.glsl b/source/blender/draw/intern/shaders/common_math_lib.glsl index 378f27056fa..33deae0b0a1 100644 --- a/source/blender/draw/intern/shaders/common_math_lib.glsl +++ b/source/blender/draw/intern/shaders/common_math_lib.glsl @@ -91,6 +91,9 @@ vec2 sqr(vec2 a) { return a * a; } vec3 sqr(vec3 a) { return a * a; } vec4 sqr(vec4 a) { return a * a; } +/* Use manual powers for fixed powers. pow() can have unpredicatble results on some implementations. + * (see T87369, T87541) */ +float pow6(float x) { return sqr(sqr(x) * x); } float pow8(float x) { return sqr(sqr(sqr(x))); } float len_squared(vec3 a) { return dot(a, a); } |