diff options
author | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-02-27 18:56:19 +0100 |
---|---|---|
committer | Hugo Locurcio <hugo.locurcio@hugo.pro> | 2022-02-27 18:56:19 +0100 |
commit | 81940c8e57c16c87787f2750364677acdd8d2bf9 (patch) | |
tree | cf992ada0dfebe103d614d870e1f911b558d8fe9 /scene | |
parent | ff877adf0f6a9f2073e95d6fd6c59515b9e90cd2 (diff) |
Clamp BaseMaterial3D triplanar sharpness to values that never look broken
Diffstat (limited to 'scene')
-rw-r--r-- | scene/resources/material.cpp | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 6fb0c0468d..2c061f5dee 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1873,8 +1873,9 @@ Vector3 BaseMaterial3D::get_uv1_offset() const { } void BaseMaterial3D::set_uv1_triplanar_blend_sharpness(float p_sharpness) { - uv1_triplanar_sharpness = p_sharpness; - RS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_blend_sharpness, p_sharpness); + // Negative values or values higher than 150 can result in NaNs, leading to broken rendering. + uv1_triplanar_sharpness = CLAMP(p_sharpness, 0.0, 150.0); + RS::get_singleton()->material_set_param(_get_material(), shader_names->uv1_blend_sharpness, uv1_triplanar_sharpness); } float BaseMaterial3D::get_uv1_triplanar_blend_sharpness() const { @@ -1900,8 +1901,9 @@ Vector3 BaseMaterial3D::get_uv2_offset() const { } void BaseMaterial3D::set_uv2_triplanar_blend_sharpness(float p_sharpness) { - uv2_triplanar_sharpness = p_sharpness; - RS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_blend_sharpness, p_sharpness); + // Negative values or values higher than 150 can result in NaNs, leading to broken rendering. + uv2_triplanar_sharpness = CLAMP(p_sharpness, 0.0, 150.0); + RS::get_singleton()->material_set_param(_get_material(), shader_names->uv2_blend_sharpness, uv2_triplanar_sharpness); } float BaseMaterial3D::get_uv2_triplanar_blend_sharpness() const { |