refract
Function
Refracts the incident vector i through a surface with normal n and ratio of indices eta; returns the zero vector on total internal reflection.
The signature and the sentence under each name are the compiler's own text at commit 26de7be8.
Syntax
declare function refract<V extends vec2 | vec3 | vec4>(a0: V, a1: V, a2: (f32)): Vdeclare function refract<T extends Numeric>(i: T, n: T, eta: number): TA number in a parameter or a return position is the scalar slot. The ambient file declares a GPU scalar as a branded number whose brand is optional, so a literal and any branded scalar both fill it.
type f32 = number & { readonly [f32Tag]?: true }
A declaration you write still needs a width, and a bare number on a field or a parameter is refused; the TypeScript constructs page carries that row with the compiler's own message.
A signature may name a type the ambient file declares for its own use. These are those declarations.
Numerictype Numeric = number | vec2 | vec3 | vec4 | vec2i | vec3i | vec4i | vec2u | vec3u | vec4u
Parameters
-
iVT -
nVT -
eta(f32)number
Return value
VT
Description
Both vectors should be normalized.
Targets
- WGSL
-
refract(a, b, c) - GLSL ES 3.00
-
refract(a, b, c)