---
title: "fragment: TypeShade 언어 참조에 실린 어트리뷰트 이름과 그 시그니처"
description: "fragment (어트리뷰트), TypeShade 언어 참조 항목입니다. Marks the pipeline's fragment-stage entry point, on the function declaration…"
url: https://typeshade.dev/ko/reference/attributes/fragment/
language: ko
---

# `@fragment`

어트리뷰트

Marks the pipeline's fragment-stage entry point, on the function declaration: `@fragment export function fs(…) { … }`.

`@fragment`는 표시한 함수를 프래그먼트 스테이지의 진입점으로 만듭니다. GPU는 덮인 픽셀 샘플마다 이 함수를 한 번 호출합니다.

## 예제 비교

삼각형 하나의 픽셀 세 개를 비교합니다. 호출마다 자신의 픽셀에서 보간된 uv를 읽고 자신의 색을 반환합니다.

**예제 프로그램**`@fragment export function fs(uv: location<0, vec2>): vec4 { return vec4(uv, 0., 1.); }`

**예제 1`uv = (0, 0)`**

**결과**

`vec4(0, 0, 0, 1)`

**예제 2`uv = (0.5, 0.5)`**

**결과**

`vec4(0.5, 0.5, 0, 1)`

**예제 3`uv = (1, 0)`**

**결과**

`vec4(1, 0, 0, 1)`

예제는 설명용 계산 모델이며 GPU를 실행하지 않습니다. 속성의 문법은 아래 컴파일러 참고 자료에서 설명합니다. 소수 결과는 표시할 때 반올림했습니다. 각 예제는 명시한 전제를 따릅니다. 실제 셰이더의 결과는 대상 언어의 정밀도와 실행 규칙에 따릅니다.

## 활용

버텍스 스테이지가 보간한 값으로 각 픽셀의 색을 계산하는 함수에 사용합니다.

## 입력 범위와 주의사항

최상위 함수 선언 앞에 씁니다. 구조체 없이 반환한 값은 첫 번째 색상 어태치먼트인 location 0으로 갑니다. 구조체를 반환하면 어태치먼트마다 필드를 하나씩 두며, 번호는 적힌 순서대로 매겨집니다.

