---
title: "uniform: 셰이더 함수 뜻과 사용법, 계산 예제와 입력 범위 및 주의점 | TypeShade"
description: "유니폼 선언은 그리기나 디스패치 동안 셰이더 호출들이 함께 읽는 호스트 제공 데이터를 나타냅니다. 카메라 설정, 크기와 작은 매개변수를 전달할 때 사용합니다. 선언만으로 데이터가 업로드되지는 않습니다."
url: https://typeshade.dev/ko/reference/functions/uniform/
language: ko
---

# `uniform`

함수

유니폼 선언은 그리기나 디스패치 동안 셰이더 호출들이 함께 읽는 호스트 제공 데이터를 나타냅니다.

## 예제 비교

호스트가 제공한 매개변수를 셰이더가 읽은 결과가 표시됩니다. 유니폼 선언 자체가 값을 업로드하지는 않습니다.

**모델의 전제**`class Params { scale: f32; } declare const u: uniform<Params>;`

**예제 1`host: u.scale = 1; shader: u.scale`**

**결과**

`1`

**예제 2`host: u.scale = 2; shader: u.scale`**

**결과**

`2`

**예제 3`host: u.scale = 0; shader: u.scale`**

**결과**

`0`

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

## 활용

카메라 설정, 크기와 작은 매개변수를 전달할 때 사용합니다.

## 입력 범위와 주의사항

선언만으로 데이터가 업로드되지는 않습니다. 호스트가 리플렉션 레이아웃에 맞게 버퍼를 할당하고 바인딩한 뒤 채워야 합니다. 셰이더는 유니폼 바인딩에 쓸 수 없습니다.

셰이더의 입력 규칙과 정밀도는 [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)에서 규정합니다.

## 관련 함수

- [`storage`](https://typeshade.dev/ko/reference/functions/storage/)
- [`array`](https://typeshade.dev/ko/reference/functions/array/)

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

Declares a uniform binding of type T; use `declare const name: uniform<T>` or `const name = uniform<T>()`.

## 구문

```ts
declare function uniform<T>(slot?: number | { group?: number; binding?: number }, binding?: number): ReadView<T>
```

매개변수나 반환 위치에 쓰인 `number`는 스칼라가 들어갈 자리입니다. 앰비언트 파일은 GPU 스칼라를 브랜드가 붙은 number로 선언하고 그 브랜드는 선택이라서, 리터럴도 브랜드가 붙은 스칼라도 이 자리에 들어갑니다.

`type f32 = number & { readonly [f32Tag]?: true }`

타입으로 쓴 `number`는 쓰이는 곳을 보고 추론하며, `f32`, `i32`, `u32`는 너비를 고정합니다. 그 행과 컴파일러가 낸 결과는 [TypeScript에서](https://typeshade.dev/ko/guide/language/from-typescript/) 페이지에 있습니다.

시그니처에는 앰비언트 파일이 스스로 쓰려고 선언한 타입이 나올 수 있습니다. 아래가 그 선언입니다.

**`ReadView`**

`type ReadView<T> = T extends number | boolean ? T : T extends (...args: never[]) => unknown ? T : { readonly [K in keyof T]: K extends string | number ? ReadView<T[K]> : T[K] }`

## 매개변수

- `slot` 선택 사항 `number | { group?: number; binding?: number }`
- `binding` 선택 사항 `number`

## 반환값

`ReadView<T>`

## 예제

- [`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/image-blur/image-blur.shade.ts`](https://typeshade.dev/ko/guide/examples/image-blur/)
- [`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/bit-bump/bit-bump.shade.ts`](https://typeshade.dev/ko/guide/examples/bit-bump/)
- [`gallery/clip-planes/clip-planes.shade.ts`](https://typeshade.dev/ko/guide/examples/clip-planes/)
- [`gallery/compute-reduction-twin/compute-reduction-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/compute-reduction-twin/)
- [`gallery/gradient-twin/gradient-twin.shade.ts`](https://typeshade.dev/ko/guide/examples/gradient-twin/)
- [`gallery/hello-camera/hello-camera.shade.ts`](https://typeshade.dev/ko/guide/examples/hello-camera/)
- [`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/imported-noise/imported-noise.shade.ts`](https://typeshade.dev/ko/guide/examples/imported-noise/)
- [`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/normal-matrix/normal-matrix.shade.ts`](https://typeshade.dev/ko/guide/examples/normal-matrix/)
- [`gallery/packed-bytes/packed-bytes.shade.ts`](https://typeshade.dev/ko/guide/examples/packed-bytes/)
- [`gallery/particle-step/particle-step.shade.ts`](https://typeshade.dev/ko/guide/examples/particle-step/)
- [`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/uniform-array/uniform-array.shade.ts`](https://typeshade.dev/ko/guide/examples/uniform-array/)
- [`gallery/workgroup-tile-2d/workgroup-tile-2d.shade.ts`](https://typeshade.dev/ko/guide/examples/workgroup-tile-2d/)

## 함께 보기

- [함수](https://typeshade.dev/ko/reference/functions/)
