Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have just begun learning shader programing. What I learned is that the rasteriser groups three vertices to form a triangle for doing further operations. If that's true how does the rasteriser determines appropriate vertices which form a triangle in the mesh/geometry? Is it the 3D software which saves geometry in the proper order in model file like .3ds or .obj, .x or is it the GPU which internally triangulates the geometry irrespective of the order the vertices are passed?

share|improve this question
    
It's been a while, but IIRC .obj stores points in the beginning of the file, and then shapes at the end of the file, so the triangles would have to be formed already. –  corsiKa Jul 8 at 22:42
add comment

1 Answer 1

up vote 5 down vote accepted

You tell the GPU how to produce triangles from the input data. You specify vertex buffers containing all your vertex data, you also specify a primitive topology (lines, triangles, et cetera) and an optional index buffer.

The topology tells the GPU how many and what pattern to take the indices in (for example, in sets of three for a triangle list). The indices simply refer directly to entries in the bound vertex buffer.

If you don't specify an index buffer, the GPU takes the data from vertex buffer directly in the pattern indicated by the topology.


Also, strictly speaking, the GPU doesn't do triangularization; by the time you submit the data, it's already expected to be in triangles -- or whatever format your primitive topology demands, like lines or points. Similarly, it's not the rasterizer that handles reading the input arrangements. That's done by the GPU well in advance of the rasterization stage.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.