Skip to content
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

Vulkan: SSR breaks with transparent materials #59512

Closed
PZerua opened this issue Mar 25, 2022 · 8 comments
Closed

Vulkan: SSR breaks with transparent materials #59512

PZerua opened this issue Mar 25, 2022 · 8 comments

Comments

@PZerua
Copy link
Contributor

PZerua commented Mar 25, 2022

Godot version

v4.0.alpha.custom_build [3990152]

System information

Windows 10, Nvidia GTX 970 (471.11), Vulkan

Issue description

When enabling SSR in a scene with transparent materials the render is completely broken:
ssr break

Taking a closer look, seems that it is related to how depth is managed when SSR is enabled in the merge_specular function here:

RD::DrawListID draw_list = RD::get_singleton()->draw_list_begin(p_dest_framebuffer, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_READ, RD::INITIAL_ACTION_KEEP, RD::FINAL_ACTION_DISCARD, Vector<Color>());

The final depth action is set to FINAL_ACTION_DISCARD, which at the end sets the flag VK_ATTACHMENT_STORE_OP_DONT_CARE in the attachment description. From the vulkan docs:

VK_ATTACHMENT_STORE_OP_DONT_CARE specifies the contents within the render area are not needed after rendering, and may be discarded.

Looking in renderdoc, the transparencies get rendered just after the effects, and the depth buffer seems to be reaching the "Render 3D Transparent Pass" in an undefined state.

Changing the final depth action to FINAL_ACTION_READ seems to fix the issue, but I'm not completely sure this is the proper solution and intended behavior.

Steps to reproduce

1 - Add a mesh and apply a material that has transparencies.
2 - Enable SSR in environment node.

Minimal reproduction project

Test SSR.zip

@Stratip
Copy link

Stratip commented Mar 25, 2022

I downloaded Test_SSR.zip and imported it with godot v4.0 alpha. It says the Main.tscn is corrupted and cannot be opened. I did download a straight-up binary from the mirror and everything seems to be very buggy and everything is clipping and stuff, maybe it will work if i compile it from source? I don't know, did you compile from source, or did you download just the executable like me?
Corrupted Main-Tscn

@PZerua
Copy link
Contributor Author

PZerua commented Mar 25, 2022

You are opening the project with Alpha 1 and some things have changed since then. Try again with the latest Alpha 5. If that doesn't work either try deleting the .godot folder.

@Calinou Calinou changed the title SSR breaks with transparent materials Vulkan: SSR breaks with transparent materials Mar 25, 2022
@Calinou Calinou added this to the 4.0 milestone Mar 25, 2022
@Stratip
Copy link

Stratip commented Mar 26, 2022

After opening it with godot 4.0 alpha 5 it does give me a warning before opening the scene that the scene has invalid/corrupt entities in it, but it opens anyways for some reason. Here after hitting F5 and previewing the scene the floor box seems to be glitching a lot with black lines. It seems to have to do with the resizing of my window because even if I don't move in the
Test SSR(DEBUG) the black lines change with the size of my window.
Window at full size:-
The scene is glitched

Window has been resized:-
Black lines have changed

Also, I don't seem to get any of those black speckles you got. Any idea why?

gpu : Intel Iris Plus Graphics 655
Supported vulkan extensions (which is probably unnecessary) :
VK_EXT_acquire_drm_display : extension revision 1
VK_EXT_acquire_xlib_display : extension revision 1
VK_EXT_debug_report : extension revision 10
VK_EXT_debug_utils : extension revision 2
VK_EXT_direct_mode_display : extension revision 1
VK_EXT_display_surface_counter : extension revision 1
VK_KHR_device_group_creation : extension revision 1
VK_KHR_display : extension revision 23
VK_KHR_external_fence_capabilities : extension revision 1
VK_KHR_external_memory_capabilities : extension revision 1
VK_KHR_external_semaphore_capabilities : extension revision 1
VK_KHR_get_display_properties2 : extension revision 1
VK_KHR_get_physical_device_properties2 : extension revision 2
VK_KHR_get_surface_capabilities2 : extension revision 1
VK_KHR_surface : extension revision 25
VK_KHR_surface_protected_capabilities : extension revision 1
VK_KHR_wayland_surface : extension revision 6
VK_KHR_xcb_surface : extension revision 6
VK_KHR_xlib_surface : extension revision 6

@lewiji
Copy link
Contributor

lewiji commented Mar 26, 2022

Possibly related: #59015

I included some videos there of a few different StandardMaterial3D settings that didn't really work with SSR/SDFGI, and one that does with a shader that manually discards alpha (but never sets the ALPHA built-in). That was for alpha backgrounds on textures, but not necessarily actual transparency/translucency in materials.

@PZerua
Copy link
Contributor Author

PZerua commented Mar 27, 2022

@ComputehGuy I'm not getting this invalid/corrupt warning, that's weird. Also for some reason in your image I can see the material doesn't have transparencies enabled, try setting transparency in the "Succulent" material to Depth-Pre Pass.

@PZerua
Copy link
Contributor Author

PZerua commented May 26, 2022

I have updated the minimal reproduction project link to Alpha 8 and I can confirm it's still happening. Looking at the code changes of the "Initial TAA implementation" (#61319), it seems like JFonS is changing the FINAL_ACTION_DISCARD to a FINAL_ACTION_READ here as I described in the issue, so problably it will be fixed after merging.

@PZerua
Copy link
Contributor Author

PZerua commented Jun 8, 2022

I can confirm it is fixed with #61319.

@PZerua PZerua closed this as completed Jun 8, 2022
@clayjohn
Copy link
Member

clayjohn commented Jun 8, 2022

Closed by: #61319

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants