nanoMMO 0.97.8
Building an MMO: The Engineering Series
Loading...
Searching...
No Matches
atmosphere.h
Go to the documentation of this file.
1#ifndef NANOMMO_CLIENT_ATMOSPHERE_H_
2#define NANOMMO_CLIENT_ATMOSPHERE_H_
3
4#include <raylib.h>
5
6#include <array>
7
8#include "terrain/lands.h"
9
10namespace nanommo {
11
12/// The sky and the light, which the shaders read each frame.
13struct Atmosphere {
14 /// The background, which the fog fades into.
15 std::array<float, 3> sky;
16 /// In metres from the camera: the fog starts at the first, and hides
17 /// everything past the second.
18 float fog_near;
19 float fog_far;
20 /// Towards the sun.
21 std::array<float, 3> sun;
22 /// What the sun adds to a face that's turned to it.
23 std::array<float, 3> sunlight;
24 /// What a face gets even when it's turned away from the sun.
25 std::array<float, 3> ambient;
26 /// Overhead, where the sky is deepest. `sky` is its colour at the horizon,
27 /// which the fog fades into.
28 std::array<float, 3> zenith;
29 /// The sun's disc, brighter than white so that the bloom spreads it, and
30 /// how wide it looks across, in degrees.
31 std::array<float, 3> disc;
32 float disc_size = 2.5f;
33 /// The clouds, where the sun's on them, and how many of the land's clouds
34 /// are out, from none to all of them.
35 std::array<float, 3> clouds;
36 float cloudiness = 0.5f;
37 /// How many of the stars show, from none in the day to all of them on a
38 /// clear night.
39 float stars = 0.0f;
40 /// How wet the ground is after rain, from dry to soaked: darker, and
41 /// shining where the light comes off it.
42 float wetness = 0.0f;
43};
44
45/// What a land's sea is made of: its colours, its waves and its light.
46struct Liquid {
47 /// Out where it's deep. Its alpha is how much of the ground it hides.
48 Color deep;
49 /// Where it's shallow, near the shore.
50 Color shallow;
51 /// Along the line where it meets the ground: foam on water, a crust on lava.
52 Color edge;
53 /// In metres, from the still surface to the top of a wave.
54 float height = 0.0f;
55 /// In metres, from the top of a wave to the next, of the longest of its
56 /// three waves.
57 float wavelength = 10.0f;
58 /// How fast its waves go, where 1 is as fast as water's.
59 float pace = 1.0f;
60 /// How much of the sun it reflects to the eye.
61 float glint = 0.0f;
62 /// The light it gives off of its own, at a wave's middle height, added to
63 /// the sun's, where 1 is as bright as a face turned to a white sun. The top
64 /// of a wave gives off four times that, and the bottom none.
65 float emission = 0.0f;
66};
67
68/// A land's colours: its atmosphere, and the colours that go into its meshes.
69struct Look {
71 Color sand;
72 Color grass;
73 Color rock;
74 Color snow;
76 /// Multiplies the colours of the trees' faces.
77 Color trees;
78};
79
80constexpr Look kMeadows = {
81 .atmosphere = {.sky = {0.6f, 0.77f, 0.92f},
82 .fog_near = 45.0f,
83 .fog_far = 150.0f,
84 .sun = {0.55f, 0.75f, 0.35f},
85 .sunlight = {0.75f, 0.68f, 0.55f},
86 .ambient = {0.4f, 0.44f, 0.52f},
87 .zenith = {0.3f, 0.5f, 0.84f},
88 .disc = {4.0f, 3.7f, 3.1f},
89 .disc_size = 3.0f,
90 .clouds = {1.0f, 1.0f, 1.0f},
91 .cloudiness = 0.55f},
92 .sand = {214, 196, 140, 255},
93 .grass = {106, 162, 70, 255},
94 .rock = {128, 120, 112, 255},
95 .snow = {238, 240, 245, 255},
96 .sea = {.deep = {48, 118, 178, 210},
97 .shallow = {95, 168, 195, 116},
98 .edge = {237, 245, 250, 242},
99 .height = 0.45f,
100 .wavelength = 10.0f,
101 .pace = 1.0f,
102 .glint = 0.6f},
103 .trees = WHITE,
104};
105
106constexpr Look kAshlands = {
107 .atmosphere = {.sky = {0.46f, 0.22f, 0.13f},
108 .fog_near = 35.0f,
109 .fog_far = 130.0f,
110 .sun = {0.6f, 0.45f, -0.4f},
111 .sunlight = {1.0f, 0.55f, 0.3f},
112 .ambient = {0.36f, 0.28f, 0.28f},
113 // A red sun in the smoke, under clouds of ash.
114 .zenith = {0.22f, 0.1f, 0.08f},
115 .disc = {4.0f, 1.4f, 0.5f},
116 .disc_size = 5.0f,
117 .clouds = {0.42f, 0.33f, 0.3f},
118 .cloudiness = 0.8f},
119 .sand = {60, 54, 52, 255},
120 .grass = {124, 112, 104, 255},
121 .rock = {84, 74, 72, 255},
122 .snow = {196, 84, 40, 255},
123 // Lava, thick and slow, which cools to a crust at the shore.
124 .sea = {.deep = {255, 130, 30, 255},
125 .shallow = {190, 60, 20, 255},
126 .edge = {40, 24, 22, 255},
127 .height = 0.3f,
128 .wavelength = 12.0f,
129 .pace = 0.25f,
130 .emission = 0.35f},
131 .trees = {58, 46, 42, 255},
132};
133
134constexpr Look kCrypt = {
135 .atmosphere = {.sky = {0.13f, 0.11f, 0.18f},
136 .fog_near = 20.0f,
137 .fog_far = 90.0f,
138 .sun = {0.3f, 0.9f, 0.2f},
139 .sunlight = {0.45f, 0.42f, 0.6f},
140 .ambient = {0.26f, 0.24f, 0.32f},
141 // Night, with a pale moon in place of a sun.
142 .zenith = {0.04f, 0.03f, 0.08f},
143 .disc = {1.6f, 1.7f, 2.2f},
144 .disc_size = 2.5f,
145 .clouds = {0.24f, 0.22f, 0.3f},
146 .cloudiness = 0.35f},
147 .sand = {70, 66, 74, 255},
148 .grass = {88, 92, 84, 255},
149 .rock = {104, 98, 112, 255},
150 .snow = {150, 146, 160, 255},
151 // A glowing green ooze.
152 .sea = {.deep = {40, 200, 150, 255},
153 .shallow = {30, 120, 90, 255},
154 .edge = {150, 240, 190, 255},
155 .height = 0.3f,
156 .wavelength = 8.0f,
157 .pace = 0.4f,
158 .glint = 0.3f,
159 .emission = 0.3f},
160 .trees = {70, 64, 80, 255},
161};
162
163/// In the order of the lands.
164constexpr std::array<Look, 3> kLooks = {kMeadows, kAshlands, kCrypt};
165static_assert(kLooks.size() == kLands.size(), "each land needs its look");
166
167} // namespace nanommo
168
169#endif // NANOMMO_CLIENT_ATMOSPHERE_H_
Definition chat.cc:9
constexpr std::array< Look, 3 > kLooks
In the order of the lands.
Definition atmosphere.h:164
constexpr Look kAshlands
Definition atmosphere.h:106
constexpr std::array< Land, 3 > kLands
Definition lands.h:31
constexpr Look kCrypt
Definition atmosphere.h:134
constexpr Look kMeadows
Definition atmosphere.h:80
The sky and the light, which the shaders read each frame.
Definition atmosphere.h:13
std::array< float, 3 > zenith
Definition atmosphere.h:28
std::array< float, 3 > ambient
What a face gets even when it's turned away from the sun.
Definition atmosphere.h:25
std::array< float, 3 > sunlight
What the sun adds to a face that's turned to it.
Definition atmosphere.h:23
std::array< float, 3 > sky
The background, which the fog fades into.
Definition atmosphere.h:15
std::array< float, 3 > disc
Definition atmosphere.h:31
std::array< float, 3 > clouds
Definition atmosphere.h:35
std::array< float, 3 > sun
Towards the sun.
Definition atmosphere.h:21
What a land's sea is made of: its colours, its waves and its light.
Definition atmosphere.h:46
Color edge
Along the line where it meets the ground: foam on water, a crust on lava.
Definition atmosphere.h:52
float height
In metres, from the still surface to the top of a wave.
Definition atmosphere.h:54
Color deep
Out where it's deep. Its alpha is how much of the ground it hides.
Definition atmosphere.h:48
Color shallow
Where it's shallow, near the shore.
Definition atmosphere.h:50
float glint
How much of the sun it reflects to the eye.
Definition atmosphere.h:61
float pace
How fast its waves go, where 1 is as fast as water's.
Definition atmosphere.h:59
A land's colours: its atmosphere, and the colours that go into its meshes.
Definition atmosphere.h:69
Color trees
Multiplies the colours of the trees' faces.
Definition atmosphere.h:77
Atmosphere atmosphere
Definition atmosphere.h:70