FXAA and Fullscreen Triangles

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?

There isn’t much difference between using a fullscreen quad or a fullscreen triangle, however you can save a few % of performance by using a triangle, as as you said, because of the overlapping groups, some parts of the screen get processed twice.

There shouldn’t be any overlapping pixels if the vertices are shared between the 2 triangle edges.
If there is, then the GL implementation isn’t compliant with the gl specification.

As for rendering only 1 triangle vs 2 triangles, you think there will be a difference in performance?

There shouldn’t be any overlapping pixels if the vertices are shared between the 2 triangle edges.

No, there won’t be any overlapping rendered pixels. But there will be overlapping fragment shaders along the main diagonal. Fragment shaders run in blocks of neighboring samples, and along the main diagonal, shaders will be run twice. The results may ultimately be discarded, but the shader will be executed multiple times for those samples.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.