Open jianliang-li opened 3 months ago
This is expected, as setting ALPHA
anywhere in the shader will force the material to go through the transparent pipeline. This is the case even if you only use ALPHA = 1.0
.
I don't think we should have a special case for ALPHA = 1.0
not making the material go through the transparent pipeline. Could you describe why you want to write to ALPHA
in the first place? Perhaps you can achieve the desired effect another way.
I had a similar problem, when using depth_draw_always, ALPHA=0.9 or less resulted in depth not being written, but ALPHA=0.99 did. (engine version 4.3.dev)
(a sphere in the scene, screen shows the view depth)
@Khasehemwy what you are seeing is a different issue from the OP.
In your case you are seeing a few different things:
depth_prepass_alpha
is being used, the object is rendered in the depth prepass. However, the depth prepass will only write out the depth for objects that have an alpha higher than 0.99
. Accordingly, nothing is written in the depth prepass.depth_draw_always
is enabled, the depth is written during the transparent pass. You don't see the results in the depth texture, because the depth texture was copied before the transparent pass@clayjohn Thank you! I found the changes needed to make the depth pre pass work for transparent objects. But does that mean there is no way to get the depth of a transparent object by depth texture in official version?
@clayjohn Thank you! I found the changes needed to make the depth pre pass work for transparent objects. But does that mean there is no way to get the depth of a transparent object by depth texture in official version?
When using hint_depth_texture
that is correct. You can however get the depth texture after rendering transparent objects using a CompositorEffect in 4.3
Tested versions
4.0.4, 4.2, 3.5
System information
macOS 14.4 (23E214) Godot 4.2, 4.0.4
Issue description
Setting ALPHA=1.0 in the shader script still has a transparent effect, just like setting the transparency of StandardMaterial3D to alpha or setting no depth test. But if the rendering mode of the shadow script adds depth_draw-always, setting ALPHA=1.0 can display normally, but it cannot produce shadow effects.
Steps to reproduce
In the project I uploaded: In the scene of node_3d_desk, the shader script has set ALPHA=1.0 and I do not want to see the tripod of the table.
Desk_normal has added StandardMaterial3D to the surfaceMaterialOverlay of Box024 without any changes.![image](https://github.com/godotengine/godot/assets/134466716/46fd56d4-f499-4d5c-8d5c-6eba38e4fe75)
Desk_alpha added StandardMaterial3D to the SurfaceMaterialOverrides of Box024 and changed transparency to alpha.![image](https://github.com/godotengine/godot/assets/134466716/9a0218cf-4f96-4b16-93a9-2651a5f47707)
Desk_no_depth_test has been added to StandardMaterial3D and transparency has been changed to no_depth_test in the surface MaterialOverrides of Box 024.![image](https://github.com/godotengine/godot/assets/134466716/6f55740e-9832-486f-b1d4-2222ad679262)
Desk_shaded_alpha added ShaderMaterial in the surfaceMaterialOverride of Box024, with only ALPHA=1.0 set in the script.![image](https://github.com/godotengine/godot/assets/134466716/ac4aa990-57a8-406f-969d-bbcb09fb5977)
In the scene of node_3d_sofa, there is also a similar problem. This problem occurs whenever the mesh has an irregular shape.
![image](https://github.com/godotengine/godot/assets/134466716/88603f19-48e4-4fbf-ba7c-ca48f1be1477)
How can I set ALPHA=1.0 in the shader without expecting transparency or no_depth_test effects, and still display shadows normally.
When I add render_mode depth_draw_always in the shader script, it can display normally, but it cannot display shadows properly. If the following image is displayed: Shadow display in normal mode:
Display shadows after setting ALPHA=1.0 and adding render_mode depth_draw_always:
![image](https://github.com/godotengine/godot/assets/134466716/fa3a13af-2567-4de0-bfdf-0eaa15812021)
Minimal reproduction project (MRP)
Test0520.zip