improving water

This commit is contained in:
2025-05-31 20:08:35 +02:00
parent f8ff6be0e6
commit 9b548c8e2f
2 changed files with 7 additions and 3 deletions

View File

@@ -78,7 +78,7 @@ void Chunk::GenerateMesh()
std::vector<std::uint32_t>& index_data = (is_water ? m_water_mesh_index_data : m_mesh_index_data);
std::uint32_t& offset = (is_water ? water_offset : mesh_offset);
Scop::Vec4f color = is_water ? Scop::Vec4f{ 1.0f, 1.0f, 1.0f, 0.9f } : Scop::Vec4f{ 1.0f };
Scop::Vec4f color = is_water ? Scop::Vec4f{ 0.3f, 0.5f, 0.7f, 0.9f } : Scop::Vec4f{ 1.0f };
std::uint32_t invalid_limit = is_water ? static_cast<std::uint32_t>(BlockType::Air) : static_cast<std::uint32_t>(BlockType::Water);

View File

@@ -28,8 +28,12 @@ World::World(Scop::Scene& scene) : m_noisecollection(42), m_scene(scene), m_prev
if(Scop::NonOwningPtr<Chunk> current_chunk = GetChunk(m_current_chunk_position); current_chunk)
{
Scop::Vec3f camera_pos = scene->GetCamera()->GetPosition();
scene->GetPostProcessData().data.GetDataAs<std::int32_t>()[0] = current_chunk->GetBlock(Scop::Vec3i(std::abs(camera_pos.x - m_current_chunk_position.x), camera_pos.y, std::abs(camera_pos.z - m_current_chunk_position.y))) == static_cast<std::uint32_t>(BlockType::Water);
Scop::Vec3i camera_pos = Scop::Vec3i(std::floor(scene->GetCamera()->GetPosition().x), scene->GetCamera()->GetPosition().y, std::floor(scene->GetCamera()->GetPosition().z));
camera_pos.x %= CHUNK_SIZE.x;
camera_pos.z %= CHUNK_SIZE.z;
camera_pos.x += CHUNK_SIZE.x;
camera_pos.z += CHUNK_SIZE.z;
scene->GetPostProcessData().data.GetDataAs<std::int32_t>()[0] = current_chunk->GetBlock(Scop::Vec3i(camera_pos.x % CHUNK_SIZE.x, camera_pos.y, camera_pos.z % CHUNK_SIZE.z)) == static_cast<std::uint32_t>(BlockType::Water);
}
if(input.IsKeyPressed(SDL_SCANCODE_G))