---
title: "textureSampleLevel(): typeshade/core/ir의 IR 빌더 함수"
description: "textureSampleLevel, typeshade/core/ir의 IR 빌더 함수입니다. 2D 텍스처를 명시한 밉 레벨에서 샘플링하여 vec4<f32>를 반환합니다."
url: https://typeshade.dev/ko/api/texturesamplelevel/
language: ko
---

# `textureSampleLevel()`

함수, 내장 함수 분류

2D 텍스처를 명시한 밉 레벨에서 샘플링하여 `vec4<f32>`를 반환합니다.

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

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

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

## 구문

```ts
function textureSampleLevel(
  tex: ReadonlyNode<'texture_2d<f32>'>,
  smp: ReadonlyNode<'sampler'>,
  uv: ReadonlyNode<'vec2<f32>'>,
  level: ReadonlyNode<'f32'> | number,
): Node<'vec4<f32>'>;
function textureSampleLevel(
  tex: ReadonlyNode<'texture_2d_array<f32>'>,
  smp: ReadonlyNode<'sampler'>,
  uv: ReadonlyNode<'vec2<f32>'>,
  layer: ReadonlyNode<'i32' | 'u32'> | number,
  level: ReadonlyNode<'f32'> | number,
): Node<'vec4<f32>'>;
```

## 매개변수

**`tex` `ReadonlyNode<'texture_2d<f32>'>`**

**`smp` `ReadonlyNode<'sampler'>`**

**`uv` `ReadonlyNode<'vec2<f32>'>`**

**`level` `ReadonlyNode<'f32'> | number`**

## 반환값

`Node<'vec4<f32>'>`

## 설명

명시한 밉 레벨에서 2D 텍스처를 샘플링하여 `vec4<f32>`를 반환합니다. 미분이 필요 없으므로 모든 스테이지에서 쓸 수 있으며, 버텍스나 컴퓨트 셰이더는 [`textureSample`](https://typeshade.dev/ko/api/texturesample/) 대신 이 형태를 씁니다. 예를 들어 버텍스 셰이더에서 변위 맵을 읽는 경우입니다. JS 숫자 `level`은 `f32` 리터럴로 승격됩니다. WGSL에서는 `textureSampleLevel(t, s, uv, l)`로, GLSL에서는 `textureLod(t, uv, l)`로 적습니다. GLSL에서는 샘플러가 텍스처의 일부입니다. CPU 평가는 `gpuStubs` 옵션이 켜져 있으면 플레이스홀더를 반환합니다.

## 대상별 지원

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

## 관련 가이드

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

## 함께 보기

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

## 소스

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