Repository: godot
Issue: Vulkan: Transparency pipeline has z-order issues
Labels: bug,topic:rendering,regression,topic:3d

### Godot version

4.0alpha13

### System information

Win 10/64 NVIDIA GeForce GTX 1060/PCIe/SSE2

### Issue description

Summary of sub issues:
* Proximity fade has broken z-ordering
* Proximity fade has no shadows #61730
* Alpha has broken z-ordering and is overly transparent farther away
* Alpha depth prepass is overly transparent which makes it appear that there are  z-ordering issues. Unknown if there's actual  z-ordering inaccuracy
* AlphaHash is just noisy with strange artifacts when drawn against the sky. 

Alpha scissoring  z-ordering works fine, as documented in #56008. But is not desirable on certain assets like pine trees as looks bad far away. 

## Proximity Fade
Here is proximity fade on an otherwise opaque object. Has no problem w/ z-ordering in GD3. All the normals are messed up but that's noted in #63550. Both sides in GD4.

![image](https://user-images.githubusercontent.com/632766/181740396-b0a7590d-2e80-4e25-91b8-56328db8d1b8.png)


## Alpha options
On my transparent foliage, I compared the alpha options. 

### Alpha Scissors
This has proper z-ordering, however it's a low quality alpha. It looks fine close up, but it's ugly from a distance. Compare GD4 alpha scissors up close, far, vs true Alpha in GD3.

![image](https://user-images.githubusercontent.com/632766/181908919-d684cb05-da51-47a9-836b-2ae1e8db39a3.png)

### Alpha
Alpha has potential. I would use it if these two issues were fixed. Also notice no shadows documented in #61730.

1. It's too transparent. You can see the grid right through it. Compare with gd3 alpha above. The pine needles look like a ghost tree.

![image](https://user-images.githubusercontent.com/632766/181908934-4d046327-1fb4-4fd6-9715-630eb4912c9b.png)

2. Some faces have the incorrect z-order, showing transparent objects that are behind it, in front. Look at the grid showing through the bottom of the image, too transparent. Another alpha z-order example is coming up below in the depthprepass section, and see the video at the bottom for more egregious examples.

![image](https://user-images.githubusercontent.com/632766/181909026-79788755-46cc-436f-a580-48708addfa5e.png)

### AlphaHash
It's noisy, and has issues with some faces turning very light against the sky. It does not appear to have z-order issues, but I don't know what I'd use this for.

![image](https://user-images.githubusercontent.com/632766/181909071-3c875e15-b289-4c0d-9086-850d90ee8ce9.png)

![image](https://user-images.githubusercontent.com/632766/181909111-466486cc-70aa-4055-9c55-5d581f5bd9f9.png)


### DepthPrePass
There are issues with having too much transparency at times, and z-order at others.  All those light green branches shouldn't be visible here:

![image](https://user-images.githubusercontent.com/632766/181909176-fd6de9ed-6418-4157-9106-f3b66a3c8abe.png)

Compare with alpha scissors
![image](https://user-images.githubusercontent.com/632766/181909206-6a653499-3bbe-467f-b1dc-bfe475480dc9.png)

Overall it doesn't look good. Alpha depth pre pass also didn't look great in GD3, but it was better than alpha or depthprepass in GD4. On the left in GD4, you can see the behind light branches popping in front of the dark front branches. On the right in GD3, you can see the low quality alpha on many of the foreground branches. The alpha really gets chopped up when layered. However the z-order is reasonable. Even in motion, I don't see any background parts obviously rendering in front.

![image](https://user-images.githubusercontent.com/632766/181909581-ced065dd-dbae-42ac-b896-7aeb053efd46.png)


### Video

Z-ordering is difficult to see in pictures, so here is video:
https://youtu.be/4_GBr-Pzmk8




### Steps to reproduce

n/a

### Minimal reproduction project
[test_zorder.zip](https://github.com/godotengine/godot/files/10256553/test_zorder.zip)

updated 12/19/22