Skip to content

Uniformly Darken Areas in the Scene Using a Triangle List, How? #1492

Answered by AnyOldName3
hytel asked this question in Q&A
Discussion options

You must be logged in to vote

The corners of the screen from the rasteriser's point of view range from -1 to 1, so to cover all of that with a single triangle, you need to go beyond the edge, and that's where the threes come from. It's pretty common that people suggest drawing a fullscreen quad instead of a single triangle, and it shouldn't make much difference here, but for more expensive effects, there are more cache misses and worse occupancy for the regions of the screen that cover the edges of the two triangles making up the quad, so it's better to get in the habit of using one big triangle.

For something as simple as this, your shaders could simply be

#version 450

layout(location = 0) in vec2 vsg_Vertex;

out g…

Replies: 7 comments 5 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by hytel
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
5 replies
@AnyOldName3
Comment options

@hytel
Comment options

@hytel
Comment options

@robertosfield
Comment options

@hytel
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants