From 089135783e143549ca72cf94dfdc45203616cf49 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sat, 17 Jul 2021 04:17:57 +0200 Subject: [PATCH] Hide triplanar sharpness when triplanar is disabled in SpatialMaterial The Triplanar Sharpness property has no effect when Triplanar is disabled. --- doc/classes/SpatialMaterial.xml | 4 ++-- scene/resources/material.cpp | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/doc/classes/SpatialMaterial.xml b/doc/classes/SpatialMaterial.xml index c54bb561f..f283618c7 100644 --- a/doc/classes/SpatialMaterial.xml +++ b/doc/classes/SpatialMaterial.xml @@ -364,7 +364,7 @@ If [code]true[/code], instead of using [code]UV[/code] textures will use a triplanar texture lookup to determine how to apply textures. Triplanar uses the orientation of the object's surface to blend between texture coordinates. It reads from the source texture 3 times, once for each axis and then blends between the results based on how closely the pixel aligns with each axis. This is often used for natural features to get a realistic blend of materials. Because triplanar texturing requires many more texture reads per-pixel it is much slower than normal UV texturing. Additionally, because it is blending the texture between the three axes, it is unsuitable when you are trying to achieve crisp texturing. - + A lower number blends the texture more softly while a higher number blends the texture more sharply. @@ -376,7 +376,7 @@ If [code]true[/code], instead of using [code]UV2[/code] textures will use a triplanar texture lookup to determine how to apply textures. Triplanar uses the orientation of the object's surface to blend between texture coordinates. It reads from the source texture 3 times, once for each axis and then blends between the results based on how closely the pixel aligns with each axis. This is often used for natural features to get a realistic blend of materials. Because triplanar texturing requires many more texture reads per-pixel it is much slower than normal UV texturing. Additionally, because it is blending the texture between the three axes, it is unsuitable when you are trying to achieve crisp texturing. - + A lower number blends the texture more softly while a higher number blends the texture more sharply. diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 3a72f693f..120933e4b 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1339,9 +1339,16 @@ void SpatialMaterial::set_flag(Flags p_flag, bool p_enabled) { } flags[p_flag] = p_enabled; - if ((p_flag == FLAG_USE_ALPHA_SCISSOR) || (p_flag == FLAG_UNSHADED) || (p_flag == FLAG_USE_SHADOW_TO_OPACITY)) { + + if ( + p_flag == FLAG_USE_ALPHA_SCISSOR || + p_flag == FLAG_UNSHADED || + p_flag == FLAG_USE_SHADOW_TO_OPACITY || + p_flag == FLAG_UV1_USE_TRIPLANAR || + p_flag == FLAG_UV2_USE_TRIPLANAR) { _change_notify(); } + _queue_shader_change(); } @@ -1434,6 +1441,14 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const { property.usage = 0; } + if (property.name == "uv1_triplanar_sharpness" && !flags[FLAG_UV1_USE_TRIPLANAR]) { + property.usage = 0; + } + + if (property.name == "uv2_triplanar_sharpness" && !flags[FLAG_UV2_USE_TRIPLANAR]) { + property.usage = 0; + } + if (property.name == "params_alpha_scissor_threshold" && !flags[FLAG_USE_ALPHA_SCISSOR]) { property.usage = 0; }