셰이더의 입력 규칙과 정밀도는 [WGSL](https://www.w3.org/TR/WGSL/)과 [GLSL ES 3.00](https://registry.khronos.org/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf)에서 규정합니다.

## 관련 속성

- [`@vertex`](https://typeshade.dev/ko/reference/attributes/vertex/)
- [`@compute`](https://typeshade.dev/ko/reference/attributes/compute/)

시그니처와 이름 아래 문장, 컴파일러 메시지는 커밋 af54ddad5의 컴파일러가 쓴 영어 원문입니다.

## 구문

```ts
declare function fragment(target: Function, context?: unknown): void
```

## 매개변수

이 데코레이터는 인자 없이 그대로 붙입니다.

선언에는 TypeScript 데코레이터 런타임이 넘겨주는 `target`과 `context`도 적혀 있습니다. 호출에서는 둘 다 쓰지 않습니다.

## 설명

The entry takes the function's name.

## 예제

- [`path/first-color/first-color.shade.ts`](https://typeshade.dev/ko/guide/examples/first-color/)
- [`path/uv-gradient/uv-gradient.shade.ts`](https://typeshade.dev/ko/guide/examples/uv-gradient/)
- [`path/moving-wave/moving-wave.shade.ts`](https://typeshade.dev/ko/guide/examples/moving-wave/)
- [`path/sdf-shapes/sdf-shapes.shade.ts`](https://typeshade.dev/ko/guide/examples/sdf-shapes/)
- [`path/tile-pattern/tile-pattern.shade.ts`](https://typeshade.dev/ko/guide/examples/tile-pattern/)
- [`path/fractal/fractal.shade.ts`](https://typeshade.dev/ko/guide/examples/fractal/)
- [`path/palette/palette.shade.ts`](https://typeshade.dev/ko/guide/examples/palette/)
- [`path/bouncing-balls/bouncing-balls.shade.ts`](https://typeshade.dev/ko/guide/examples/bouncing-balls/)
- [`path/ray-tracer/ray-tracer.shade.ts`](https://typeshade.dev/ko/guide/examples/ray-tracer/)
- [`gallery/capsule-corp-namek-class/capsule-corp-namek-class.shade.ts`](https://typeshade.dev/ko/guide/examples/capsule-corp-namek-class/)
- [`gallery/domain-warp-twin/domain-warp-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/domain-warp-twin/)
- [`gallery/hillshade-twin/hillshade-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/hillshade-twin/)
- [`gallery/julia-twin/julia-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/julia-twin/)
- [`gallery/kaleidoscope-twin/kaleidoscope-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/kaleidoscope-twin/)
- [`gallery/mandelbrot-twin/mandelbrot-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/mandelbrot-twin/)
- [`gallery/ocean-twin/ocean-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/ocean-twin/)
- [`gallery/path-tracer/path-tracer.shade.ts`](https://typeshade.dev/ko/guide/examples/path-tracer/)
- [`gallery/plasma-twin/plasma-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/plasma-twin/)
- [`gallery/rt-renderer-class/rt-renderer-class.shade.ts`](https://typeshade.dev/ko/guide/examples/rt-renderer-class/)
- [`gallery/starfield-twin/starfield-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/starfield-twin/)
- [`gallery/tunnel-twin/tunnel-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/tunnel-twin/)
- [`gallery/voronoi-twin/voronoi-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/voronoi-twin/)
- [`gallery/fp64-burning-ship-twin/fp64-burning-ship-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-burning-ship-twin/)
- [`gallery/fp64-cancellation-twin/fp64-cancellation-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-cancellation-twin/)
- [`gallery/fp64-checker-plane-twin/fp64-checker-plane-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-checker-plane-twin/)
- [`gallery/fp64-clock-twin/fp64-clock-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-clock-twin/)
- [`gallery/fp64-deep-zoom-twin/fp64-deep-zoom-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-deep-zoom-twin/)
- [`gallery/fp64-julia-twin/fp64-julia-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-julia-twin/)
- [`gallery/fp64-lane-stripes/fp64-lane-stripes.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-lane-stripes/)
- [`gallery/fp64-loran-twin/fp64-loran-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-loran-twin/)
- [`gallery/fp64-mandelbrot-de-twin/fp64-mandelbrot-de-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-mandelbrot-de-twin/)
- [`gallery/fp64-newton-twin/fp64-newton-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-newton-twin/)
- [`gallery/fp64-rtc-twin/fp64-rtc-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-rtc-twin/)
- [`gallery/fp64-sine-sweep-twin/fp64-sine-sweep-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/fp64-sine-sweep-twin/)
- [`gallery/array-literal-ramp/array-literal-ramp.shade.ts`](https://typeshade.dev/ko/guide/examples/array-literal-ramp/)
- [`gallery/array-methods/array-methods.shade.ts`](https://typeshade.dev/ko/guide/examples/array-methods/)
- [`gallery/bare-position/bare-position.shade.ts`](https://typeshade.dev/ko/guide/examples/bare-position/)
- [`gallery/bit-bump/bit-bump.shade.ts`](https://typeshade.dev/ko/guide/examples/bit-bump/)
- [`gallery/bitfield-bands/bitfield-bands.shade.ts`](https://typeshade.dev/ko/guide/examples/bitfield-bands/)
- [`gallery/block-scope/block-scope.shade.ts`](https://typeshade.dev/ko/guide/examples/block-scope/)
- [`gallery/bool-select/bool-select.shade.ts`](https://typeshade.dev/ko/guide/examples/bool-select/)
- [`gallery/class-builder/class-builder.shade.ts`](https://typeshade.dev/ko/guide/examples/class-builder/)
- [`gallery/class-parts/class-parts.shade.ts`](https://typeshade.dev/ko/guide/examples/class-parts/)
- [`gallery/class-syntax/class-syntax.shade.ts`](https://typeshade.dev/ko/guide/examples/class-syntax/)
- [`gallery/clip-planes/clip-planes.shade.ts`](https://typeshade.dev/ko/guide/examples/clip-planes/)
- [`gallery/closures/closures.shade.ts`](https://typeshade.dev/ko/guide/examples/closures/)
- [`gallery/convert-grid/convert-grid.shade.ts`](https://typeshade.dev/ko/guide/examples/convert-grid/)
- [`gallery/cube-array-gather/cube-array-gather.shade.ts`](https://typeshade.dev/ko/guide/examples/cube-array-gather/)
- [`gallery/cube-env/cube-env.shade.ts`](https://typeshade.dev/ko/guide/examples/cube-env/)
- [`gallery/cutout/cutout.shade.ts`](https://typeshade.dev/ko/guide/examples/cutout/)
- [`gallery/default-args/default-args.shade.ts`](https://typeshade.dev/ko/guide/examples/default-args/)
- [`gallery/feedback-trail/feedback-trail.shade.ts`](https://typeshade.dev/ko/guide/examples/feedback-trail/)
- [`gallery/generic-class/generic-class.shade.ts`](https://typeshade.dev/ko/guide/examples/generic-class/)
- [`gallery/generic-helpers/generic-helpers.shade.ts`](https://typeshade.dev/ko/guide/examples/generic-helpers/)
- [`gallery/gradient-twin/gradient-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/gradient-twin/)
- [`gallery/hello/hello.shade.ts`](https://typeshade.dev/ko/guide/examples/hello/)
- [`gallery/hello-uniform/hello-uniform.shade.ts`](https://typeshade.dev/ko/guide/examples/hello-uniform/)
- [`gallery/hello-uniform-struct/hello-uniform-struct.shade.ts`](https://typeshade.dev/ko/guide/examples/hello-uniform-struct/)
- [`gallery/hello-vsin/hello-vsin.shade.ts`](https://typeshade.dev/ko/guide/examples/hello-vsin/)
- [`gallery/hello-vsout/hello-vsout.shade.ts`](https://typeshade.dev/ko/guide/examples/hello-vsout/)
- [`gallery/higher-order/higher-order.shade.ts`](https://typeshade.dev/ko/guide/examples/higher-order/)
- [`gallery/id-pick/id-pick.shade.ts`](https://typeshade.dev/ko/guide/examples/id-pick/)
- [`gallery/imported-noise/imported-noise.shade.ts`](https://typeshade.dev/ko/guide/examples/imported-noise/)
- [`gallery/inferred-returns/inferred-returns.shade.ts`](https://typeshade.dev/ko/guide/examples/inferred-returns/)
- [`gallery/integer-math/integer-math.shade.ts`](https://typeshade.dev/ko/guide/examples/integer-math/)
- [`gallery/loops-over-data/loops-over-data.shade.ts`](https://typeshade.dev/ko/guide/examples/loops-over-data/)
- [`gallery/mixin-surface/mixin-surface.shade.ts`](https://typeshade.dev/ko/guide/examples/mixin-surface/)
- [`gallery/module-const/module-const.shade.ts`](https://typeshade.dev/ko/guide/examples/module-const/)
- [`gallery/msaa-resolve/msaa-resolve.shade.ts`](https://typeshade.dev/ko/guide/examples/msaa-resolve/)
- [`gallery/normal-matrix/normal-matrix.shade.ts`](https://typeshade.dev/ko/guide/examples/normal-matrix/)
- [`gallery/null-values/null-values.shade.ts`](https://typeshade.dev/ko/guide/examples/null-values/)
- [`gallery/optional-fields/optional-fields.shade.ts`](https://typeshade.dev/ko/guide/examples/optional-fields/)
- [`gallery/optional-values/optional-values.shade.ts`](https://typeshade.dev/ko/guide/examples/optional-values/)
- [`gallery/orbit-inout/orbit-inout.shade.ts`](https://typeshade.dev/ko/guide/examples/orbit-inout/)
- [`gallery/packed-bytes/packed-bytes.shade.ts`](https://typeshade.dev/ko/guide/examples/packed-bytes/)
- [`gallery/packing-bitcast/packing-bitcast.shade.ts`](https://typeshade.dev/ko/guide/examples/packing-bitcast/)
- [`gallery/palette-const/palette-const.shade.ts`](https://typeshade.dev/ko/guide/examples/palette-const/)
- [`gallery/pick-composite/pick-composite.shade.ts`](https://typeshade.dev/ko/guide/examples/pick-composite/)
- [`gallery/private-state/private-state.shade.ts`](https://typeshade.dev/ko/guide/examples/private-state/)
- [`gallery/ray-class/ray-class.shade.ts`](https://typeshade.dev/ko/guide/examples/ray-class/)
- [`gallery/reference-parameters/reference-parameters.shade.ts`](https://typeshade.dev/ko/guide/examples/reference-parameters/)
- [`gallery/rng-method/rng-method.shade.ts`](https://typeshade.dev/ko/guide/examples/rng-method/)
- [`gallery/sample-branch/sample-branch.shade.ts`](https://typeshade.dev/ko/guide/examples/sample-branch/)
- [`gallery/separable-blur/separable-blur.shade.ts`](https://typeshade.dev/ko/guide/examples/separable-blur/)
- [`gallery/shadow-compare/shadow-compare.shade.ts`](https://typeshade.dev/ko/guide/examples/shadow-compare/)
- [`gallery/shape-inheritance/shape-inheritance.shade.ts`](https://typeshade.dev/ko/guide/examples/shape-inheritance/)
- [`gallery/textured-quad/textured-quad.shade.ts`](https://typeshade.dev/ko/guide/examples/textured-quad/)
- [`gallery/tuple-and-brand/tuple-and-brand.shade.ts`](https://typeshade.dev/ko/guide/examples/tuple-and-brand/)
- [`gallery/twin-structs/twin-structs.shade.ts`](https://typeshade.dev/ko/guide/examples/twin-structs/)
- [`gallery/uniform-array/uniform-array.shade.ts`](https://typeshade.dev/ko/guide/examples/uniform-array/)

## 함께 보기

- [어트리뷰트](https://typeshade.dev/ko/reference/attributes/)
