Fullscreen shader

I am making a Full screen effect in URP, in the shader I am using the vertix world space to achieve this effect,


However with transparent objects, the effect fails, It seems as if the shader can’t read the transparent object pixels positions in world space, is there a way to fix that problem ?

It can’t read their position, because transparent objects usually don’t write to depth. Now I don’t have much experience with URP, I am not sure if it renders a separate depth texture with separate passes or it can use the depth buffer directly, but what you could do is to make sure that the depth of transparent objects is written, by giving the materials a separate pass that does only that, and render it either before or after the objects are rendered. The “before” method is also called depth pre-pass, and it’s used to make sure there are no overlapping transparent objects that might lead to flickering when an order of rendering for those objects changes.

But before you do it, think about the effects - you won’t be able to see the effect on the terrain / opaque objects that are behind the transparent objects. Normally you’d render such an effect as a fullscreen pass for opaque, and per-object for transparent ones. I can’t really tell you how to do it in URP, but perhaps a Projector might help. At least in default pipeline, a projector essentially just renders objects within its frustum with another material (and an extra projection matrix injected). So you could use such a projector to re-render your transparent objects and take the depth from their vertex shader.