1
votes

Let's say there's a color render texture that is 1000 px wide, 500 px tall. And I draw a quad with vertices at the four corners (-1, -1, 0), (1, -1, 0), (-1, 1, 0), (1, 1, 0) to it without any transformation in the vertex shader.

Will this always cover the entire texture's surface by default, assuming no other other GL functions prior to this sole draw command were called?

What OpenGL functions (that modify vertex positions) could cause this quad to no longer fill the screen?

(I'm trying to understand how vertices can be messed with prior to the vertex shader, so I can avoid or use the right functions to always map them so NDC (-1, -1) to (1, 1) represents the entire surface).

edit: If the positions are not altered, then I'm also wondering how their mapping to a render buffer might be modified prior to the vertex shader. For instance, will (-1, -1, 0) reliably refer to a fragment at the bottom-left of the render buffer, (0, 0, 0) to the middle, and (1, 1, 0) to the top-right?

1
What do you observe exactly? It doesn't fill the whole screen or you see nothing? Note that the z-coordinates are 0. If you are using a depth test, this might discard the fragments.Gilles-Philippe Paillé
@Gilles-PhilippePaillé - There's no depth/stencil testing, I'm mostly asking so I can understand how OpenGL modifies positions prior to the vert shader fully, so I can write my camera/drawing code more deliberately. (right now it's mostly "it works somehow")Anne Quinn
Okay, I understand. No, nothing modifies the vertex coordinates between the VBO and the start of the Vertex Shader. The data you send is the one you are receiving.Gilles-Philippe Paillé
@Gilles-PhilippePaillé - Aw, I see! That makes sense. I've edited the question to also ask how those positions might be made to draw to different fragment positions, or clipped altogether, outside of the vertex shaderAnne Quinn
@AnneQuinn "For instance, will (-1, -1, 0) reliably refer to a fragment at the bottom-left of the render buffer, (0, 0, 0) to the middle, and (1, 1, 0) to the top-right?" the mapping of normalized device coordinates to the framebuffer is defined by the viewport (glViewport). (-1, -1) is the bottom left of the viewport rectangle and (1, 1) the top right.Rabbid76

1 Answers

3
votes

Nothing happens to vertex data "prior to the vertex shader". Nothing can happen to it, because OpenGL doesn't know what the vertex attributes mean. It doesn't know what attribute 2 refers to; it doesn't know what is a position, normal, texture coordinate or anything. As far as OpenGL is concerned, it's all just data. What gives that data meaning is your vertex shader. And only in the way defined by your vertex shader.

Data from buffer objects are read in accord with the format specified by your VAO, and are given to the vertex shader invocations which process those vertices.