MxEngine
RenderPipeline.h
1 // Copyright(c) 2019 - 2020, #Momo
2 // All rights reserved.
3 //
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met :
6 //
7 // 1. Redistributions of source code must retain the above copyright notice, this
8 // list of conditions and the following disclaimer.
9 //
10 // 2. Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and /or other materials provided with the distribution.
13 //
14 // 3. Neither the name of the copyright holder nor the names of its
15 // contributors may be used to endorse or promote products derived from
16 // this software without specific prior written permission.
17 //
18 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 // DISCLAIMED.IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 // DAMAGES(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 // OR TORT(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 
29 #pragma once
30 
31 #include "Platform/GraphicAPI.h"
32 #include "Rectangle.h"
33 #include "SkyboxObject.h"
34 
35 namespace MxEngine
36 {
38  {
40  size_t VertexCount;
41  };
42 
43  struct CameraUnit
44  {
45  Matrix4x4 ViewProjMatrix;
46  Matrix4x4 StaticViewProjMatrix;
47  Vector3 ViewportPosition;
48  GResource<FrameBuffer> FrameBufferMSAA;
49  GResource<FrameBuffer> FrameBufferHDR;
50  GResource<Texture> BloomTextureHDR;
51  GResource<Texture> OutputTexture;
52  Matrix3x3 InversedSkyboxRotation;
53  GResource<CubeMap> SkyboxMap;
54  float BloomWeight;
55  float Exposure;
56 
57  bool IsPerspective;
58  bool RenderToTexture;
59  uint8_t BloomIterations;
60  };
61 
63  {
64  GResource<Shader> MainShader;
65  GResource<Shader> SkyboxShader;
66  GResource<Shader> ShadowMapShader;
67  GResource<Shader> ShadowCubeMapShader;
68  GResource<Shader> MSAAHDRSplitShader;
69  GResource<Shader> HDRSplitShader;
70  GResource<Shader> BloomShader;
71  GResource<Shader> HDRBloomCombineHDRShader;
72  GResource<Shader> ImageForwardShader;
73  GResource<Shader> DebugDrawShader;
74 
75  GResource<Texture> DefaultMaterialMap;
76  GResource<Texture> DefaultNormalMap;
77  GResource<Texture> DefaultHeightMap;
78  GResource<Texture> DefaultBlackMap;
79  GResource<CubeMap> DefaultBlackCubeMap;
80 
81  GResource<FrameBuffer> DepthFrameBuffer;
82  GResource<FrameBuffer> PostProcessFrameBuffer;
83  std::array<GResource<FrameBuffer>, 2> BloomBuffers;
84 
85  SkyboxObject SkyboxCubeObject;
86  DebugBufferUnit DebugBufferObject;
87  Rectangle RectangularObject;
88  VectorInt2 Viewport;
89 
90  Vector3 FogColor;
91  float FogDistance;
92  float FogDensity;
93 
94  uint8_t ShadowBlurIterations;
95  uint8_t MainCameraIndex;
96  bool OverlayDebugDraws;
97  bool RenderToDefaultFrameBuffer;
98  };
99 
101  {
102  GResource<Texture> ShadowMap;
103  Matrix4x4 ProjectionMatrix;
104  Matrix4x4 BiasedProjectionMatrix;
105  Vector3 Direction;
106  Vector3 AmbientColor;
107  Vector3 DiffuseColor;
108  Vector3 SpecularColor;
109  };
110 
112  {
113  GResource<CubeMap> ShadowMap;
114  Matrix4x4 ProjectionMatrices[6];
115  Vector3 Position;
116  float FarDistance;
117  Vector3 Factors;
118  Vector3 AmbientColor;
119  Vector3 DiffuseColor;
120  Vector3 SpecularColor;
121  };
122 
124  {
125  GResource<Texture> ShadowMap;
126  Matrix4x4 ProjectionMatrix;
127  Matrix4x4 BiasedProjectionMatrix;
128  Vector3 Position;
129  Vector3 AmbientColor;
130  Vector3 DiffuseColor;
131  Vector3 SpecularColor;
132  Vector3 Direction;
133  float InnerAngleCos;
134  float OuterAngleCos;
135  };
136 
138  {
139  MxVector<DirectionalLigthUnit> DirectionalLights;
140  MxVector<PointLightUnit> PointLights;
141  MxVector<SpotLightUnit> SpotLights;
142  };
143 
144  struct RenderUnit
145  {
148 
149  Material RenderMaterial;
150 
151  Matrix4x4 ModelMatrix;
152  Matrix3x3 NormalMatrix;
153 
154  size_t InstanceCount;
155  };
156 
158  {
159  EnvironmentUnit Environment;
160  LightingSystem Lighting;
161  MxVector<RenderUnit> OpaqueRenderUnits;
162  MxVector<RenderUnit> TransparentRenderUnits;
163  MxVector<CameraUnit> Cameras;
164  };
165 }
Definition: AbstractFactory.h:61
Definition: RenderPipeline.h:123
Definition: RenderPipeline.h:43
Definition: Material.h:38
Definition: SkyboxObject.h:35
Definition: RenderPipeline.h:157
Definition: Rectangle.h:35
Definition: RenderPipeline.h:111
Definition: RenderPipeline.h:137
Definition: RenderPipeline.h:62
Definition: RenderPipeline.h:100
Definition: RenderPipeline.h:37
Definition: Application.cpp:49
Definition: RenderPipeline.h:144