adding post processing

This commit is contained in:
2025-05-31 18:03:36 +02:00
parent 88fead6cfc
commit 4319c4096b
18 changed files with 244 additions and 11 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.8f } : Scop::Vec4f{ 1.0f };
Scop::Vec4f color = is_water ? Scop::Vec4f{ 1.0f, 1.0f, 1.0f, 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

@@ -1,13 +1,8 @@
#include "Maths/Vec3.h"
#include <Noise.h>
#include <Block.h>
#include <cstdint>
#include <random>
constexpr float HEIGHT_COEFF = 255.0f;
constexpr std::uint32_t WATER_LEVEL = 20;
Noise::Noise(const std::uint32_t seed, float frequency, float amplitude, int octaves, float lacunarity, float persistance, int redistribution, float compensatory_factor): m_seed(std::mt19937(seed)), c_frequency(frequency), c_amplitude(amplitude), c_octaves(octaves), c_lacunarity(lacunarity), c_persistance(persistance), c_redistribution(redistribution), c_compensatory_factor(compensatory_factor)
{
if(c_amplitude > 1.0f || c_amplitude < -1.0f)

View File

@@ -7,7 +7,10 @@
#include <array>
#include <random>
#define NOISE_SIZE 512
constexpr float HEIGHT_COEFF = 255.0f;
constexpr std::uint32_t NOISE_SIZE = 512;
constexpr std::uint32_t WATER_LEVEL = 20;
class Noise
{
public:

View File

@@ -2,6 +2,7 @@
#include <ScopCore.h>
#include <NoiseCollection.h>
#include <World.h>
#include <Utils.h>
@@ -25,6 +26,8 @@ World::World(Scop::Scene& scene) : m_scene(scene), m_previous_chunk_position(-10
std::int32_t z_chunk = static_cast<std::int32_t>(camera->GetPosition().z) / static_cast<std::int32_t>(CHUNK_SIZE.z);
m_current_chunk_position = Scop::Vec2i{ x_chunk, z_chunk };
scene->GetPostProcessData().data.GetDataAs<std::int32_t>()[0] = scene->GetCamera()->GetPosition().y <= WATER_LEVEL;
if(input.IsKeyPressed(SDL_SCANCODE_G))
generation_debounce = true;
else if(generation_debounce)

View File

@@ -10,9 +10,13 @@ int main(int ac, char** av)
Scop::ScopEngine engine(ac, av, "Vox", 0, 0, GetExecutablePath().parent_path().parent_path() / "ScopEngine/Assets");
Scop::Scene& splash_scene = SplashScreen();
std::shared_ptr<Scop::Shader> shader = Scop::LoadShaderFromFile(GetExecutablePath().parent_path().parent_path() / "Resources/Fragment.spv", Scop::ShaderType::Fragment, Scop::DefaultShaderLayout);
std::shared_ptr<Scop::Shader> post_process_shader = Scop::LoadShaderFromFile(GetExecutablePath().parent_path().parent_path() / "Resources/PostProcess.spv", Scop::ShaderType::Fragment, Scop::PostProcessShaderLayout);
Scop::SceneDescriptor main_scene_desc;
main_scene_desc.fragment_shader = shader;
main_scene_desc.post_process_shader = post_process_shader;
main_scene_desc.post_process_data_size = sizeof(std::int32_t);
main_scene_desc.render_post_process_enabled = true;
main_scene_desc.camera = std::make_shared<Scop::FirstPerson3D>(Scop::Vec3f{ 0.0f, 20.0f, 0.0f }, 80.f);
main_scene_desc.culling = Scop::CullMode::Front;
Scop::Scene& main_scene = splash_scene.AddChildScene("main", std::move(main_scene_desc));