Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified bin/pg.wasm
Binary file not shown.
2 changes: 1 addition & 1 deletion constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
10 changes: 8 additions & 2 deletions generation/glsl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 18 additions & 3 deletions generation/noise.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down