summary refs log tree commit diff
path: root/src/World/Clouds.hpp
blob: 4bd0637f87cec4b180c75b46c9592ae02acfb1d5 (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
43
#pragma once

#include "../Time.hpp"
#include "../GFX/Shading/Program.hpp"
#include "../GFX/Shading/Uniform.hpp"
#include "../GFX/Camera.hpp"
#include "../GFX/Mesh.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(const Time& time);
    void render(const GFX::Camera& camera);
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);

    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::Mesh m_mesh;

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

}