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>
This commit is contained in:
@@ -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";
|
||||
|
||||
Reference in New Issue
Block a user