-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement distance fade and transparency #54222
Conversation
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>
Is support for dithered fade still planned? I remember reduz talking about a way to set different material transparency modes, including one that would automatically replace alpha blending with dithering. This way, you can also use dithered transparency for traditional materials (even if they don't use LOD). For instance, having the following options in BaseMaterial3D as an enum:
The current implementation is useful, but I fear it'll run into issues with transparency sorting for objects that have multiple materials (or multiple overlapping objects with LOD). |
That sounds useful indeed. Right now, users can implement dithering themselves in a spatial shader by reading the It should be a matter of adding the "Dithering" option along the other transparency settings and then taking the code from godot/scene/resources/material.cpp Lines 1109 to 1150 in 24fdedf
Also, some care should be taken so that objects with dithered transparency go into the opaque render list instead of the transparent one. I'll add it to my backlog, but I have some other things to work on before this. If anyone wants to have a go, feel free :) |
servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp
Show resolved
Hide resolved
Thanks! |
Based on #50654, supersedes it.
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:transparency
property.visibility_range_fade_mode
property is set to "Self".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.
Quick HLOD fade example:
fade.mp4