noise.h File Reference

Perlin noise routines for procedural textures, etc. More...

#include "llmath.h"

Include dependency graph for noise.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.


#define B   0x100
#define BM   0xff
#define N   0x1000
#define NF32   (4096.f)
#define NP   12
#define NM   0xfff
#define s_curve(t)   ( t * t * (3.f - 2.f * t) )
#define lerp_m(t, a, b)   ( a + t * (b - a) )
#define setup_noise(i, b0, b1, r0, r1)


F32 turbulence2 (F32 *v, F32 freq)
F32 turbulence3 (float *v, float freq)
F32 clouds3 (float *v, float freq)
F32 noise2 (float *vec)
F32 noise3 (float *vec)
F32 bias (F32 a, F32 b)
F32 gain (F32 a, F32 b)
static void init (void)
void fast_setup (F32 vec, U8 &b0, U8 &b1, F32 &r0, F32 &r1)
F32 noise1 (const F32 arg)
F32 fast_at2 (F32 rx, F32 ry, F32 *q)
F32 fast_at3 (F32 rx, F32 ry, F32 rz, F32 *q)
static void normalize2 (F32 v[2])
static void normalize3 (F32 v[3])


S32 p [B+B+2]
F32 g3 [B+B+2][3]
F32 g2 [B+B+2][2]
F32 g1 [B+B+2]
S32 gNoiseStart

Detailed Description

Perlin noise routines for procedural textures, etc.


Copyright (c) 2000-2007, Linden Research, Inc.

Second Life Viewer Source Code The source code in this file ("Source Code") is provided by Linden Lab to you under the terms of the GNU General Public License, version 2.0 ("GPL"), unless you have obtained a separate licensing agreement ("Other License"), formally executed by you and Linden Lab. Terms of the GPL can be found in doc/GPL-license.txt in this distribution, or online at

There are special exceptions to the terms and conditions of the GPL as it is applied to this Source Code. View the full text of the exception in the file doc/FLOSS-exception.txt in this software distribution, or online at

By copying, modifying or distributing this software, you acknowledge that you have read and understood your obligations described above, and agree to abide by those obligations.


Definition in file noise.h.

Define Documentation

#define B   0x100

Definition at line 108 of file noise.h.

#define BM   0xff

Definition at line 109 of file noise.h.

#define lerp_m ( t,
b   )     ( a + t * (b - a) )

Definition at line 126 of file noise.h.

#define N   0x1000

Definition at line 111 of file noise.h.

#define NF32   (4096.f)

Definition at line 112 of file noise.h.

#define NM   0xfff

Definition at line 114 of file noise.h.

#define NP   12

Definition at line 113 of file noise.h.

#define s_curve ( t   )     ( t * t * (3.f - 2.f * t) )

Definition at line 124 of file noise.h.

#define setup_noise ( i,
r1   ) 


t = vec[i] + N;\
        b0 = (lltrunc(t)) & BM;\
        b1 = (b0+1) & BM;\
        r0 = t - lltrunc(t);\
        r1 = r0 - 1.f;

Definition at line 128 of file noise.h.

Referenced by noise1().

Function Documentation

F32 bias ( F32  a,
F32  b 
) [inline]

Definition at line 43 of file noise.h.

References f.

Referenced by LLStringBase< T >::compareDict(), LLImageTGA::decodeAndProcess(), and LLFace::renderSelectedUV().

F32 clouds3 ( float *  v,
float  freq 
) [inline]

Definition at line 90 of file noise.h.

References f, noise3(), and t.

F32 fast_at2 ( F32  rx,
F32  ry,
F32 q 
) [inline]

Definition at line 169 of file noise.h.

F32 fast_at3 ( F32  rx,
F32  ry,
F32  rz,
F32 q 
) [inline]

Definition at line 176 of file noise.h.

void fast_setup ( F32  vec,
U8 b0,
U8 b1,
F32 r0,
F32 r1 
) [inline]

Definition at line 136 of file noise.h.

References lltrunc(), NF32, and S32.

F32 gain ( F32  a,
F32  b 
) [inline]

Definition at line 48 of file noise.h.

References f, and p.

Referenced by LLAudioEngine::mapWindVecToGain(), process_attached_sound(), process_attached_sound_gain_change(), process_sound_trigger(), LLViewerObject::processUpdateMessage(), and LLVOAvatar::updateCharacter().

static void init ( void   )  [static]

Definition at line 316 of file noise.h.

References B, g1, g2, g3, i, j, normalize2(), normalize3(), and p.

Referenced by tut::LLTemplateMessageBuilderTestData::defaultTemplate(), LLUUID::getCurrentTime(), idle_startup(), tut::LLMessageSystemTestData::LLMessageSystemTestData(), noise1(), noise2(), and noise3().

F32 noise1 ( const F32  arg  )  [inline]

Definition at line 148 of file noise.h.

References g1, gNoiseStart, init(), lerp_m, p, s_curve, setup_noise, t, u, and v.

Referenced by LLVOAvatar::idleUpdate(), and LLDrawPoolAvatar::renderAvatars().

F32 noise2 ( float *  vec  ) 

Definition at line 47 of file noise.cpp.

References a, b, fast_at2(), fast_setup(), g2, gNoiseStart, i, init(), j, lerp_m, p, S32, s_curve, u, and v.

Referenced by LLSurfacePatch::eval(), LLVLComposition::generateHeights(), LLBodyNoiseMotion::onUpdate(), and turbulence2().

F32 noise3 ( float *  vec  )  [inline]

Definition at line 183 of file noise.h.

References a, b, c, d, fast_at3(), fast_setup(), g3, gNoiseStart, i, init(), j, lerp_m, p, S32, s_curve, t, u, and v.

Referenced by clouds3(), and turbulence3().

static void normalize2 ( F32  v[2]  )  [static]

Definition at line 297 of file noise.h.

References s.

static void normalize3 ( F32  v[3]  )  [static]

Definition at line 306 of file noise.h.

References s.

F32 turbulence2 ( F32 v,
F32  freq 
) [inline]

Definition at line 62 of file noise.h.

References f, noise2(), and t.

Referenced by LLVLComposition::generateHeights().

F32 turbulence3 ( float *  v,
float  freq 
) [inline]

Definition at line 74 of file noise.h.

References f, noise3(), and t.

Referenced by LLVOTree::updateGeometry().

Variable Documentation

F32 g1[B+B+2]

Definition at line 43 of file noise.cpp.

F32 g2[B+B+2][2]

Definition at line 42 of file noise.cpp.

F32 g3[B+B+2][3]

Definition at line 41 of file noise.cpp.

S32 gNoiseStart

Definition at line 44 of file noise.cpp.

Referenced by noise1(), noise2(), and noise3().

S32 p[B+B+2]

Definition at line 40 of file noise.cpp.

Generated on Thu Jul 1 06:10:56 2010 for Second Life Viewer by  doxygen 1.4.7