textureGather
이 페이지에서

textureGather

함수

Reads one channel from the four texels a linear filter would blend at the coordinate on mip level 0, through the sampler smp, and returns them as a vec4 in the order (umin,vmax), (umax,vmax), (umax,vmin), (umin,vmin), in any stage.

이름마다 붙은 시그니처와 설명은 커밋 26de7be8의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.

구문

declare function textureGather<E extends TextureElem = f32>(
component: number,
tex: texture_2d<E>,
smp: sampler,
uv: vec2,
): Vec4OfElem<E>
declare function textureGather<E extends TextureElem = f32>(
component: number,
tex: texture_2d_array<E>,
smp: sampler,
uv: vec2,
layer: number,
): Vec4OfElem<E>
declare function textureGather<E extends TextureElem = f32>(
component: number,
tex: texture_cube<E>,
smp: sampler,
dir: vec3,
): Vec4OfElem<E>
declare function textureGather<E extends TextureElem = f32>(
component: number,
tex: texture_cube_array<E>,
smp: sampler,
dir: vec3,
layer: number,
): Vec4OfElem<E>
declare function textureGather(tex: texture_depth_2d, smp: sampler, uv: vec2): vec4
declare function textureGather(tex: texture_depth_2d_array, smp: sampler, uv: vec2, layer: number): vec4
declare function textureGather(tex: texture_depth_cube, smp: sampler, dir: vec3): vec4
declare function textureGather(tex: texture_depth_cube_array, smp: sampler, dir: vec3, layer: number): vec4

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

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

직접 쓰는 선언에는 여전히 너비가 필요합니다. 필드나 매개변수에 number만 적으면 거부되며, 그 행과 컴파일러가 낸 메시지는 TypeScript에서 페이지에 있습니다.

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

TextureElem
type TextureElem = f32 | i32 | u32

매개변수

반환값

Vec4OfElem<E>vec4

설명

On a colour texture the first argument is the channel, a whole number from 0 to 3 written in the call; a depth texture has one channel and takes none; an array texture takes the layer after the coordinate. Compiles to textureGather on WGSL; GLSL ES 3.00 has no gather, so a module using it emits WGSL alone.

대상별 출력

WGSL
textureGather(a, b, c, d)
GLSL ES 3.00
textureGather has no GLSL ES 3.00 spelling (textureGather is ES 3.10)

예제

함께 보기

이 페이지 편집 문제 보고