Euphoria
world.h
Go to the documentation of this file.
1#pragma once
2#include "eu/core/scurve.h"
3
6#include "eu/render/space.h"
7
8#include <unordered_set>
9
10namespace eu::core
11{
12 struct Geom;
13}
14
15namespace eu::render
16{
17
25{
30 std::unordered_set<core::VertexType> debug_types;
31
34
35 CompiledGeom(const CompiledGeom&) = delete;
37 void operator=(const CompiledGeom&) = delete;
38 void operator=(CompiledGeom&&) = delete;
39};
40
61
62std::shared_ptr<CompiledGeom> compile_geom(DEBUG_LABEL_ARG_MANY const core::Geom&, const core::CompiledGeomVertexAttributes& layout);
63std::shared_ptr<CompiledGeom_TransformInstance> compile_geom_with_transform_instance(
65 const core::Geom&, const core::CompiledGeomVertexAttributes& layout, std::size_t max_instances
66);
67
68// todo(Gustav): merge with CameraVectors... this has a better name
70{
74};
75
77enum class Billboarding
78{
79 none,
80 screen,
82 axial_y,
84};
85
88{
89 std::shared_ptr<CompiledGeom> geom;
90 std::shared_ptr<Material> material;
91
92 std::optional<Rgb> outline;
93
96
98};
99
100m4 transform_from_rotation(const v3& position, const Ypr& ypr);
101m4 transform_from_billboard(const v3& position, Billboarding billboarding, const CompiledCamera& cc);
102
103std::shared_ptr<MeshInstance> make_mesh_instance(std::shared_ptr<CompiledGeom> geom, std::shared_ptr<Material> mat);
104
107{
108 std::shared_ptr<CompiledGeom_TransformInstance> geom;
109 std::shared_ptr<Material> material;
110
111 //todo(Gustav): add outline
112
113 std::vector<m4> world_from_locals;
114};
115
116std::shared_ptr<MeshInstance_TransformInstanced> make_mesh_instance(
117 std::shared_ptr<CompiledGeom_TransformInstance> geom, std::shared_ptr<Material> mat
118);
119
120void render_geom(const CompiledGeom& geom);
122
123
133
136{
137 v3 position = {0.0f, 0.0f, 0.0f};
138 float min_range = 10.0f;
139 float max_range = 20.0f;
141
143 float specular_strength = 1.0f;
144 float diffuse_strength = 1.0f;
145};
146
148
151{
152 v3 position = {0.0f, 0.0f, 0.0f};
153 Ypr rotation = {0.0_rad, 0.0_rad, 0.0_rad};
154 An fov = 10.0_deg;
155 float aspect = 1.0;
156
157 float min_range = 10.0f;
158 float max_range = 20.0f;
160
162 float specular_strength = 1.0f;
163 float diffuse_strength = 1.0f;
164
165 std::shared_ptr<Texture2d> cookie; // if null, pure white is used
166};
167
169struct Lights
170{
172 float ambient_strength = 0.029f;
173
174 float shadow_near = 1.0f;
175 float shadow_offset = 50.0f;
176 float shadow_far = 200.0f;
177 float shadow_size = 70.0f;
178
179 std::vector<DirectionalLight> directional_lights;
180 std::vector<PointLight> point_lights;
181 std::vector<FrustumLight> frustum_lights;
182};
183
185struct Skybox
186{
187 std::shared_ptr<CompiledGeom> geom = nullptr;
188 std::shared_ptr<TextureCubemap> cubemap = nullptr;
189};
190
193struct World
194{
195 std::vector<std::shared_ptr<MeshInstance>> meshes;
196 std::vector<std::shared_ptr<MeshInstance_TransformInstanced>> instances;
198
200 std::optional<Skybox> skybox;
201};
202
207} // 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:78
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
std::int32_t i32
Definition ints.h:9
std::uint32_t u32
Definition ints.h:14
An angle in both degrees and radians.
Definition angle.h:13
A (inclusive) range between two values.
Definition range.h:19
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:10
A "compiled" camera for use in rendering.
Definition camera.h:41
Represents a Geom on the GPU, instanced on a transform.
Definition world.h:43
CompiledGeom_TransformInstance(CompiledGeom_TransformInstance &&)=delete
CompiledGeom_TransformInstance(const CompiledGeom_TransformInstance &)=delete
std::unordered_set< core::VertexType > debug_types
Definition world.h:51
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:25
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:30
A directional light,.
Definition world.h:126
Like a spotlight but can be positioned with a transform, supports light cookies and can use a "view f...
Definition world.h:151
core::SCurve curve
curve and ui, needs to be trimmed down for actual renderer
Definition world.h:159
std::shared_ptr< Texture2d > cookie
Definition world.h:165
All lights in a world.
Definition world.h:170
float shadow_near
Definition world.h:174
float shadow_size
Definition world.h:177
float shadow_offset
Definition world.h:175
std::vector< PointLight > point_lights
Definition world.h:180
std::vector< DirectionalLight > directional_lights
Definition world.h:179
float ambient_strength
Definition world.h:172
std::vector< FrustumLight > frustum_lights
Definition world.h:181
Stores Geom + Material (aka a mesh) and its current transform but instanced for faster rendering.
Definition world.h:107
std::shared_ptr< Material > material
Definition world.h:109
std::shared_ptr< CompiledGeom_TransformInstance > geom
Definition world.h:108
Stores Geom + Material (aka a mesh) and its current transform.
Definition world.h:88
std::shared_ptr< CompiledGeom > geom
Definition world.h:89
Billboarding billboarding
if not none, rotation is ignored
Definition world.h:95
LocalAxis get_local_axis() const
std::optional< Rgb > outline
Definition world.h:92
std::shared_ptr< Material > material
Definition world.h:90
A point light.
Definition world.h:136
core::SCurve curve
curve and ui, needs to be trimmed down for actual renderer
Definition world.h:140
A skybox model with a cubemap texture.
Definition world.h:186
std::shared_ptr< CompiledGeom > geom
Definition world.h:187
std::shared_ptr< TextureCubemap > cubemap
Definition world.h:188
A list of objects to render.
Definition world.h:194
std::optional< Skybox > skybox
Definition world.h:200
std::vector< std::shared_ptr< MeshInstance > > meshes
Definition world.h:195
std::vector< std::shared_ptr< MeshInstance_TransformInstanced > > instances
Definition world.h:196
Lights lights
Definition world.h:197
a 3d vector
Definition vec3.h:27