| TGX 1.1.3 A tiny 2D/3D graphics library optimized for 32 bits microcontrollers.

Loading...
Searching...
No Matches
Renderer3DSpotLightData.h
Go to the documentation of this file.
1
5//
6// Copyright 2020 Arvind Singh
7//
8// This library is free software; you can redistribute it and/or
9// modify it under the terms of the GNU Lesser General Public
10// License as published by the Free Software Foundation; either
11// version 2.1 of the License, or (at your option) any later version.
12//
13// This library is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the GNU
16// Lesser General Public License for more details.
17//
18// You should have received a copy of the GNU Lesser General Public
19// License along with this library; If not, see <http://www.gnu.org/licenses/>.
20
21#ifndef _TGX_RENDERER3D_SPOT_LIGHT_DATA_H_
22#define _TGX_RENDERER3D_SPOT_LIGHT_DATA_H_
23
24// only C++, no plain C
25#ifdef __cplusplus
26
27#include "tgx_config.h"
28#include "Color.h"
29#include "Vec3.h"
30
31 namespace tgx
32{
33
34 namespace Renderer3D_detail
35 {
36
37 enum SpotLightFlag
38 {
39 SPOT_LIGHT_CONE_ENABLED = 1u << 0,
40 SPOT_LIGHT_SOFT_CONE = 1u << 1,
41 SPOT_LIGHT_RUNTIME_SPECULAR_ENABLED = 1u << 2
42 };
43
44
45 enum SpotLightGlobalFlag
46 {
47 SPOT_LIGHT_GLOBAL_RUNTIME_SPECULAR = 1u << 0,
48 SPOT_LIGHT_GLOBAL_ACTIVE_CONE = 1u << 1
49 };
50
51
59 template<int MAX_SPOT_LIGHTS>
60 struct SpotLightData
61 {
62 static_assert(MAX_SPOT_LIGHTS > 0, "MAX_SPOT_LIGHTS must be positive for this specialization");
63
64 int count;
65 int globalFlags;
66
67 // User-space scene parameters.
68 fVec3 position[MAX_SPOT_LIGHTS];
69 fVec3 direction[MAX_SPOT_LIGHTS];
70 RGBf diffuseColor[MAX_SPOT_LIGHTS];
71 RGBf specularColor[MAX_SPOT_LIGHTS];
72
73 int flags[MAX_SPOT_LIGHTS];
74
75 // Precomputed range and cone constants.
76 float range2[MAX_SPOT_LIGHTS];
77 float invRange2[MAX_SPOT_LIGHTS];
78 float cosOuter[MAX_SPOT_LIGHTS];
79 float invCosWidth[MAX_SPOT_LIGHTS];
80
81 // Camera-space runtime geometry.
82 fVec3 positionView[MAX_SPOT_LIGHTS];
83 fVec3 directionView[MAX_SPOT_LIGHTS];
84
85 // Material-scaled runtime colors.
86 RGBf runtimeDiffuseColor[MAX_SPOT_LIGHTS];
87 RGBf runtimeSpecularColor[MAX_SPOT_LIGHTS];
88 };
89
90
94 template<>
95 struct SpotLightData<0>
96 {
97 };
98
99 }
100
101}
102
103#endif
104
105#endif
106
Color.h
Color classes [RGB565, RGB24, RGB32, RGB64, RGBf, HSV].
Vec3.h
3D vector.
tgx::RGBf
Color in R,G,B float format.
Definition: Color.h:2405
tgx::Renderer3D_detail::SpotLightData
Internal storage for local spot lights.
Definition: Renderer3DSpotLightData.h:61
tgx::Renderer3D_detail::SpotLightData::cosOuter
float cosOuter[MAX_SPOT_LIGHTS]
Cosine of the outer cone half-angle.
Definition: Renderer3DSpotLightData.h:78
tgx::Renderer3D_detail::SpotLightData::invCosWidth
float invCosWidth[MAX_SPOT_LIGHTS]
1 / (cos(inner) - cos(outer)), or 0 for hard cones.
Definition: Renderer3DSpotLightData.h:79
tgx::Renderer3D_detail::SpotLightData::globalFlags
int globalFlags
Bitwise OR of SpotLightGlobalFlag values.
Definition: Renderer3DSpotLightData.h:65
tgx::Renderer3D_detail::SpotLightData::flags
int flags[MAX_SPOT_LIGHTS]
Bitwise OR of SpotLightFlag values.
Definition: Renderer3DSpotLightData.h:73
tgx::Renderer3D_detail::SpotLightData::direction
fVec3 direction[MAX_SPOT_LIGHTS]
Light directions in world space.
Definition: Renderer3DSpotLightData.h:69
tgx::Renderer3D_detail::SpotLightData::invRange2
float invRange2[MAX_SPOT_LIGHTS]
Inverse squared range, or 0 for infinite range.
Definition: Renderer3DSpotLightData.h:77
tgx::Renderer3D_detail::SpotLightData::positionView
fVec3 positionView[MAX_SPOT_LIGHTS]
Light positions in view space.
Definition: Renderer3DSpotLightData.h:82
tgx::Renderer3D_detail::SpotLightData::directionView
fVec3 directionView[MAX_SPOT_LIGHTS]
Normalized light directions in view space.
Definition: Renderer3DSpotLightData.h:83
tgx::Renderer3D_detail::SpotLightData::diffuseColor
RGBf diffuseColor[MAX_SPOT_LIGHTS]
User diffuse light colors.
Definition: Renderer3DSpotLightData.h:70
tgx::Renderer3D_detail::SpotLightData::runtimeSpecularColor
RGBf runtimeSpecularColor[MAX_SPOT_LIGHTS]
specularColor multiplied by material specular strength.
Definition: Renderer3DSpotLightData.h:87
tgx::Renderer3D_detail::SpotLightData::specularColor
RGBf specularColor[MAX_SPOT_LIGHTS]
User specular light colors.
Definition: Renderer3DSpotLightData.h:71
tgx::Renderer3D_detail::SpotLightData::range2
float range2[MAX_SPOT_LIGHTS]
Squared range, or a very large value for infinite range.
Definition: Renderer3DSpotLightData.h:76
tgx::Renderer3D_detail::SpotLightData::runtimeDiffuseColor
RGBf runtimeDiffuseColor[MAX_SPOT_LIGHTS]
diffuseColor multiplied by material diffuse strength.
Definition: Renderer3DSpotLightData.h:86
tgx::Renderer3D_detail::SpotLightData::count
int count
Number of active spot-light slots.
Definition: Renderer3DSpotLightData.h:64
tgx::Renderer3D_detail::SpotLightData::position
fVec3 position[MAX_SPOT_LIGHTS]
Light positions in world space.
Definition: Renderer3DSpotLightData.h:68
tgx::Vec3< float >
tgx_config.h
Configuration file depending on the architecture.