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

Add disable_alpha render mode to shaders #51711

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Calinou
Copy link
Member

@Calinou Calinou commented Aug 16, 2021

master version of #51844. Follow-up to #51709.

This can be used by multipass shaders to write to a texture's alpha channel without causing the material to become transparent.

Testing project: test_shader_disable_alpha_master.zip

Preview

Default render mode

Default render mode

disable_alpha render mode

disable_alpha render mode

This can be used by multipass shaders to write to a texture's
alpha channel without causing the material to become transparent.
@clayjohn
Copy link
Member

I'm not sure I understand the use case for this. What effect does this setting allow you to achieve that you could not otherwise?

@Calinou
Copy link
Member Author

Calinou commented Aug 16, 2021

I'm not sure I understand the use case for this. What effect does this setting allow you to achieve that you could not otherwise?

The use case is described in godotengine/godot-proposals#2935.

@Lauson1ex
Copy link
Contributor

I'm not sure I understand the use case for this. What effect does this setting allow you to achieve that you could not otherwise?

@clayjohn It's to store and transfer data between render targets. I'll give you one real world use case applied on the Godot engine itself: on Godot 4.0's bokeh DOF shader, the size of the circle of confusion is stored on the alpha component, and accessed by later passes of the shader. On Material Maker, they have to store depth in a separate buffer first, and then color on a second pass, essentially rendering the screen twice always. With this, they could just store depth on the alpha component, everything in a single pass. Having 4 components is so useful.

@Lauson1ex
Copy link
Contributor

@Calinou Although disable_alpha is indeed preventing the geometry from going through the transparent pipeline, it seems that ALPHA is not being written to the render target. Trying to retrieve alpha from the render target yields 1.0 always. Even when transparent_bg is enabled. I've attached a sample project.
image
image
disable_alpha_test.zip

@Calinou
Copy link
Member Author

Calinou commented Aug 18, 2021

Trying to retrieve alpha from the render target yields 1.0 always. Even when transparent_bg is enabled. I've attached a sample project.

transparent_bg is not reimplemented yet in Vulkan. I'd try the 3.x version of this PR.

@Lauson1ex
Copy link
Contributor

Trying to retrieve alpha from the render target yields 1.0 always. Even when transparent_bg is enabled. I've attached a sample project.

transparent_bg is not reimplemented yet in Vulkan. I'd try the 3.x version of this PR.

Okay. Thank you. I'll be right into it 🙂

@Lauson1ex
Copy link
Contributor

Lauson1ex commented Aug 18, 2021

I'd try the 3.x version of this PR.

@Calinou I'm afraid I didn't find a 3.x version of this PR. #51708 doesn't feature disable_alpha, so I couldn't test it there.

@Calinou
Copy link
Member Author

Calinou commented Aug 18, 2021

@Calinou I'm afraid I didn't find a 3.x version of this PR. #51708 doesn't feature disable_alpha, so I couldn't test it there.

I forgot to open a pull request for it. Here it is: #51844

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

Successfully merging this pull request may close these issues.

4 participants