-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathr_skybox.h
85 lines (70 loc) · 1.46 KB
/
r_skybox.h
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
#ifndef R_SKYBOX_HDR
#define R_SKYBOX_HDR
#include "r_texture.h"
#include "r_method.h"
namespace u {
struct string;
}
namespace m {
struct mat4;
struct vec3;
}
namespace r {
// fog
enum {
kFogLinear,
kFogExp,
kFogExp2
};
struct fog {
fog();
m::vec3 color;
float density; // Used for Exp, Exp2, and sky fog gradient
float start; // Starting range (linear only)
float end; // Ending range (linear only)
enum {
kLinear,
kExp,
kExp2
};
int equation;
};
inline fog::fog()
: density(0.0f)
, start(0.0f)
, end(0.0f)
, equation(fog::kLinear)
{
}
struct pipeline;
struct skyboxMethod : method {
bool init(const u::vector<const char *> &defines = u::vector<const char *>());
void setWVP(const m::mat4 &wvp);
void setTextureUnit(int unit);
void setWorld(const m::mat4 &worldInverse);
void setFog(const fog &f);
void setSkyColor(const m::vec3 &color);
private:
uniform *m_WVP;
uniform *m_world;
uniform *m_skyColor;
uniform *m_colorMap;
uniform *m_fog0; // { r, g, b }
uniform *m_fog1; // { range.x, range.y, density }
uniform *m_fogEquation;
};
struct skybox {
skybox();
~skybox();
bool load(const u::string &skyboxName);
bool upload();
void render(const pipeline &pl, const fog &f);
private:
texture2D m_textures[6];
skyboxMethod m_methods[2];
m::vec3 m_skyColor;
GLuint m_vao;
GLuint m_vbo;
};
}
#endif