PDA

View Full Version : fragment shader runs one time for every triangle?



Richard Zhao
09-14-2010, 07:57 AM
I'm not sure. Does fragment shader run one time for every triangle or every vertex?
Following the pipline, it's after Primitive Assembly. but if it's for a triangle, why does it only have one gl_FragColor. One triangle don't have to have only one color.

Thanks
Richard

Alfonse Reinheart
09-14-2010, 08:43 AM
I'm not sure. Does fragment shader run one time for every triangle or every vertex?

Neither. It is run for every fragment. A triangle is rasterized into a number of fragments, based on the area that the triangle covers. Large triangles will generate more fragments than small triangles.

Richard Zhao
09-14-2010, 04:53 PM
Is a fragment a pixel? If not, how many pixels does a fragment have?

ZbuffeR
09-14-2010, 11:54 PM
A fragment is one pixel unless some sort of xSAA antialiasing is in action.

Alfonse Reinheart
09-15-2010, 09:54 AM
Is a fragment a pixel?

No, a fragment is not a pixel. Pixels are stored in images, like the framebuffer. A fragment is a collection of information that may be written to one or more samples in the framebuffer.

The area a fragment covers is no larger than the area of a pixel. If antialiasing is in use, it may be smaller than the area of a single pixel.

Fragments become pixels, but they are not pixels yet.