random
이 페이지에서

random

함수

Returns an f32 in the range [0, 1) hashed from an f32, vec2 or vec3 seed, emitted as fract(sin(dot(seed, k)) * 43758.5453123).

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

구문

declare function random(seed: f32 | vec2 | vec3): f32

매개변수

반환값

f32

설명

One seed is one value in the IR and NOT on a GPU: WGSL bounds sin to 2^-11 absolute error on [-PI, PI] and not at all outside it, which is where this hash lives, so the driver decides the answer (surface section 55 has the measurements; #181 replaces the hash with an exact integer one). There is no unseeded form: Math.random() without a seed does not compile.

예제

함께 보기

이 페이지 편집 문제 보고