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 = math::color(255, 244, 214, 255);
209 float intensity = 5.0f;
210
212 bool casts_shadows{true};
213
218 {
226 float near_plane{0.2f};
228 float far_plane{550.0f};
230 float bias{0.00100f};
232 float normal_bias{0.1300f};
233
238 {
239 // Hard shadows don't require any special parameters
240 };
241
246 {
248 float x_offset{1.0f};
250 float y_offset{1.0f};
251 };
252
257 {
259 float penumbra_x_offset{1.0f};
261 float penumbra_y_offset{1.5f};
262 };
263
268 {
270 float min_variance{0.02f};
272 float depth_multiplier{450.0f};
274 bool do_blur{true};
276 float blur_x_offset{1.0f};
278 float blur_y_offset{1.0f};
279 };
280
285 {
287 float hardness{0.7f};
289 float depth_multiplier{9000.0f};
291 bool do_blur{true};
293 float blur_x_offset{1.0f};
295 float blur_y_offset{1.0f};
296 };
297
298
304
305
307 bool show_coverage{false};
308
309
310
312
313
323
325 {
327 float fov_x_adjust = 0.0f;
329 float fov_y_adjust = 0.0f;
331 bool stencil_pack = false;
332
334
338
345 {
347 bool enabled{false};
350 float ray_length{0.2f};
353 float thickness{0.15f};
357 float n_dot_l_fade_end{0.475f};
362};
363
364} // 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
Struct representing contact shadow parameters. Screen-space ray-marched shadows that add fine detail ...
Definition light.h:345
float n_dot_l_fade_start
N·L smoothstep low edge: below this, contact shadow fades out (surface faces away from light).
Definition light.h:355
bool enabled
Whether contact shadows are enabled for this light.
Definition light.h:347
float n_dot_l_fade_end
N·L smoothstep high edge: at or above this, contact shadow has full strength.
Definition light.h:357
uint8_t num_splits
Number of splits for cascade shadow maps.
Definition light.h:319
float split_distribution
Split distribution for cascade shadow maps.
Definition light.h:317
bool stabilize
Whether to stabilize the shadow map.
Definition light.h:321
Struct representing directional light specific properties.
Definition light.h:185
float fov_y_adjust
Field of view y-axis adjustment.
Definition light.h:329
bool stencil_pack
Whether to use stencil packing.
Definition light.h:331
float fov_x_adjust
Field of view x-axis adjustment.
Definition light.h:327
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 implementation parameters for ESM shadow mapping.
Definition light.h:285
float blur_x_offset
Blur offset along the x-axis.
Definition light.h:293
float depth_multiplier
Depth multiplier for ESM.
Definition light.h:289
bool do_blur
Whether to blur the shadow map.
Definition light.h:291
float hardness
ESM hardness parameter.
Definition light.h:287
float blur_y_offset
Blur offset along the y-axis.
Definition light.h:295
Struct representing implementation parameters for hard shadow mapping.
Definition light.h:238
Struct representing implementation parameters for PCF shadow mapping.
Definition light.h:246
float y_offset
Offset along the y-axis for PCF sampling.
Definition light.h:250
float x_offset
Offset along the x-axis for PCF sampling.
Definition light.h:248
Struct representing implementation parameters for PCSS shadow mapping.
Definition light.h:257
float penumbra_x_offset
Offset along the x-axis for PCSS sampling.
Definition light.h:259
float penumbra_y_offset
Offset along the y-axis for PCSS sampling.
Definition light.h:261
Struct representing implementation parameters for VSM shadow mapping.
Definition light.h:268
float blur_x_offset
Blur offset along the x-axis.
Definition light.h:276
float depth_multiplier
Depth multiplier for VSM.
Definition light.h:272
float min_variance
Minimum variance for VSM filtering.
Definition light.h:270
float blur_y_offset
Blur offset along the y-axis.
Definition light.h:278
bool do_blur
Whether to blur the shadow map.
Definition light.h:274
Struct representing common shadow map parameters.
Definition light.h:218
float near_plane
Near plane distance for shadow mapping.
Definition light.h:226
float bias
Bias for shadow mapping.
Definition light.h:230
float normal_bias
Normal bias for shadow mapping.
Definition light.h:232
float far_plane
Far plane distance for shadow mapping.
Definition light.h:228
sm_resolution resolution
Resolution of the shadow map.
Definition light.h:224
sm_depth depth
Depth method for shadow mapping.
Definition light.h:220
sm_impl type
Implementation type for shadow mapping.
Definition light.h:222
bool show_coverage
Whether to show shadow map coverage.
Definition light.h:307
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:212
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
struct unravel::light::contact_shadow_params contact_shadow
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
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