diff --git a/bin/pg.wasm b/bin/pg.wasm index 0ff4a5e..b727aca 100644 Binary files a/bin/pg.wasm and b/bin/pg.wasm differ diff --git a/constants.h b/constants.h index 47ce046..3ab5e38 100644 --- a/constants.h +++ b/constants.h @@ -39,7 +39,7 @@ constexpr float ROCK_NOISE_SHARPNESS = 85.0; // grass constexpr int MAX_NUM_GRASSES_PER_CHUNK = 2048; constexpr int MAX_NUM_FLOWERS_PER_CHUNK = 2048; -constexpr float GRASS_THRESHOLD = 0.05; +constexpr float GRASS_THRESHOLD = 0.65; constexpr float GRASS_HEIGHT_VARIATION_RANGE = 0.5; constexpr float GRASS_COLOR_VARIATION_BASE = 1.0; constexpr float GRASS_COLOR_VARIATION_RANGE = 0.3; diff --git a/generation/glsl.cc b/generation/glsl.cc index 5c62339..9f41fac 100644 --- a/generation/glsl.cc +++ b/generation/glsl.cc @@ -431,15 +431,21 @@ float getWetness(vec2 position) return clamp(simplex(position / 2.f) + 0.2f, 0.f, 1.f); } -float getGrassMaterial(vec2 position, float wetness) +float getGrassNoise(vec2 position, float wetness) { float noise = warpNoise1Layer_2(position * 10.f) * wetness; + return noise * 9.5f; +} + +float getGrassMaterial(vec2 position, float wetness) +{ + float noise = getGrassNoise(position, wetness); return clamp(noise, 0.f, 1.f); } float getGrassObject(vec2 position, float wetness) { - return getGrassMaterial(position, wetness); + return getGrassNoise(position, wetness); } bool getGrassVisibility(vec2 position, float wetness) diff --git a/generation/noise.h b/generation/noise.h index ba6f63a..59c22c8 100644 --- a/generation/noise.h +++ b/generation/noise.h @@ -176,7 +176,22 @@ class UberNoise { case (uint8_t)INSTANCE::TREE: { - color = vm::vec3{0.f, 0.f, 0.f}; + const float hash = (hashNoise(x * 3.f, z * 3.f) * 2.0 - 1.0); + const float colorVariationNoise = vm::clamp(GRASS_COLOR_VARIATION_BASE + simplexm15 * GRASS_COLOR_VARIATION_RANGE, 0.0f, 1.f + GRASS_COLOR_VARIATION_RANGE); + const float randomBladeFactor = heightfield.field.hash * 2.f - 1.f; + color = (vm::vec3{colorVariationNoise / 1.0f, colorVariationNoise / 1.0f, colorVariationNoise / 1.3f} + + vm::vec3{randomBladeFactor / 10.f, randomBladeFactor / 7.f, randomBladeFactor / 12.f}) + + vm::vec3{hash, hash / 3.f, -hash} / 7.f; + break; + } + case (uint8_t)INSTANCE::BUSH: + { + const float hash = (hashNoise(x * 6.f, z * 6.f) * 2.0 - 1.0); + const float colorVariationNoise = vm::clamp(GRASS_COLOR_VARIATION_BASE + simplexm15 * GRASS_COLOR_VARIATION_RANGE, 0.0f, 1.f + GRASS_COLOR_VARIATION_RANGE); + const float randomBladeFactor = heightfield.field.hash * 2.f - 1.f; + color = (vm::vec3{colorVariationNoise / 1.3f, colorVariationNoise / 1.0f, colorVariationNoise / 1.1f} + + vm::vec3{randomBladeFactor / 12.f, randomBladeFactor / 6.f, randomBladeFactor / 10.f}) + + vm::vec3{hash, -hash / 2.f, -hash / 2.f} / 6.f; break; } case (uint8_t)INSTANCE::FLOWER: @@ -188,8 +203,8 @@ class UberNoise { const float colorVariationNoise = vm::clamp(GRASS_COLOR_VARIATION_BASE + simplexm15 * GRASS_COLOR_VARIATION_RANGE, 0.0f, 1.f + GRASS_COLOR_VARIATION_RANGE); const float randomBladeFactor = heightfield.field.hash * 2.f - 1.f; - color = (vm::vec3{colorVariationNoise / 1.4f, colorVariationNoise / 1.6f, colorVariationNoise / 1.75f} + - vm::vec3{randomBladeFactor / 8.f, randomBladeFactor / 10.f, randomBladeFactor / 12.f}); + color = (vm::vec3{colorVariationNoise / 2.05f, colorVariationNoise / 1.6f, colorVariationNoise / 2.1f} + + vm::vec3{randomBladeFactor / 13.f, randomBladeFactor / 9.f, randomBladeFactor / 14.f}); break; } case (uint8_t)INSTANCE::ROCK: