-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
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
Examples: Postprocessing fullscreen triangle optimization #21358
Conversation
I remember we used this technique for rendering particles in my demoscene days back in 2002 🤓 The rationale is indeed interesting. We can probably implement this in |
Just week ago had conversation with coworkers about this. 👍 |
I think the source code should only be modified in that way when to a comment is added that links to a respective explanation. Without knowing this approach, new devs are going to wonder about this setup. |
Also see this article by @luruke for additional suggestions. |
@zeux Do you know if this is a good thing to do with current/future GPUs? |
Coincidentally I have been thinking of this technique, too, to improve our post-processing performance lately. Real-Time Rendering mentions in Chapter 12 that image processing with this technique is 10% faster than the one with quadrilateral on AMD GCN architecture, because of better cache coherency. And similar to @mrdoob I was thinking whether this technique is still good on other architectures/GPUs. |
Yeah full-screen triangle is never worse than a full-screen quad for post-processing. It can be better depending on the GPU; I'd generally expect gains in the 0-5% range depending on the effect and GPU in question, I've seen 8% quoted in some presentations but it's usually more of an outlier. The issues this addresses are, in order of increasing severity:
A full-screen triangle typically solves all of these issues as GPUs generate full waves/quads of pixels in correct order and process all of them without waste. The only downside is that it's harder to use this if you only want to run postfx on part of your screen, although you can use scissor rectangles for that. |
@zeux Many thanks for the explanation! 🙏 Okay, I'll just merge it and clean it up then. |
Thanks! |
Clean up: 0e8e043 |
Description
The postprocessing is using a fullscreen PlaneGeometry for fullscreen fragmentShader, it can lead to quad overshading. Here a fullscreen Triangle instead.