Mercurial > hg > dmlib
view src/dmperlin.h @ 2577:04c035342960
Attribute code in dmperlin.[ch] to be heavily based on Ken Perlin's original C
implementation, which can be found, for example, at
https://cs.nyu.edu/~perlin/doc/oscar.html#noise
author | Matti Hamalainen <ccr@tnsp.org> |
---|---|
date | Sat, 12 Mar 2022 02:42:16 +0200 |
parents | 85fab9d640ec |
children | e716a2f18da0 |
line wrap: on
line source
/* * DMLib * -- Perlin noise functionality * Based heavily on original code (C) Copyright Ken Perlin * Adapted and enhanced by Matti 'ccr' Hamalainen */ #ifndef DMPERLIN_H #define DMPERLIN_H #include "dmlib.h" #ifdef __cplusplus extern "C" { #endif #define DM_PLNS_B (0x100) #define DM_PLNS_BM (0x0ff) #define DM_PLNS_N (0x1000) typedef struct { int p[DM_PLNS_B + DM_PLNS_B + 2]; DMFloat g2[DM_PLNS_B + DM_PLNS_B + 2][2]; DMFloat g1[DM_PLNS_B + DM_PLNS_B + 2]; } DMPerlinContext; int dmPerlinInit(DMPerlinContext *ctx, const int seed); DMFloat dmPerlinNoise2D(const DMPerlinContext *ctx, DMFloat x, DMFloat y, DMFloat alpha, DMFloat beta, int n); #ifdef __cplusplus } #endif #endif // DMPERLIN_H