godotengine / godotengine/godot

BaseMaterial3D Shadow to Opacity does not work as expected with transparency modes other than Alpha

Open
#95,602 1 comment 2 reactions 0 assignees View on GitHub
bug topic:3d topic:rendering
Dominant language
C++
Stars
117k
Forks
26.8k
PR merge metrics
PR metrics pending

Description

- *Related to https://github.com/godotengine/godot/issues/91496.*

### Tested versions

- Reproducible in: 4.3.rc 4359c28fe

### System information

Godot v4.3.rc (4359c28fe) - Fedora Linux 40 (KDE Plasma) - X11 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 4090 (nvidia; 555.58.02) - 13th Gen Intel(R) Core(TM) i9-13900K (32 Threads)

### Issue description

BaseMaterial3D Shadow to Opacity does not work as expected with transparency modes other than Alpha.

I would expect the shadow opacity to affect the alpha scissor threshold (and ideally not force alpha transparency if alpha scissor transparency is chosen, so you can avoid transparency sorting issues inherent to alpha transparency).

The same goes for alpha hash, although I don't expect this one to be needed as often in this scenario.

I've only tested this in Forward+ so far, so I don't know if this applies to Mobile or Compatibility.

### Transparency = Alpha (or Disabled, as alpha is forced here)

![image](https://github.com/user-attachments/assets/4ba929c0-1524-454d-aa80-60f5e5bae604)

### Transparency = Alpha Scissor

*I would expect this mode to look like Alpha, but with a hard edge.*

![image](https://github.com/user-attachments/assets/d747d633-e2f1-437d-ba68-d2f7898e56ae)

### Transparency = Alpha Hash

*I would expect this mode to look like Alpha, but with dithered edges.*

![image](https://github.com/user-attachments/assets/75bf49fa-c8fc-42a1-a816-dcdb4201f58b)

### Transparency = Depth Prepass

*I would expect this mode to look like Alpha, but with fully opaque areas being drawn as opaque to reduce the visibility of transparency sorting issues.*

![image](https://github.com/user-attachments/assets/a226a1b1-392f-4e85-b4cd-d27cdd283771)

With an alpha albedo texture applied:

### Transparency = Alpha

![image](https://github.com/user-attachments/assets/e9759bfe-bbee-41a1-b6b4-f7a3b121742e)

### Transparency = Alpha Scissor (threshold = 0.2)

![image](https://github.com/user-attachments/assets/0528f232-8bb5-45c0-9175-e6317513df8c)

### Transparency = Alpha Hash

![image](https://github.com/user-attachments/assets/69a351e3-f483-4891-b238-41ed4daee8a4)

### Transparency = Depth Prepass

![image](https://github.com/user-attachments/assets/58244c66-1e15-45ae-a54e-0da3e67738b1)

### Steps to reproduce

- Add a DirectionalLight3D node with shadows enabled.
- Add a MeshInstance3D with a BoxMesh (to use as a shadow caster).
- Add a second MeshInstance3D with a PlaneMesh (to use as a shadow receiver). Add a StandardMaterial3D to it, enable **Shadow to Opacity.** In this mode, opacity is determined by how much shadow is received (fully shaded areas are opaque).
- Change the plane's material transparency mode to **Alpha Scissor**, **Alpha Hash** or **Opaque Prepass*, and notice the transparency no longer working as expected.

### Minimal reproduction project (MRP)

[Non-Overlapping Transprancy 2.zip](https://github.com/user-attachments/files/16627725/Non-Overlapping.Transprancy.2.zip)

Contributor guide

Open the contributing guide

Research direction

Start with the attached Minimal Reproduction Project and reproduce the issue in Godot 4.3.rc using Forward+. Trace how BaseMaterial3D handles Shadow to Opacity with Alpha Scissor, Alpha Hash, and Depth Prepass; done means those modes preserve the expected shadow-driven opacity behavior without unexpectedly forcing Alpha transparency.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
computer-graphics, game-dev
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.