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
136constexpr core::SCurve default_light_curve = { 5.0f, 1.0f };
137
140{
141 v3 position = {0.0f, 0.0f, 0.0f};
142 float min_range = 10.0f;
143 float max_range = 20.0f;
145
147 float specular_strength = 1.0f;
148 float diffuse_strength = 1.0f;
149};
150
152
155{
156 v3 position = {0.0f, 0.0f, 0.0f};
158 {
159 .yaw = 0.0_rad,
160 .pitch = 0.0_rad,
161 .roll = 0.0_rad
162 };
163 An fov = 10.0_deg;
164 float aspect = 1.0;
165
166 float min_range = 10.0f;
167 float max_range = 20.0f;
169
171 float specular_strength = 1.0f;
172 float diffuse_strength = 1.0f;
173
174 std::shared_ptr<Texture2d> cookie; // if null, pure white is used
175};
176
178struct Lights
179{
181 float ambient_strength = 0.029f;
182
183 float shadow_near = 1.0f;
184 float shadow_offset = 50.0f;
185 float shadow_far = 200.0f;
186 float shadow_size = 70.0f;
187
188 std::vector<DirectionalLight> directional_lights;
189 std::vector<PointLight> point_lights;
190 std::vector<FrustumLight> frustum_lights;
191};
192
194struct Skybox
195{
196 std::shared_ptr<CompiledGeom> geom = nullptr;
197 std::shared_ptr<TextureCubemap> cubemap = nullptr;
198};
199
202struct World
203{
204 std::vector<std::shared_ptr<MeshInstance>> meshes;
205 std::vector<std::shared_ptr<MeshInstance_TransformInstanced>> instances;
207
209 std::optional<Skybox> skybox;
210};
211
215
216} // namespace eu::render
#define DEBUG_LABEL_ARG_MANY
first debug label argument of many
constexpr m4 m4_identity
The identity matrix.
Definition mat4.h:190
constexpr core::SCurve default_light_curve
Definition world.h:136
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:6
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
4x4 matrix
Definition mat4.h:26
A temporary view of the local space of a camera.
Definition space.h:8
A "compiled" camera for use in rendering.
Definition camera.h:44
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:155
core::SCurve curve
curve and ui, needs to be trimmed down for actual renderer
Definition world.h:168
std::shared_ptr< Texture2d > cookie
Definition world.h:174
All lights in a world.
Definition world.h:179
float shadow_near
Definition world.h:183
float shadow_size
Definition world.h:186
float shadow_offset
Definition world.h:184
std::vector< PointLight > point_lights
Definition world.h:189
std::vector< DirectionalLight > directional_lights
Definition world.h:188
float ambient_strength
Definition world.h:181
std::vector< FrustumLight > frustum_lights
Definition world.h:190
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:140
core::SCurve curve
curve and ui, needs to be trimmed down for actual renderer
Definition world.h:144
A skybox model with a cubemap texture.
Definition world.h:195
std::shared_ptr< CompiledGeom > geom
Definition world.h:196
std::shared_ptr< TextureCubemap > cubemap
Definition world.h:197
A list of objects to render.
Definition world.h:203
std::optional< Skybox > skybox
Definition world.h:209
std::vector< std::shared_ptr< MeshInstance > > meshes
Definition world.h:204
std::vector< std::shared_ptr< MeshInstance_TransformInstanced > > instances
Definition world.h:205
Lights lights
Definition world.h:206
a 3d vector
Definition vec3.h:27