Unravel Engine C++ Reference
Loading...
Searching...
No Matches
light.h
Go to the documentation of this file.
1#pragma once
2
3#include <engine/engine_export.h>
4
5#include <cstdint>
6#include <math/math.h>
7
8namespace unravel
9{
13enum class light_type : uint8_t
14{
15 spot = 0,
16 point = 1,
17 directional = 2,
18
19 count
20};
21
25enum class sm_depth : uint8_t
26{
27 invz = 0,
28 linear = 1,
29
30 count
31};
32
36enum class pack_depth : uint8_t
37{
38 rgba = 0,
39 vsm = 1,
40
41 count
42};
43
47enum class sm_impl : uint8_t
48{
49 hard = 0,
50 pcf = 1,
51 pcss = 2,
52 vsm = 3,
53 esm = 4,
54
55 count,
56};
57
61enum class sm_type : uint8_t
62{
63 single = 0,
64 omni = 1,
65 cascade = 2,
66
67 count
68};
69
73enum class sm_resolution : uint8_t
74{
75 low,
76 medium,
77 high,
79
80 count
81};
82
86struct light
87{
90
94 struct spot
95 {
100 void set_range(float r);
101
106 float get_range() const
107 {
108 return range;
109 }
110
115 void set_outer_angle(float angle);
116
121 float get_outer_angle() const
122 {
123 return outer_angle;
124 }
125
130 void set_inner_angle(float angle);
131
136 float get_inner_angle() const
137 {
138 return inner_angle;
139 }
140
142 float range = 10.0f;
144 float outer_angle = 60.0f;
146 float inner_angle = 30.0f;
147
151 // struct shadowmap_params
152 // {
153 // } shadow_params{};
154 };
155
159 struct point
160 {
162 float range = 10.0f;
164 float exponent_falloff = 1.0f;
165
169 // struct shadowmap_params
170 // {
171 // /// Field of view x-axis adjustment.
172 // float fov_x_adjust = 0.0f;
173 // /// Field of view y-axis adjustment.
174 // float fov_y_adjust = 0.0f;
175 // /// Whether to use stencil packing.
176 // bool stencil_pack = false;
177
178 // } shadow_params{};
179 };
180
185 {
189 // struct shadowmap_params
190 // {
191 // /// Split distribution for cascade shadow maps.
192 // float split_distribution = 0.8f;
193 // /// Number of splits for cascade shadow maps.
194 // uint8_t num_splits = 4;
195 // /// Whether to stabilize the shadow map.
196 // bool stabilize = true;
197 // } shadow_params{};
198 };
199
207 math::color color = {1.0f, 1.0f, 1.0f, 1.0f};
209 float intensity = 2.5f;
210
212 float ambient_intensity = 0.0f;
213
215 bool casts_shadows{true};
216
221 {
229 float near_plane{0.2f};
231 float far_plane{550.0f};
233 float bias{0.00110f};
235 float normal_bias{0.015f};
236
237
238 // struct impl_params
239 // {
240 // /// Custom parameter 0 for shadow mapping.
241 // float hardness{};
242 // /// Custom parameter 1 for shadow mapping.
243 // float depth_multiplier{};
244 // /// Number of shadow maps along the x-axis.
245 // float blur_x_num{2};
246 // /// Number of shadow maps along the y-axis.
247 // float blur_y_num{2};
248 // /// Offset along the x-axis for shadow mapping.
249 // float blur_x_offset{1};
250 // /// Offset along the y-axis for shadow mapping.
251 // float blur_y_offset{1};
252 // /// Whether to perform blur on the shadow map.
253 // bool do_blur{true};
254 // } impl;
255
256
258 bool show_coverage{false};
259
261
262
272
274 {
276 float fov_x_adjust = 0.0f;
278 float fov_y_adjust = 0.0f;
280 bool stencil_pack = false;
281
283
287};
288
289} // namespace unravel
sm_type
Enum representing the type of shadow map.
Definition light.h:62
sm_resolution
Enum representing the resolution of shadow maps.
Definition light.h:74
sm_impl
Enum representing the implementation type for shadow mapping.
Definition light.h:48
sm_depth
Enum representing the depth method for shadow mapping.
Definition light.h:26
light_type
Enum representing the type of light.
Definition light.h:14
pack_depth
Enum representing the packing method for depth in shadow mapping.
Definition light.h:37
uint8_t num_splits
Number of splits for cascade shadow maps.
Definition light.h:268
float split_distribution
Split distribution for cascade shadow maps.
Definition light.h:266
bool stabilize
Whether to stabilize the shadow map.
Definition light.h:270
Struct representing directional light specific properties.
Definition light.h:185
float fov_y_adjust
Field of view y-axis adjustment.
Definition light.h:278
bool stencil_pack
Whether to use stencil packing.
Definition light.h:280
float fov_x_adjust
Field of view x-axis adjustment.
Definition light.h:276
Struct representing point light specific properties.
Definition light.h:160
float exponent_falloff
The exponent falloff for the point light.
Definition light.h:164
Struct representing common shadow map parameters.
Definition light.h:221
float near_plane
Near plane distance for shadow mapping.
Definition light.h:229
float bias
Bias for shadow mapping.
Definition light.h:233
float normal_bias
Normal bias for shadow mapping.
Definition light.h:235
float far_plane
Far plane distance for shadow mapping.
Definition light.h:231
sm_resolution resolution
Resolution of the shadow map.
Definition light.h:227
sm_depth depth
Depth method for shadow mapping.
Definition light.h:223
sm_impl type
Implementation type for shadow mapping.
Definition light.h:225
bool show_coverage
Whether to show shadow map coverage.
Definition light.h:258
Struct representing spot light specific properties.
Definition light.h:95
void set_inner_angle(float angle)
Sets the inner angle of the spot light.
Definition light.cpp:21
void set_outer_angle(float angle)
Sets the outer angle of the spot light.
Definition light.cpp:13
float outer_angle
The outer angle of the spot light.
Definition light.h:144
float inner_angle
The inner angle of the spot light.
Definition light.h:146
float get_range() const
Gets the range of the spot light.
Definition light.h:106
void set_range(float r)
Sets the range of the spot light.
Definition light.cpp:5
float get_outer_angle() const
Gets the outer angle of the spot light.
Definition light.h:121
float get_inner_angle() const
Gets the inner angle of the spot light.
Definition light.h:136
float range
The range of the spot light.
Definition light.h:142
Struct representing a light.
Definition light.h:87
bool casts_shadows
Whether the light casts shadows.
Definition light.h:215
struct unravel::light::directional_shadowmap_params directional_shadow_params
struct unravel::light::shadowmap_params shadow_params
float intensity
The intensity of the light.
Definition light.h:209
light_type type
The type of the light.
Definition light.h:89
math::color color
The color of the light.
Definition light.h:207
point point_data
Data specific to point lights.
Definition light.h:203
float ambient_intensity
The ambient intensity of the light.
Definition light.h:212
directional directional_data
Data specific to directional lights.
Definition light.h:205
struct unravel::light::point_shadowmap_params point_shadow_params
spot spot_data
Data specific to spot lights.
Definition light.h:201
struct unravel::light::spot_shadowmap_params spot_shadow_params