Graphics Reference
In-Depth Information
Noise Functions
GLSL includes the built-in noise func-
tions below, which can be used by both
fragment and vertex shaders. The noise
functions are pseudo-random stochas-
tic functions that are C 1 continuous with
range [-1., 1.] and mean 0.0, and they
are deterministic for a given input. The
output has the same statistical character
if the domain is rotated or translated.
The noise functions can readily be used
to create textures that add to the visual
complexity of a scene.
The GLSL language specification
defines the noise functions shown here,
but at this writing, it has not actually
been implemented in all GLSL systems.
While everyone agrees that there need
to be built-in noise functions available,
not everyone agrees on what would be
the best specific implementation. This
is why glman builds them in using 2D
and 3D textures.
float noise1(genType x) Returns a 1D noise value based on the input value x .
At this time, this function is not available in GLSL.
vec2 noise2(genType x) Returns a 2D noise value based on the input value x .
At this time, this function is not available in GLSL.
vec3 noise3 (genType x) Returns a 3D noise value based on the input value x .
vec4 noise4 (genType x) Returns a 4D noise value based on the input value x .
Swizzle
An operation that is probably new to you is the swizzle operation. This lets you
rearrange or reorganize the components of a vector in any way you want. This
operation is specified by simply writing the components of a vector in any
order you want, using one of the component name sets. For example, if m is a
vec4 , you can reverse the order of the components of m by writing m.wzyx , or
you can duplicate some of the components of m by writing m.rrbb .
New Function Parameter Types
GLSL function parameters differ from the standard C “pass by value” approach.
GLSL parameters are passed by value-return . This means that parameters' val-
ues may be copied into a function or may be returned by the function, or both,
but unlike with “pass by reference” variables, there is no change to any of the
actual parameters until the function returns. The function parameters are pre-
ceded by one of the keywords in , out , or inout ; this comes before the type of
the parameter.
 
Search WWH ::




Custom Search