Euphoria
world.h
Go to the documentation of this file.
1#pragma once
2
3#include <unordered_set>
4#include <memory>
5
6#include "eu/core/scurve.h"
7
10#include "eu/render/space.h"
11
12namespace eu::core
13{
14 struct Geom;
15}
16
17namespace eu::render
18{
19
23
24
27{
32 std::unordered_set<core::VertexType> debug_types;
33
36
37 CompiledGeom(const CompiledGeom&) = delete;
39 void operator=(const CompiledGeom&) = delete;
40 void operator=(CompiledGeom&&) = delete;
41};
42
63
64std::shared_ptr<CompiledGeom> compile_geom(DEBUG_LABEL_ARG_MANY const core::Geom&, const core::CompiledGeomVertexAttributes& layout);
65std::shared_ptr<CompiledGeom_TransformInstance> compile_geom_with_transform_instance(
67 const core::Geom&, const core::CompiledGeomVertexAttributes& layout, std::size_t max_instances
68);
69
70// todo(Gustav): merge with CameraVectors... this has a better name
72{
76};
77
87
90{
91 std::shared_ptr<CompiledGeom> geom;
92 std::shared_ptr<Material> material;
93
94 std::optional<Rgb> outline;
95
98
99 [[nodiscard]] LocalAxis get_local_axis() const;
100};
101
102m4 transform_from_rotation(const v3& position, const Ypr& ypr);
103m4 transform_from_billboard(const v3& position, Billboarding billboarding, const CompiledCamera& cc);
104
105std::shared_ptr<MeshInstance> make_mesh_instance(std::shared_ptr<CompiledGeom> geom, std::shared_ptr<Material> mat);
106
109{
110 std::shared_ptr<CompiledGeom_TransformInstance> geom;
111 std::shared_ptr<Material> material;
112
113 //todo(Gustav): add outline
114
115 std::vector<m4> world_from_locals;
116};
117
118std::shared_ptr<MeshInstance_TransformInstanced> make_mesh_instance(
119 std::shared_ptr<CompiledGeom_TransformInstance> geom, std::shared_ptr<Material> mat
120);
121
122void render_geom(const CompiledGeom& geom);
124
125
135
138{
139 v3 position = {0.0f, 0.0f, 0.0f};
140 float min_range = 10.0f;
141 float max_range = 20.0f;
143
145 float specular_strength = 1.0f;
146 float diffuse_strength = 1.0f;
147};
148
150
153{
154 v3 position = {0.0f, 0.0f, 0.0f};
156 {
157 .yaw = 0.0_rad,
158 .pitch = 0.0_rad,
159 .roll = 0.0_rad
160 };
161 An fov = 10.0_deg;
162 float aspect = 1.0;
163
164 float min_range = 10.0f;
165 float max_range = 20.0f;
167
169 float specular_strength = 1.0f;
170 float diffuse_strength = 1.0f;
171
172 std::shared_ptr<Texture2d> cookie; // if null, pure white is used
173};
174
176struct Lights
177{
179 float ambient_strength = 0.029f;
180
181 float shadow_near = 1.0f;
182 float shadow_offset = 50.0f;
183 float shadow_far = 200.0f;
184 float shadow_size = 70.0f;
185
186 std::vector<DirectionalLight> directional_lights;
187 std::vector<PointLight> point_lights;
188 std::vector<FrustumLight> frustum_lights;
189};
190
192struct Skybox
193{
194 std::shared_ptr<CompiledGeom> geom = nullptr;
195 std::shared_ptr<TextureCubemap> cubemap = nullptr;
196};
197
200struct World
201{
202 std::vector<std::shared_ptr<MeshInstance>> meshes;
203 std::vector<std::shared_ptr<MeshInstance_TransformInstanced>> instances;
205
207 std::optional<Skybox> skybox;
208};
209
213
214} // namespace eu::render
#define DEBUG_LABEL_ARG_MANY
first debug label argument of many
constexpr m4 m4_identity
The identity matrix.
Definition mat4.h:177
void render_geom_instanced(const MeshInstance_TransformInstanced &instanced)
void render_geom(const CompiledGeom &geom)
std::shared_ptr< CompiledGeom > compile_geom(DEBUG_LABEL_ARG_MANY const core::Geom &, const core::CompiledGeomVertexAttributes &layout)
std::shared_ptr< MeshInstance > make_mesh_instance(std::shared_ptr< CompiledGeom > geom, std::shared_ptr< Material > mat)
std::shared_ptr< CompiledGeom_TransformInstance > compile_geom_with_transform_instance(DEBUG_LABEL_ARG_MANY const core::Geom &, const core::CompiledGeomVertexAttributes &layout, std::size_t max_instances)
Billboarding
Defines the billboarding algorithm to use.
Definition world.h:80
m4 transform_from_rotation(const v3 &position, const Ypr &ypr)
CameraVectors create_vectors(const Camera &camera)
Capture the current local space of the camera.
m4 transform_from_billboard(const v3 &position, Billboarding billboarding, const CompiledCamera &cc)
constexpr auto white
Definition colors.h:156
constexpr auto black
Definition colors.h:157
Definition ui.h:4
int32_t i32
Definition ints.h:9
uint32_t u32
Definition ints.h:14
An angle in both degrees and radians.
Definition angle.h:13
Represents color in gamma (non-linear) space (aka sRGB).
Definition colors.h:14
yaw + pitch + roll
Definition axisangle.h:33
A list of CompiledVertexLayoutNoNameList (for geom).
vertices and triangles
Definition geom.h:30
Contains the parameters for an S-Curve.
Definition scurve.h:15
static constexpr SCurve light_curve()
Definition scurve.h:27
4x4 matrix
Definition mat4.h:19
A temporary view of the local space of a camera.
Definition space.h:8
A "compiled" camera for use in rendering.
Definition camera.h:51
CompiledGeom_TransformInstance(CompiledGeom_TransformInstance &&)=delete
CompiledGeom_TransformInstance(const CompiledGeom_TransformInstance &)=delete
std::unordered_set< core::VertexType > debug_types
Definition world.h:53
void operator=(CompiledGeom_TransformInstance &&)=delete
CompiledGeom_TransformInstance(u32, std::size_t, u32, u32, u32, const core::CompiledGeomVertexAttributes &, i32)
void operator=(const CompiledGeom_TransformInstance &)=delete
Represents a Geom on the GPU.
Definition world.h:27
void operator=(CompiledGeom &&)=delete
CompiledGeom(const CompiledGeom &)=delete
CompiledGeom(CompiledGeom &&)=delete
void operator=(const CompiledGeom &)=delete
CompiledGeom(u32, u32, u32, const core::CompiledGeomVertexAttributes &, i32)
std::unordered_set< core::VertexType > debug_types
Definition world.h:32
A directional light,.
Definition world.h:128
Like a spotlight but can be positioned with a transform, supports light cookies and can use a "view f...
Definition world.h:153
core::SCurve curve
curve and ui, needs to be trimmed down for actual renderer
Definition world.h:166
std::shared_ptr< Texture2d > cookie
Definition world.h:172
All lights in a world.
Definition world.h:177
float shadow_near
Definition world.h:181
float shadow_size
Definition world.h:184
float shadow_offset
Definition world.h:182
std::vector< PointLight > point_lights
Definition world.h:187
std::vector< DirectionalLight > directional_lights
Definition world.h:186
float ambient_strength
Definition world.h:179
std::vector< FrustumLight > frustum_lights
Definition world.h:188
Stores Geom + Material (aka a mesh) and its current transform but instanced for faster rendering.
Definition world.h:109
std::shared_ptr< Material > material
Definition world.h:111
std::shared_ptr< CompiledGeom_TransformInstance > geom
Definition world.h:110
Stores Geom + Material (aka a mesh) and its current transform.
Definition world.h:90
std::shared_ptr< CompiledGeom > geom
Definition world.h:91
Billboarding billboarding
if not none, rotation is ignored
Definition world.h:97
LocalAxis get_local_axis() const
std::optional< Rgb > outline
Definition world.h:94
std::shared_ptr< Material > material
Definition world.h:92
A point light.
Definition world.h:138
core::SCurve curve
curve and ui, needs to be trimmed down for actual renderer
Definition world.h:142
A skybox model with a cubemap texture.
Definition world.h:193
std::shared_ptr< CompiledGeom > geom
Definition world.h:194
std::shared_ptr< TextureCubemap > cubemap
Definition world.h:195
A list of objects to render.
Definition world.h:201
std::optional< Skybox > skybox
Definition world.h:207
std::vector< std::shared_ptr< MeshInstance > > meshes
Definition world.h:202
std::vector< std::shared_ptr< MeshInstance_TransformInstanced > > instances
Definition world.h:203
Lights lights
Definition world.h:204
a 3d vector
Definition vec3.h:27