textureSampleLevel
이 페이지에서

textureSampleLevel()

함수, 내장 함수 분류

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

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

이 export는 IR 노드를 반환합니다. "use typeshade" 파일에서는 내장 함수 자체를 부릅니다: textureSampleLevel()

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

구문

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 대신 이 형태를 씁니다. 예를 들어 버텍스 셰이더에서 변위 맵을 읽는 경우입니다. 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 }로 모듈을 컴파일하지 않으면 이 호출은 예외를 던집니다. 그 옵션으로 컴파일하면 플레이스홀더를 반환합니다.

관련 가이드

함께 보기

소스

src/core/ir/node.ts, 1821행, 커밋 af54ddad5 기준

이 페이지 편집 문제 보고