textureSample
함수
Samples a float texture through the sampler smp with the implicit level of detail, in the fragment stage only: at uv on a texture_2d, by a vec3 direction on a texture_cube, by a vec3 coordinate on a texture_3d, by one f32 on a texture_1d, and on an array texture the argument after the coordinate picks the layer.
이름마다 붙은 시그니처와 설명은 커밋 26de7be8의 컴파일러 소스에서 그대로 가져온 영어 원문입니다.
구문
declare function textureSample(tex: texture_2d<f32>, smp: sampler, uv: vec2): vec4declare function textureSample( tex: texture_2d_array<f32>, smp: sampler, uv: vec2, layer: number,): vec4declare function textureSample(tex: texture_cube<f32>, smp: sampler, dir: vec3): vec4declare function textureSample(tex: texture_3d<f32>, smp: sampler, coord: vec3): vec4declare function textureSample(tex: texture_1d<f32>, smp: sampler, coord: number): vec4declare function textureSample( tex: texture_cube_array<f32>, smp: sampler, dir: vec3, layer: number,): vec4매개변수나 반환 위치에 쓰인 number는 스칼라가 들어갈 자리입니다. 앰비언트 파일은 GPU 스칼라를 브랜드가 붙은 number로 선언하고 그 브랜드는 선택이라서, 리터럴도 브랜드가 붙은 스칼라도 이 자리에 들어갑니다.
type f32 = number & { readonly [f32Tag]?: true }
직접 쓰는 선언에는 여전히 너비가 필요합니다. 필드나 매개변수에 number만 적으면 거부되며, 그 행과 컴파일러가 낸 메시지는 TypeScript에서 페이지에 있습니다.
매개변수
-
textexture_2d<f32>texture_2d_array<f32>texture_cube<f32>texture_3d<f32>texture_1d<f32>texture_cube_array<f32> -
smpsampler -
uv선택 사항vec2 -
dir선택 사항vec3 -
coord선택 사항vec3number -
layer선택 사항number
반환값
설명
Compiles to textureSample on WGSL and texture on GLSL, where the layer is folded into a vec3 coordinate; a texture_1d or a texture_cube_array has no GLSL ES 3.00 form, so a module using one emits WGSL alone.
대상별 출력
- WGSL
-
textureSample(a, b, c) - GLSL ES 3.00
-
texture(a, c)