summary refs log tree commit diff
path: root/src/World/Clouds.hpp
blob: b2d5a10b69e00e01f92a4336e32e08ede1f5a8a9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once

#include "../GFX/Binder.hpp"
#include "../GFX/Shading/Program.hpp"
#include "../GFX/Shading/Uniform.hpp"
#include "../GFX/Camera.hpp"

namespace MC::World {

class Clouds {
public:
    Clouds(Real ascept, Real fov, Real near, Real far, Vector<3, F32> sky_color, Vector<3, F32> sun_direction);

    void update(U64 time);
    void render(const GFX::Camera& camera) const;
private:
    constexpr static U32 CloudMatrixSize = 128;
    constexpr static Int Height = 200;
    constexpr static Real Scale = 15;
    constexpr static Real TileSize = CloudMatrixSize * Scale;

    using CloudMatrix = Matrix<CloudMatrixSize, CloudMatrixSize, Bool>;

    void render_single_instance(const GFX::Camera& camera, Int x, Int y) const;

    static CloudMatrix create_cloud_matrix();
    static GFX::Mesh create_mesh(const CloudMatrix& cloud_matrix);

    static const Char* vertex;
    static const Char* fragment;

    Real m_x_offset = 0.0;

    GFX::Shading::Program m_program;
    GFX::BindableMesh m_mesh;

    GFX::Shading::Uniform m_model_uniform;
    GFX::Shading::Uniform m_view_uniform;
    GFX::Shading::Uniform m_projection_uniform;
};

}