textureDimensions
이 페이지에서

textureDimensions

함수

텍스처 크기는 이미지의 범위를 나타내며 색상 값과는 다릅니다.

다른 언어의 관련 이름

관련 연산은 인수, 지원 범위와 의미가 다를 수 있습니다. 다른 언어의 이름을 TypeShade 별칭으로 사용할 수는 없습니다. 지원하는 형태와 제한은 대상 언어에 따라 다릅니다.

  • GLSL: textureSize

대상별 출력

예제 비교

반환 벡터의 각 성분은 해당 축의 텍셀 수입니다. 큐브의 면 수는 크기 벡터에 포함되지 않습니다.

예제 1texture_2d: 8 × 4
결과
vec2u(8, 4)
예제 2texture_3d: 8 × 4 × 2
결과
vec3u(8, 4, 2)
예제 3texture_cube: 4 × 4 × 6
결과
vec2u(4, 4)

예제는 설명용 계산 모델이며 GPU를 실행하지 않습니다. 정확한 호출 형식은 아래 컴파일러 참고 자료에서 설명합니다. 소수 결과는 표시할 때 반올림했습니다. 각 예제는 명시한 전제를 따릅니다. 실제 셰이더의 결과는 대상 언어의 정밀도와 실행 규칙에 따릅니다.

활용

텍셀 단위의 이동량을 정규화된 좌표 변화량으로 바꿀 때 사용합니다.

입력 범위와 주의사항

배열 레이어 수와 샘플 수는 별도로 조회합니다. 큐브 텍스처에서는 한 면의 크기를 돌려줍니다.

셰이더의 입력 규칙과 정밀도는 WGSL과 GLSL ES 3.00에서 규정합니다.

WGSL
textureDimensions(a)
GLSL ES 3.00
uvec2(textureSize(a, 0))

시그니처와 이름 아래 문장, 컴파일러 메시지는 커밋 af54ddad5의 컴파일러가 쓴 영어 원문입니다.

Returns the size of the texture's base mip level: width and height as a vec2u, width, height and depth as a vec3u on a texture_3d, or the width alone as a u32 on a texture_1d.

구문

declare function textureDimensions<E extends TextureElem = f32>(
tex: texture_2d<E> | texture_2d_array<E>,
level?: number,
): vec2u
declare function textureDimensions<E extends TextureElem = f32>(
tex: texture_cube<E> | texture_cube_array<E>,
level?: number,
): vec2u
declare function textureDimensions<E extends TextureElem = f32>(
tex: texture_3d<E>,
level?: number,
): vec3u
declare function textureDimensions<E extends TextureElem = f32>(tex: texture_1d<E>, level?: number): u32
declare function textureDimensions<E extends TextureElem = f32>(tex: texture_multisampled_2d<E>): vec2u
declare function textureDimensions(
tex:
| texture_depth_2d
| texture_depth_2d_array
| texture_depth_cube
| texture_depth_cube_array
| texture_depth_multisampled_2d,
level?: number,
): vec2u
declare function textureDimensions<F extends StorageFormat, A extends StorageAccess>(
tex: texture_storage_2d<F, A> | texture_storage_2d_array<F, A>,
): vec2u

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

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

타입으로 쓴 number는 쓰이는 곳을 보고 추론하며, f32, i32, u32는 너비를 고정합니다. 그 행과 컴파일러가 낸 결과는 TypeScript에서 페이지에 있습니다.

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

TextureElem
type TextureElem = f32 | i32 | u32
StorageFormat
type StorageFormat = 'rgba8unorm' | 'rgba8snorm' | 'rgba8uint' | 'rgba8sint' | 'rgba16uint' | 'rgba16sint' | 'rgba16float' | 'r32uint' | 'r32sint' | 'r32float' | 'rg32uint' | 'rg32sint' | 'rg32float' | 'rgba32uint' | 'rgba32sint' | 'rgba32float' | 'bgra8unorm'
StorageAccess
type StorageAccess = 'write' | 'read' | 'read_write'

매개변수

반환값

vec2uvec3uu32

설명

On a cube texture it is the size of one face.

대상별 출력

WGSL
textureDimensions(a)
GLSL ES 3.00
uvec2(textureSize(a, 0))

예제

함께 보기

이 페이지 편집 문제 보고