Hi,
I was reading Timothy Lottes’ FXAA whitepaper and it mentions that it uses fullscreen triangles.
My current post-processing framework uses fullscreen quads.
The application setup:
float quad[] =
{
-1.0f, 1.0f, // top left corner
-1.0f, -1.0f, // bottom left corner
1.0f, 1.0f, // top right corner
1.0f, -1.0f // bottom right corner
};
glGenVertexArrays(1, &m_vertexArrayObject);
glBindVertexArray(m_vertexArrayObject);
glGenBuffers(1, &m_vertexBufferObject);
glBindBuffer(GL_ARRAY_BUFFER, m_vertexBufferObject);
glBufferData(GL_ARRAY_BUFFER, sizeof(quad), quad, GL_STATIC_DRAW);
glVertexAttribPointer(glGetAttribLocation(m_program, "PositionNDC", 2, GL_FLOAT, GL_FALSE, 0, BUFFER_OFFSET(0));
glEnableVertexAttribArray(glGetAttribLocation(m_program, "PositionNDC");
The vertex shader
in vec2 PositionNDC;
out vec2 Texcoord;
void main()
{
gl_Position = vec4(PositionNDC, 0.0, 1.0);
Texcoord = PositionNDC * 0.5 + 0.5;
}
How does one setup a fullscreen triangle for use in post-processing effects?
Most modern GPUs work on groups of pixels so for a fullscreen quad rendered as 2 triangles the main diagonal will have overlapping groups of pixels for the GPU to process. So I can see the benefits of a fullscreen triangle. But is there much difference in real world performance over fullscreen quads?