//========= Copyright © 1996-2006, Valve Corporation, All rights reserved. ============// // // Purpose: noise() primitives. // //=====================================================================================// #include #include "basetypes.h" #ifndef _PS3 #include #endif #include "tier0/dbg.h" #include "mathlib/mathlib.h" #include "mathlib/vector.h" #include "mathlib/noise.h" // memdbgon must be the last include file in a .cpp file!!! #include "tier0/memdbgon.h" // generate high quality noise based upon "sparse convolution". HIgher quality than perlin noise, // and no direcitonal artifacts. #include "noisedata.h" #define N_IMPULSES_PER_CELL 5 #define NORMALIZING_FACTOR 1.0 //(0.5/N_IMPULSES_PER_CELL) static inline int LatticeCoord(float x) { return ((int) floor(x)) & 0xff; } static inline int Hash4D(int ix, int iy, int iz, int idx) { int ret=perm_a[ix]; ret=perm_b[(ret+iy) & 0xff]; ret=perm_c[(ret+iz) & 0xff]; ret=perm_d[(ret+idx) & 0xff]; return ret; } #define SQ(x) ((x)*(x)) static float CellNoise( int ix, int iy, int iz, float xfrac, float yfrac, float zfrac, float (*pNoiseShapeFunction)(float) ) { float ret=0; for(int idx=0;idx