Help end child hunger

Vertex Processor

 
Prev: Pipeline Overview Next: Fragment Processor
 

The vertex processor is responsible for running the vertex shaders. The input for a vertex shader is the vertex data, namely its position, color, normals, etc, depending on what the OpenGL application sends.

The following OpenGL code would send to the vertex processor a color and a vertex position for each vertex.

	glBegin(...);
		glColor3f(0.2,0.4,0.6);
		glVertex3f(-1.0,1.0,2.0);
		glColor3f(0.2,0.4,0.8);
		glVertex3f(1.0,-1.0,2.0);
	glEnd();

In a vertex shader you can write code for tasks such as:

  • Vertex position transformation using the modelview and projection matrices
  • Normal transformation, and if required its normalization
  • Texture coordinate generation and transformation
  • Lighting per vertex or computing values for lighting per pixel
  • Color computation

There is no requirement to perform all the operations above, your application may not use lighting for instance. However, once you write a vertex shader you are replacing the full functionality of the vertex processor, hence you can’t perform normal transformation and expect the fixed functionality to perform texture coordinate generation. When a vertex shader is used it becomes responsible for replacing all the needed functionality of this stage of the pipeline.

As can be seen in the previous subsection the vertex processor has no information regarding connectivity, hence operations that require topological knowledge can’t be performed in here. For instance it is not possible for a vertex shader to perform back face culling, since it operates on vertices and not on faces. The vertex processor processes vertices individually and has no clue of the remaining vertices.

The vertex shader is responsible for at least writing a variable: gl_Position, usually transforming the vertex with the modelview and projection matrices.

A vertex processor has access to OpenGL state, so it can perform operations that involve lighting for instance, and use materials. It can also access textures (only available in the newest hardware). There is no access to the frame buffer.

 

Prev: Pipeline Overview Next: Fragment Processor
 

  2 Responses to “Vertex Processor”

  1. very good.
    i wil read all tut in blog.
    Thank you .

  2. Excellent work. I’ve picked through a stack of pdfs and books trying to grasp the whole shader thing – for someone who is used to the old way it’s very opaque and damn hard to find a good exposition of. Yours takes the win easily. I hope to see more articles from you on this topic that delve into the vast possibilities opened up by the whole shader language paradigm – I’m starting to become sold that it is worth the initial horror of it (what? I have to write the whole opengl driver / pipeline myself? Why not just have us design and fabricate the gpu’s ourselves? Or even better – just expose the video ram directly and let us rasterize with sheer power of will! Ok ok. Anyway, please write a book, and make expand from this to much more advanced, siggraph-worthy stuff.
    -Matt

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: