-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathLightingData.h
More file actions
80 lines (73 loc) · 2.45 KB
/
Copy pathLightingData.h
File metadata and controls
80 lines (73 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#ifndef GAME_ENGINE_LIGHTING_DATA_H
#define GAME_ENGINE_LIGHTING_DATA_H
#include "CoreLib/VectorMath.h"
#include "CoreLib/Basic.h"
#include "HardwareRenderer.h"
#include "PipelineContext.h"
#include "Level.h"
#include "RenderProcedure.h"
#include "StandardViewUniforms.h"
namespace GameEngine
{
const unsigned short GpuLightType_Point = 0;
const unsigned short GpuLightType_Directional = 1;
const unsigned short GpuLightType_Spot = 2;
struct GpuLightData
{
unsigned short lightType;
unsigned short shaderMapId;
float radius;
float decay;
float startAngle;
VectorMath::Vec3 position;
float endAngle;
VectorMath::Vec3 color;
unsigned int direction;
VectorMath::Matrix4 lightMatrix;
};
struct GpuLightProbeData
{
VectorMath::Vec3 position;
float radius;
VectorMath::Vec3 tintColor;
int envMapId;
};
struct LightingUniform
{
VectorMath::Vec3 lightColor; float padding0;
VectorMath::Vec3 lightDir; int sunLightEnabled = 0;
int shadowMapId = -1;
int numCascades = 0;
int lightCount = 0, lightProbeCount = 0;
VectorMath::Matrix4 lightMatrix[MaxShadowCascades];
float zPlanes[MaxShadowCascades];
VectorMath::Vec3 ambient = VectorMath::Vec3::Create(0.2f);
float padding1;
};
class LightingEnvironment
{
private:
bool useEnvMap = true;
CoreLib::RefPtr<TextureCubeArray> emptyEnvMapArray;
void AddShadowPass(FrameRenderTask & tasks, WorldRenderPass * shadowRenderPass, DrawableSink * sink, ShadowMapResource & shadowMapRes, int shadowMapId,
StandardViewUniforms & shadowMapView, int & shadowMapViewInstancePtr);
public:
DeviceMemory * uniformMemory;
ModuleInstance moduleInstance;
CoreLib::List<GpuLightData> lights;
CoreLib::List<GpuLightProbeData> lightProbes;
CoreLib::List<Texture*> lightProbeTextures;
CoreLib::List<CoreLib::RefPtr<Texture2D>> shadowMaps;
CoreLib::RefPtr<Buffer> lightBuffer, lightProbeBuffer;
CoreLib::List<ModuleInstance> shadowViewInstances;
CoreLib::List<Drawable*> drawableBuffer, reorderBuffer;
RendererSharedResource * sharedRes;
void* lightBufferPtr, *lightProbeBufferPtr;
int lightBufferSize, lightProbeBufferSize;
LightingUniform uniformData;
void GatherInfo(FrameRenderTask & tasks, DrawableSink * sink, const RenderProcedureParameters & params, int w, int h, StandardViewUniforms & cameraView, WorldRenderPass * shadowPass);
void Init(RendererSharedResource & sharedRes, DeviceMemory * uniformMemory, bool pUseEnvMap);
void UpdateSharedResourceBinding();
};
}
#endif