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
2026/08/26
Updated
2026/08/07

Fragment

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.

Fragments vs. pixels

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.

Why is it called a fragment?
The term comes from the graphics card's rendering pipeline, where geometry gets 'fragmented' into individual screen pixels for further processing.
Become an Indie Gamedev with GDQuest!

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.

Nathan

Founder and teacher at GDQuest
  • Starter Kit
  • Learn Gamedev from Zero
Check out GDSchool

You're welcome in our little community

Get help from peers and pros on GDQuest's Discord server!

20,000 membersJoin Server

Contribute to GDQuest's Free Library

There are multiple ways you can join our effort to create free and open source gamedev resources that are accessible to everyone!

Site in BETA!found a bug?