PDA

View Full Version : What on earth are Fragments?



Olumide
01-05-2002, 09:25 AM
I'm studying the OpenGL frame buffer at the momment, and the word "Fragment" or "Fragments" appears so often...

How exactly am I to think of a fragment? As a pixel or clipped polygon or all of the above!?!...

DFrey
01-05-2002, 09:42 AM
The OpenGL spec gives a very clear definition of a fragment. From 2.4 of the OpenGL 1.2 spec:


The rasterizer produces a series of framebuffer addresses
and values using a two-dimensional description of a point, line segment, or
polygon. Each fragment so produced is fed to the next stage that performs
operations on individual fragments before they finally alter the framebuffer.

harsman
01-05-2002, 09:58 AM
Think of it as a bundle of state used to update the framebuffer.

Olumide
01-05-2002, 10:00 AM
To quote you therefore, a fragment is a "2D description of a point, line segment or polygon..."

My question still is WHAT is a fragment?

I (now) know it is produced during rasterization ... so it must be in the form of a pixel and not a polygon ... YES or NO !
________________________

I know there are per vertex operations, per pixel operations and per fragment operations. That suggests to me that fragments are distict from bitmaps and "vertexed" entities (i.e. polygons) as well ...

[This message has been edited by Olumide (edited 01-05-2002).]

Bob
01-05-2002, 12:11 PM
A fragemnt is more or less a pixel.

A pixel is a point on the window, that has a color and a position.

A fragment also has info about the Z-value, stencil value, and other stuff needed to determine whether the pixel is supposed to be drawn or not. Say you draw a triangle, and parts of that triangle is occluded by another object. The whole triangle will generate fragments when rasterized, but some fragments is not drawn on the screen, because their Z-value is too large (rejected by the depth test), wrong stencil value (rejected by the stencil test), for example.

Per pixel operations is something that affect only the way the pixel appear on the screen. I.e., you can't affect the Z-value in a pixel shader, because Z-value does not belong to a pixel.

Per fragment operations is something that operates on other stuff. Depth test is a per fragment test. You reject/keep the fragment based on the Z-value.

dorbie
01-05-2002, 06:46 PM
A fragment refers to the per pixel values like colors, texture values etc, used by OpenGL to decide what color ultimately gets placed in a screen pixel.

So for example when a textured smooth shaded triangle get's drawn, for each pixel a color fragment is generated and a texture fragment is generated, a texture environment like GL_MODULATE will multiply these to produce the new fragment color from the texture unit to be sent to the next stage of the pipeline, whether it's another texture unit in the case of multitexture, or fog fragment calculations of blend fragment calculations.

So, fragments are pixel level values, but they are called fragments to make the distinction that these are partial or intermediate per pixel values which will ultimately be combined to produce a value which is written to the pixel.

When people say 'texture fragment' they are referring to pixel level texture samples. When they say 'per fragment' they pretty much mean per pixel in the context of some specific operation. When they say 'fragment lighting' they mean per pixel lighting, for example Phong shading.