From c571e4a7f4a5cc34fa9b7efeff37ee69fcf6249d Mon Sep 17 00:00:00 2001 From: JFonS Date: Tue, 20 Jul 2021 15:17:34 -0300 Subject: Implement distance fade and transparency The built-in ALPHA in spatial shaders comes pre-set with a per-instance transparency value. Multiply by it if you want to keep it. The transparency value of any given GeometryInstance3D is affected by: - Its new "transparency" property. - Its own visiblity range when the new "visibility_range_fade_mode" property is set to "Self". - Its parent visibility range when the parent's fade mode is set to "Dependencies". The "Self" mode will fade-out the instance when reaching the visibility range limits, while the "Dependencies" mode will fade-in its dependencies. Per-instance transparency is only implemented in the forward clustered renderer, support for mobile should be added in the future. Co-authored-by: reduz --- doc/classes/GeometryInstance3D.xml | 17 ++++++++++++++++- doc/classes/RenderingServer.xml | 18 ++++++++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) (limited to 'doc/classes') diff --git a/doc/classes/GeometryInstance3D.xml b/doc/classes/GeometryInstance3D.xml index 97cef205c3..0a2c0fbe81 100644 --- a/doc/classes/GeometryInstance3D.xml +++ b/doc/classes/GeometryInstance3D.xml @@ -49,6 +49,9 @@ The material override for the whole geometry. If a material is assigned to this property, it will be used instead of any material set in any material slot of the mesh. + + Transparency applied to the whole geometry. In spatial shaders, transparency is set as the default value of the [code]ALPHA[/code] built-in. + Starting distance from which the GeometryInstance3D will be visible, taking [member visibility_range_begin_margin] into account as well. The default value of 0 is used to disable the range check. @@ -56,11 +59,14 @@ Margin for the [member visibility_range_begin] threshold. The GeometryInstance3D will only change its visibility state when it goes over or under the [member visibility_range_begin] threshold by this amount. - Distance from which the GeometryInstance3D will be hidden, taking [member visibility_range_end_margin] into account as well. The default value of 0 is used to disable the range check.. + Distance from which the GeometryInstance3D will be hidden, taking [member visibility_range_end_margin] into account as well. The default value of 0 is used to disable the range check. Margin for the [member visibility_range_end] threshold. The GeometryInstance3D will only change its visibility state when it goes over or under the [member visibility_range_end] threshold by this amount. + + Controls which instances will be faded when approaching the limits of the visibility range. See [enum VisibilityRangeFadeMode] for possible values. + @@ -94,5 +100,14 @@ + + Will not fade itself nor its visibility dependencies, hysteresis will be used instead. See [member visibility_range_begin] and [member Node3D.visibility_parent] for more information. + + + Will fade-out itself when reaching the limits of its own visibility range. The fading range is determined by [member visibility_range_begin_margin] and [member visibility_range_end_margin]. + + + Will fade-in its visibility dependencies (see [member Node3D.visibility_parent]) when reaching the limits of its own visibility range. The fading range is determined by [member visibility_range_begin_margin] and [member visibility_range_end_margin]. + diff --git a/doc/classes/RenderingServer.xml b/doc/classes/RenderingServer.xml index 973f8cdb1e..b53233add5 100644 --- a/doc/classes/RenderingServer.xml +++ b/doc/classes/RenderingServer.xml @@ -1377,6 +1377,14 @@ + + + + + + Sets the transparency for the given geometry instance. Equivalent to [member GeometryInstance3D.transparency]. + + @@ -1384,6 +1392,7 @@ + Sets the visibility range values for the given geometry instance. Equivalent to [member GeometryInstance3D.visibility_range_begin] and related properties. @@ -4178,6 +4187,15 @@ Only render the shadows from the object. The object itself will not be drawn. + + Disable visibility range fading for the given instance. + + + Fade-out the given instance when it approaches its visibility range limits. + + + Fade-in the given instance's dependencies when reaching its visibility range limits. + -- cgit v1.2.3