Fragment
2026/08/07
- Type
- Learning Resource
- Format
- Glossary Article
- Version
- General
- Subject Tags
- Code
- MIT
- Game Assets
- 2016-2026, GDQuest© - All rights reserved
- All else
- 2016-2026, GDQuest© - All rights reserved
- Created
- Updated
- 2026/08/26
- 2026/08/07
A fragment is a sample of the final rendered image that the graphics card may or may not end up drawing. It's the fundamental unit of data processed by a fragment shader.
The fragment shader calculates each fragment's color, which ultimately determines the colors of pixels drawn on the screen or a texture.
In other words, while a pixel represents a single point of color in a rendered image, one way to think of a fragment is as a potential pixel that the graphics card may or may not end up drawing.
Each fragment also contains information like its position on the screen, UV coordinates, and other data passed from the vertex shader to the fragment shader.
In practice, the words fragment and pixel are often used interchangeably when talking about shaders.
Technically, there can be multiple fragments per pixel, or there can be fragments that are discarded before being drawn so they don't end up in the final rendered image.
For example, the discard keyword tells the fragment shader to stop processing the current fragment. This code skips drawing any fragments that are not in the left half of the screen:
if (UV.x < 0.5) {
discard;
}This is different from setting the fragment to a transparent color. Unlike returning a transparent color, a discarded fragment isn't drawn at all.
Don't stop here. Step-by-step tutorials are fun but they only take you so far.
Try one of our proven study programs to become an independent Gamedev truly capable of realizing the games you’ve always wanted to make.
Get help from peers and pros on GDQuest's Discord server!
20,000 membersJoin ServerThere are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!
Sponsor this library by learning gamedev with us onGDSchool
Learn MoreImprove and build on assets or suggest edits onGithub
Contributeshare this page and talk about GDQUest onRedditYoutubeTwitter…
Site in BETA!found a bug?