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 support for depth function in spatial materials and/or shaders (GL_GREATER, …) #1298

Open
huhund opened this issue Aug 3, 2020 · 4 comments · May be fixed by godotengine/godot#73527

Comments

@huhund
Copy link

huhund commented Aug 3, 2020

Describe the project you are working on:
A 3D 3rd person game.

Describe the problem or limitation you are having in your project:
There is no way to change the depth test function for shaders or materials. It's is not possible to change the glDepthFunc() from the default GL_LEQUAL to GL_GREATER

Describe the feature / enhancement and how it helps to overcome the problem or limitation:
A lot of effects needs to change depth function. E.g. when Super Mario is behind an object you will see him rendered as a gray silhouette. This can easily be achieved with rendering the object in two passes, where the silhouette pass is rendered with GL_GREATER.

Describe how your proposal will work, with code, pseudocode, mockups, and/or diagrams:

  1. A drop down selection, right next the "no depth test" flag in the material settings.
  2. A "depth_mode" setting in the shader, similar to the "render_mode" setting.

If this enhancement will not be used often, can it be worked around with a few lines of script?:
It can only be implemented in the core renderer.

Is there a reason why this should be core and not an add-on in the asset library?:
It can only be implemented in the core renderer.

@clayjohn
Copy link
Member

clayjohn commented Aug 3, 2020

Setting depth function to greater would have the same impact as just disabling the depth test in that case wouldn't it? In which case it would be equivalent to disabling depth with the no_depth_test flag in SpatialMaterials.

@Calinou
Copy link
Member

Calinou commented Aug 3, 2020

@clayjohn If I understand correctly, the difference is that with GL_GREATER, the material is rendered only if it's occluded. It will be invisible if it's not occluded by anything.

You could render the second pass with No Depth Test, but I think this will cause the pass in question to be visible in front of the depth-enabled pass.

@huhund
Copy link
Author

huhund commented Aug 4, 2020

Calinou is correct. No-depth-test does a different thing. GL_GREATER is an "inverse" depth check.

@Calinou Calinou changed the title Support for depth function in spatial materials and/or shaders Support for depth function in spatial materials and/or shaders (GL_GREATER, …) Apr 18, 2021
@Calinou Calinou changed the title Support for depth function in spatial materials and/or shaders (GL_GREATER, …) Add support for depth function in spatial materials and/or shaders (GL_GREATER, …) Jan 5, 2022
@Calinou
Copy link
Member

Calinou commented Aug 9, 2024

@DigvijaysinhGohil Please don't bump issues without contributing significant new information. Use the 👍 reaction button on the first post instead.

You can use the All button on the sidebar on the right (below the Notifications header) to subscribe to notifications without leaving a reply on a thread:

image

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.

3 participants