wgslPolyfill top-level property

Map<String, CodeNode> wgslPolyfill
getter/setter pair

Implementation

var wgslPolyfill = {
  "lessThanEqual": CodeNode("""
fn lessThanEqual( a : vec3<f32>, b : vec3<f32> ) -> vec3<bool> {

	return vec3<bool>( a.x <= b.x, a.y <= b.y, a.z <= b.z );

}
"""),
  "mod": CodeNode("""
fn mod( x : f32, y : f32 ) -> f32 {

	return x - y * floor( x / y );

}
"""),
  "repeatWrapping": CodeNode("""
fn repeatWrapping( uv : vec2<f32>, dimension : vec2<i32> ) -> vec2<i32> {

	var uvScaled = vec2<i32>( uv * vec2<f32>( dimension ) );

	return ( ( uvScaled % dimension ) + dimension ) % dimension;

}
"""),
  "inversesqrt": CodeNode("""
fn inversesqrt( x : f32 ) -> f32 {

	return 1.0 / sqrt( x );

}
""")
};