---
title: "textureLoad(): typeshade/core/ir의 IR 빌더 함수, TypeShade API"
description: "textureLoad, typeshade/core/ir의 IR 빌더 함수입니다. 정수 좌표에서 2D 텍스처의 텍셀 하나를 읽습니다. 텍스처의 원소 타입에 맞춰 vec4<f32>, vec4<u32> 또는 vec4<i32>를 반환합니다."
url: https://typeshade.dev/ko/api/textureload/
language: ko
---

# `textureLoad()`

함수, 내장 함수 분류

정수 좌표에서 2D 텍스처의 텍셀 하나를 읽습니다. 텍스처의 원소 타입에 맞춰 `vec4<f32>`, `vec4<u32>` 또는 `vec4<i32>`를 반환합니다.

`import { textureLoad } from 'typeshade/core/ir'`

이 export는 IR 노드를 반환합니다. `"use typeshade"` 파일에서는 내장 함수 자체를 부릅니다: [`textureLoad()`](https://typeshade.dev/ko/reference/functions/textureLoad/)

설명은 커밋 af54ddad5의 검토된 컴파일러 문서를 번역한 것입니다. 시그니처와 예제 코드는 원문을 따르며, 필요한 경우 설명에 편집상 수정이 반영됩니다.

## 구문

```ts
function textureLoad<K extends TextureLoad2dKey>(
  tex: ReadonlyNode<K>,
  coord: NodeLike,
  level: NodeLike,
): Node<TexelKey<K>>;
function textureLoad<K extends TextureLoadArrayKey>(
  tex: ReadonlyNode<K>,
  coord: NodeLike,
  layer: ReadonlyNode<'i32' | 'u32'> | number,
  level: NodeLike,
): Node<TexelKey<K>>;
```

## 매개변수

**`tex` `ReadonlyNode<K>`**

**`coord` `NodeLike`**

**`level` `NodeLike`**

## 반환값

`Node<TexelKey<K>>`

## 예외

**[`SD0015`](https://typeshade.dev/ko/reference/errors/sd0015/)**

JS 숫자 레벨은 `u32` 리터럴로 승격되므로 0은 두 타깃 모두에서 올바른 정수 레벨을 생성합니다. 소수 레벨은 SD0015를 던집니다.

## 설명

WGSL은 밉 레벨 인자를 요구합니다. 기본 레벨에는 `0`을 넘깁니다. JS 숫자 레벨은 `u32` 리터럴로 승격되므로 `0`은 두 타깃 모두에서 올바른 정수 레벨을 생성합니다. 소수 레벨은 [`SD0015`](https://typeshade.dev/ko/reference/errors/sd0015/)를 던집니다.

좌표는 보통 `vec2<i32>`입니다. 여기서는 벡터나 스칼라 노드를 모두 받아들이며, 검사는 GPU 컴파일러가 합니다. CPU 평가는 `gpuStubs` 옵션이 켜져 있을 때 플레이스홀더를 반환합니다.

정수 텍스처를 읽을 때는 이 함수를 씁니다. 정수 텍셀은 필터링할 수 없으므로 [`textureSample`](https://typeshade.dev/ko/api/texturesample/)과 [`textureSampleLevel`](https://typeshade.dev/ko/api/texturesamplelevel/)은 정수 텍스처의 키를 `tsc`에서 거부합니다.

## 대상별 지원

| 대상 | 지원 | 비고 |
| --- | --- | --- |
| WGSL (WebGPU) | 지원 | `textureLoad(tex, coord, level)`. |
| GLSL ES 3.00 (WebGL2) | 지원 | `texelFetch(tex, coord, int(level))`. |
| CPU 오라클 | 스텁 | 오라클에는 텍스처 메모리와 이웃 프래그먼트가 없습니다. 모듈을 `{ gpuStubs: true }` 옵션으로 컴파일하지 않았다면 이 호출은 예외를 던집니다. 이 옵션을 켜면 플레이스홀더를 반환합니다. |

## 관련 가이드

- [레이아웃과 리소스](https://typeshade.dev/ko/guide/internals/layouts-and-resources/)
- [CPU 오라클 안내서](https://typeshade.dev/ko/guide/internals/the-cpu-oracle/)

## 함께 보기

- [`textureLoad()`](https://typeshade.dev/ko/reference/functions/textureLoad/)
- [`textureSample`](https://typeshade.dev/ko/api/texturesample/)
- [`textureSampleLevel`](https://typeshade.dev/ko/api/texturesamplelevel/)
- [`resource`](https://typeshade.dev/ko/api/resource/)

## 소스

[`src/core/ir/node.ts`, 1882행](https://github.com/typeshade/typeshade/blob/af54ddad5/src/core/ir/node.ts#L1882), 커밋 af54ddad5 기준
