textureLoad
이 페이지에서

textureLoad()

함수, 내장 함수 분류

Load one texel from a 2D texture at integer coordinates, returning vec4<f32>, vec4<u32> or vec4<i32> to match the texture's element.

import { textureLoad } from 'typeshade'

시그니처, 설명, 예제는 커밋 c66579bf의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

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

A JS number level lifts to a u32 literal, so 0 emits a valid integer level on both targets, and a fractional level throws SD0015.

설명

WGSL requires the mip level argument; pass 0 for the base level. A JS number level lifts to a u32 literal, so 0 emits a valid integer level on both targets, and a fractional level throws SD0015. The coordinate is usually a vec2<i32>; any vector or scalar node is accepted here and the GPU compiler checks it. The CPU evaluation returns a placeholder under its gpuStubs option.

For an integer texture this is the read to use: integer texels cannot be filtered, so textureSample and textureSampleLevel reject those keys at tsc.

대상별 지원

대상지원비고
WGSL (WebGPU) 지원

textureLoad(tex, coord, level).

GLSL ES 3.00 (WebGL2) 지원

texelFetch(tex, coord, int(level)).

CPU 오라클 스텁

The oracle has no texture memory and no neighbouring fragments. The call throws unless the module was compiled with { gpuStubs: true }, which returns a placeholder.

관련 가이드

함께 보기

소스

src/core/ir/node.ts, 2146행, 커밋 c66579bf 기준

이 페이지 편집 문제 보고