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

OpenGL: Blend modes other than Mix don't work unless Depth Draw Mode is set to Never #76334

Closed
Tracked by #66458
decacis opened this issue Apr 22, 2023 · 3 comments · Fixed by #77409
Closed
Tracked by #66458

OpenGL: Blend modes other than Mix don't work unless Depth Draw Mode is set to Never #76334

decacis opened this issue Apr 22, 2023 · 3 comments · Fixed by #77409

Comments

@decacis
Copy link
Contributor

decacis commented Apr 22, 2023

Godot version

v4.1.dev1.official [db13026]

System information

Windows 10, Compatibility, NVIDIA GeForce GTX 1050 Ti (528.24)

Issue description

Setting the blend mode to something besides mix behaves the same as mix. This is the same whether is a ShaderMaterial or a StandarMaterial3D.

Blend-Add

I think this should have been fixed by #75968 unless I misunderstood the PR, and it does seem to be included in this version (4.1 dev1). It does work if you set the Depth Draw Mode to Never though.

Steps to reproduce

  • Add a MeshInstance3D with a mesh of any type
  • Add a StandarMaterial3D
  • Set the blend mode to add (or any other than mix)
  • It won't work unless you set the depth draw mode to Never

Minimal reproduction project

BlendAdd.zip

@clayjohn
Copy link
Member

Tagged as "good first issue" for clarity, this is a good first issue for someone with a little bit of OpenGL experience

@Calinou Calinou changed the title Blend mode besides mix doesn't work in GL Compatibility renderer (3D) OpenGL: Blend mode besides mix doesn't work unless Depth Draw Mode is set to Never Apr 27, 2023
@Calinou Calinou changed the title OpenGL: Blend mode besides mix doesn't work unless Depth Draw Mode is set to Never OpenGL: Blend modes other than Mix don't work unless Depth Draw Mode is set to Never Apr 27, 2023
@allenwp
Copy link
Contributor

allenwp commented May 23, 2023

This is a good first issue :) I was able to determine the problem by comparing the OpenGL renderer with the forward mobile and forward clustered renderers. It seems that the following was omitted in OpenGL's set_code(const String &p_code) function for BLEND_MODE_ADD, BLEND_MODE_SUB, and BLEND_MODE_MUL:

uses_blend_alpha = true; //force alpha used because of blend

I'll have a PR to fix this issue soon, but will need to go over the contribution guidelines first.

@allenwp
Copy link
Contributor

allenwp commented May 23, 2023

I have noticed that the OpenGL Subtract blend mode doesn't work no matter what other draw modes are selected. This appears to be because it was using GL_FUNC_REVERSE_SUBTRACT instead of GL_FUNC_SUBTRACT. I will include this fix in my PR as well to address all of the "Blend modes other than Mix don't work" cases.

The OpenGL renderer has always used GL_FUNC_REVERSE_SUBTRACT, but it looks like the other new renderers in Godot 4 use BLEND_OP_SUBTRACT instead of BLEND_OP_REVERSE_SUBTRACT. I'll open a different issue to discuss this inconsistency between renderers.

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

Successfully merging a pull request may close this issue.

4 participants