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

Use two-pass rendering for double sided transparent objects #4825

Open
QbieShay opened this issue Jul 6, 2022 · 2 comments
Open

Use two-pass rendering for double sided transparent objects #4825

QbieShay opened this issue Jul 6, 2022 · 2 comments

Comments

@QbieShay
Copy link

QbieShay commented Jul 6, 2022

Describe the project you are working on

Various VFX.
Specifically, double sided smoke.
For an example,
image
from: https://twitter.com/qbieshay/status/1422982180339339267?s=20&t=t0oqMyFy3uPLaixxVr4fXA

Describe the problem or limitation you are having in your project

It's hard and cumbersome to have multiple render passes for double sided transparent objects, and a single render pass with cull disabled will create obvious artifacts.
Cull off:
Screenshot from 2022-07-08 15-11-45

Two-pass:
Screenshot from 2022-07-08 15-21-33

Note, this specific texture has hard edges so i could use scissor, but other textures like the first image of the issue don't work with scissor.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

Add a cull_two_sides flag (name up for debate) which will tell godot's renderer to do two draw passes, one first with front face culling, and one after with backface culling.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

There will be a flag that will tell the renderer to render the same object twice, one with front face culling and one with backface culling.
These passes will be executed one after the other so there is no need to worry about render priority.
Int he shader, it's possible to control the rendering with FRONT_FACING, which is a flag that already exists.

If this enhancement will not be used often, can it be worked around with a few lines of script?

Not a few lines of script. It is possible to reimplement a special "shader material" that will actually auto assign a second pass. The problem is that rendering order of draw passes flickers (see #4777) and culling flags are part of the shader code (see #933)
These issues coupled together create an incredibly cumbersome pipeline to work with double sided transparent materials.
Overlay material could be a way to fix this issue, but won't work for multi surface meshes. I have no need for multi surface meshes, but maybe someone else does.

Is there a reason why this should be core and not an add-on in the asset library?

It modifies the renderer.

@mrjustaguy
Copy link

mrjustaguy commented Jul 6, 2022

isn't cull disabled what you're looking for? (one of the 3 cull modes, the other two being front and back)

@QbieShay
Copy link
Author

QbieShay commented Jul 6, 2022

No, cull disable renders in the same render pass, meaning that sometimes you have overlapping triangles and visual artifacts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Needs consensus
Development

No branches or pull requests

2 participants