Noise function for procedurally generated blocks
Hantverk'n » Devlog
I'm using a stateless pgc hash function in 3D coordinate space to generate noise for my procedurally generated blocks. In case anyone is curious about the code, here are pcg hash functions for 1D, 2D and 3D in integer coordinates written in C++
inline constexpr uint32_t pcgHash(uint32_t x) { uint32_t state = (x * 0x2C9277B5u) + 0xAC564B05u, word = ((state >> ((state >> 28) + 4)) ^ state) * 0x108EF2D9u; return word ^ (word >> 22); } inline constexpr uint32_t pcgHash(uint32_t x, uint32_t y) { uint32_t h = pcgHash(x) + pcgHash(y); return h ^ (h >> ((x % 15) + 1)); } inline constexpr uint32_t pcgHash(uint32_t x, uint32_t y, uint32_t z) { uint32_t h = pcgHash(x) + pcgHash(y) + pcgHash(z); return h ^ (h >> ((x % 15) + 1)); }
and what the 2D noise it generates looks like via shadertoy
https://www.shadertoy.com/view/Mcsyz4
Update: The following code yields good looking noise and is slightly faster
inline constexpr uint32_t pcgHash(uint32_t x, uint32_t y) { return pcgHash(pcgHash(y) + x); }
Hantverk'n
Status | In development |
Author | Teknologicus |
Genre | Adventure |
Tags | Exploration, Open World, Voxel |
More posts
- Overhaul of buffer use in voxel engine7 days ago
- Tetahexacontree 4x4x4 Occupancy Bitmasks Lookup Table19 days ago
- Voxel-level ambient occlusion optimization bits generation via compute shader59 days ago
- Image rotation via shearing64 days ago
- Rotation without rotating66 days ago
- Voxel volume mipmaps generation via compute shader66 days ago
- Dynamic global illumination methods79 days ago
- More ambient occlusions optimizationsAug 30, 2024
- Procedurally generated grooved, cracked brick blocksAug 27, 2024
- Procedurally generated cobblestone blocks with surface indentationsAug 27, 2024
Leave a comment
Log in with itch.io to leave a comment.