diff options
author | JFonS <joan.fonssanchez@gmail.com> | 2021-07-20 15:17:34 -0300 |
---|---|---|
committer | jfons <joan.fonssanchez@gmail.com> | 2021-10-25 11:39:34 +0200 |
commit | c571e4a7f4a5cc34fa9b7efeff37ee69fcf6249d (patch) | |
tree | a4c2c52f3f5bc8f53526b91b04845496bec2b30b /scene/resources/material.cpp | |
parent | 88d9914519bd2016bd5181a7aa4c00f8063ad940 (diff) | |
download | redot-engine-c571e4a7f4a5cc34fa9b7efeff37ee69fcf6249d.tar.gz |
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 <reduzio@gmail.com>
Diffstat (limited to 'scene/resources/material.cpp')
-rw-r--r-- | scene/resources/material.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index abb3381c4e..3c7d73fef2 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -1086,7 +1086,7 @@ void BaseMaterial3D::_update_shader() { code += " ALPHA = 1.0;\n"; } else if (transparency != TRANSPARENCY_DISABLED || flags[FLAG_USE_SHADOW_TO_OPACITY] || (distance_fade == DISTANCE_FADE_PIXEL_ALPHA) || proximity_fade_enabled) { - code += " ALPHA = albedo.a * albedo_tex.a;\n"; + code += " ALPHA *= albedo.a * albedo_tex.a;\n"; } if (transparency == TRANSPARENCY_ALPHA_HASH) { code += " ALPHA_HASH_SCALE = alpha_hash_scale;\n"; |