From c2e93a5e4d09e9244d2a2f1995c843c4c188187a 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 ff3deb82fa5..33da572d972 100644 --- a/doc/classes/SpatialMaterial.xml +++ b/doc/classes/SpatialMaterial.xml @@ -365,7 +365,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. @@ -377,7 +377,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 b9495cdf150..123d07bc7d9 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1322,9 +1322,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(); } @@ -1420,6 +1427,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; }