Postprocessing with depth pass and transparent objects
Asked Answered
P

10

0

Hey

I'm trying to create a custom post process on top of everything (including transparent objects) that requires the depth pass. I've tried using the screen-reading technique (https://docs.godotengine.org/en/3.1/tutorials/shading/advanced_postprocessing.html) but SCREEN_TEXTURE grabs the screen before transparent objects are being drawn :( What would be the best way of doing this without rendering twice the scene ?

Thank you in advance !

Prism answered 24/3, 2020 at 17:50 Comment(0)
W
0

Make sure the transparent objects are using depth draw alpha pre-pass: https://docs.godotengine.org/en/stable/tutorials/3d/spatial_material.html#depth-draw-mode

edit: or maybe it should be always, one of those I think.

Wisner answered 24/3, 2020 at 19:46 Comment(0)
P
0

Hum thanks it's half-resolving my issue as I now see my object, however the Albedo does not show anymore at some point when I'm rotating my camera, this is quite strange. Here is my transparent shader header, and I simply write to the ALPHA and ALBEDO in the frag.

shader_type spatial;
render_mode unshaded, depth_draw_alpha_prepass;
Prism answered 24/3, 2020 at 20:50 Comment(0)
W
0

Might some of your models normals be inverted? Might have to adjust the cull mode.

Wisner answered 25/3, 2020 at 6:52 Comment(0)
P
0

My normals and cull are fine... :(

Prism answered 25/3, 2020 at 8:42 Comment(0)
R
0

This is simply a limitation of SCREEN_TEXTURE. It will only have opaque objects rendered in it. The reason why it shows as black might be because the depth was generated in a pre-pass, but no color information because transparent objects don't get rendered in it.

Rayerayfield answered 25/3, 2020 at 14:14 Comment(0)
P
0

Ok, sorry to bother you with my question. Assuming the fact that I want to use Viewports and no "hacky quad post process technique"; how could I setup a 2 pass shader using depth. Let me explain in details:

I need to blur an object in the scene, but only one large object and this specific object intersects with others. So in the end I need depth information and two post process shaders. How can I do that properly in godot ? Thanks in advance !

Prism answered 1/4, 2020 at 9:55 Comment(0)
F
0

Have you solved this? I'm having the same problem.

Forever answered 25/5, 2020 at 14:56 Comment(0)
L
0

You could do it with a 2D shader, but I don't think the depth buffer can be accessed then.

Lynsey answered 26/5, 2020 at 15:43 Comment(0)
W
0

@Dschoonmaker said: You could do it with a 2D shader, but I don't think the depth buffer can be accessed then.

@SIsilicon28 was/is working on giving access to buffers via viewport texture.

Wisner answered 26/5, 2020 at 16:37 Comment(0)
S
0

My solution to this (I'm using screen reading shader to create a blur effect at speed) was to fake the transparency with dithering - you can either find a shader that does it on the Godot subreddit or check the Spatial Material Distance Fade dither after converting it to a shader.

Shellacking answered 27/9, 2021 at 9:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.