Hide triplanar sharpness when triplanar is disabled in SpatialMaterial

The Triplanar Sharpness property has no effect when Triplanar
is disabled.
This commit is contained in:
Hugo Locurcio 2021-07-17 04:17:57 +02:00
parent 4d3c11e85e
commit c2e93a5e4d
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
2 changed files with 18 additions and 3 deletions

View file

@ -365,7 +365,7 @@
<member name="uv1_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false"> <member name="uv1_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false">
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. 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.
</member> </member>
<member name="uv1_triplanar_sharpness" type="float" setter="set_uv1_triplanar_blend_sharpness" getter="get_uv1_triplanar_blend_sharpness" default="1.0"> <member name="uv1_triplanar_sharpness" type="float" setter="set_uv1_triplanar_blend_sharpness" getter="get_uv1_triplanar_blend_sharpness">
A lower number blends the texture more softly while a higher number blends the texture more sharply. A lower number blends the texture more softly while a higher number blends the texture more sharply.
</member> </member>
<member name="uv2_offset" type="Vector3" setter="set_uv2_offset" getter="get_uv2_offset" default="Vector3( 0, 0, 0 )"> <member name="uv2_offset" type="Vector3" setter="set_uv2_offset" getter="get_uv2_offset" default="Vector3( 0, 0, 0 )">
@ -377,7 +377,7 @@
<member name="uv2_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false"> <member name="uv2_triplanar" type="bool" setter="set_flag" getter="get_flag" default="false">
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. 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.
</member> </member>
<member name="uv2_triplanar_sharpness" type="float" setter="set_uv2_triplanar_blend_sharpness" getter="get_uv2_triplanar_blend_sharpness" default="1.0"> <member name="uv2_triplanar_sharpness" type="float" setter="set_uv2_triplanar_blend_sharpness" getter="get_uv2_triplanar_blend_sharpness">
A lower number blends the texture more softly while a higher number blends the texture more sharply. A lower number blends the texture more softly while a higher number blends the texture more sharply.
</member> </member>
<member name="vertex_color_is_srgb" type="bool" setter="set_flag" getter="get_flag" default="false"> <member name="vertex_color_is_srgb" type="bool" setter="set_flag" getter="get_flag" default="false">

View file

@ -1322,9 +1322,16 @@ void SpatialMaterial::set_flag(Flags p_flag, bool p_enabled) {
} }
flags[p_flag] = 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(); _change_notify();
} }
_queue_shader_change(); _queue_shader_change();
} }
@ -1420,6 +1427,14 @@ void SpatialMaterial::_validate_property(PropertyInfo &property) const {
property.usage = 0; 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]) { if (property.name == "params_alpha_scissor_threshold" && !flags[FLAG_USE_ALPHA_SCISSOR]) {
property.usage = 0; property.usage = 0;
} }