Skip to content

Commit 84c39f6

Browse files
committed
Updated MiniEngine to most modern version, including glTF2 support
1 parent 2956985 commit 84c39f6

File tree

506 files changed

+2091497
-7366
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

506 files changed

+2091497
-7366
lines changed

MiniEngine/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Build_VS11
1616
Build_VS12
1717
Build_VS14
1818
Build_VS15
19+
Build
1920
Packages
2021
/ModelConverter/assimp.dll
2122
Packages

MiniEngine/Core/BitonicSort.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,21 +33,21 @@ namespace BitonicSort
3333
IndirectArgsBuffer s_DispatchArgs;
3434

3535
RootSignature s_RootSignature;
36-
ComputePSO s_BitonicIndirectArgsCS;
37-
ComputePSO s_Bitonic32PreSortCS;
38-
ComputePSO s_Bitonic32InnerSortCS;
39-
ComputePSO s_Bitonic32OuterSortCS;
40-
ComputePSO s_Bitonic64PreSortCS;
41-
ComputePSO s_Bitonic64InnerSortCS;
42-
ComputePSO s_Bitonic64OuterSortCS;
36+
ComputePSO s_BitonicIndirectArgsCS(L"Bitonic Sort: Indirect Args CS");
37+
ComputePSO s_Bitonic32PreSortCS(L"Bitonic Sort: 32 Pre Sort CS");
38+
ComputePSO s_Bitonic32InnerSortCS(L"Bitonic Sort: 32 Inner Sort CS");
39+
ComputePSO s_Bitonic32OuterSortCS(L"Bitonic Sort: 32 Outer Sort CS");
40+
ComputePSO s_Bitonic64PreSortCS(L"Bitonic Sort: 64 Pre Sort CS");
41+
ComputePSO s_Bitonic64InnerSortCS(L"Bitonic Sort: 64 Inner Sort CS");
42+
ComputePSO s_Bitonic64OuterSortCS(L"Bitonic Sort: 64 Outer Sort CS");
4343

4444
// Called once by Core to initialize shaders
4545
void Initialize(void);
4646
void Shutdown(void);
4747
}
4848

4949
void BitonicSort::Initialize( void )
50-
{
50+
{
5151
s_DispatchArgs.Create(L"Bitonic sort dispatch args", 22*23/2, 12);
5252

5353
s_RootSignature.Reset(4, 0);

MiniEngine/Core/BufferManager.cpp

Lines changed: 30 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
#include "pch.h"
1515
#include "BufferManager.h"
16-
#include "GraphicsCore.h"
16+
#include "Display.h"
1717
#include "CommandContext.h"
1818
#include "EsramAllocator.h"
1919
#include "TemporalEffects.h"
@@ -66,14 +66,15 @@ namespace Graphics
6666
ColorBuffer g_MotionPrepBuffer;
6767
ColorBuffer g_LumaBuffer;
6868
ColorBuffer g_TemporalColor[2];
69-
ColorBuffer g_aBloomUAV1[2]; // 640x384 (1/3)
70-
ColorBuffer g_aBloomUAV2[2]; // 320x192 (1/6)
71-
ColorBuffer g_aBloomUAV3[2]; // 160x96 (1/12)
72-
ColorBuffer g_aBloomUAV4[2]; // 80x48 (1/24)
73-
ColorBuffer g_aBloomUAV5[2]; // 40x24 (1/48)
69+
ColorBuffer g_TemporalMinBound;
70+
ColorBuffer g_TemporalMaxBound;
71+
ColorBuffer g_aBloomUAV1[2]; // 640x384 (1/3)
72+
ColorBuffer g_aBloomUAV2[2]; // 320x192 (1/6)
73+
ColorBuffer g_aBloomUAV3[2]; // 160x96 (1/12)
74+
ColorBuffer g_aBloomUAV4[2]; // 80x48 (1/24)
75+
ColorBuffer g_aBloomUAV5[2]; // 40x24 (1/48)
7476
ColorBuffer g_LumaLR;
7577
ByteAddressBuffer g_Histogram;
76-
ByteAddressBuffer g_FXAAWorkCounters;
7778
ByteAddressBuffer g_FXAAWorkQueue;
7879
TypedBuffer g_FXAAColorQueue(DXGI_FORMAT_R11G11B10_FLOAT);
7980

@@ -112,7 +113,7 @@ void Graphics::InitializeRenderingBuffers( uint32_t bufferWidth, uint32_t buffer
112113
g_VelocityBuffer.Create( L"Motion Vectors", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R32_UINT );
113114
g_PostEffectsBuffer.Create( L"Post Effects Buffer", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R32_UINT );
114115

115-
esram.PushStack(); // Render HDR image
116+
esram.PushStack(); // Render HDR image
116117

117118
g_LinearDepth[0].Create( L"Linear Depth 0", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R16_UNORM );
118119
g_LinearDepth[1].Create( L"Linear Depth 1", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R16_UNORM );
@@ -148,13 +149,13 @@ void Graphics::InitializeRenderingBuffers( uint32_t bufferWidth, uint32_t buffer
148149
g_AOHighQuality2.Create( L"AO High Quality 2", bufferWidth2, bufferHeight2, 1, DXGI_FORMAT_R8_UNORM, esram );
149150
g_AOHighQuality3.Create( L"AO High Quality 3", bufferWidth3, bufferHeight3, 1, DXGI_FORMAT_R8_UNORM, esram );
150151
g_AOHighQuality4.Create( L"AO High Quality 4", bufferWidth4, bufferHeight4, 1, DXGI_FORMAT_R8_UNORM, esram );
151-
esram.PopStack(); // End generating SSAO
152+
esram.PopStack(); // End generating SSAO
152153

153154
g_ShadowBuffer.Create( L"Shadow Map", 2048, 2048, esram );
154155

155-
esram.PopStack(); // End Shading
156+
esram.PopStack(); // End Shading
156157

157-
esram.PushStack(); // Begin depth of field
158+
esram.PushStack(); // Begin depth of field
158159
g_DoFTileClass[0].Create(L"DoF Tile Classification Buffer 0", bufferWidth4, bufferHeight4, 1, DXGI_FORMAT_R11G11B10_FLOAT);
159160
g_DoFTileClass[1].Create(L"DoF Tile Classification Buffer 1", bufferWidth4, bufferHeight4, 1, DXGI_FORMAT_R11G11B10_FLOAT);
160161

@@ -167,21 +168,24 @@ void Graphics::InitializeRenderingBuffers( uint32_t bufferWidth, uint32_t buffer
167168
g_DoFWorkQueue.Create(L"DoF Work Queue", bufferWidth4 * bufferHeight4, 4, esram );
168169
g_DoFFastQueue.Create(L"DoF Fast Queue", bufferWidth4 * bufferHeight4, 4, esram );
169170
g_DoFFixupQueue.Create(L"DoF Fixup Queue", bufferWidth4 * bufferHeight4, 4, esram );
170-
esram.PopStack(); // End depth of field
171+
esram.PopStack(); // End depth of field
171172

172173
g_TemporalColor[0].Create( L"Temporal Color 0", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R16G16B16A16_FLOAT);
173174
g_TemporalColor[1].Create( L"Temporal Color 1", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R16G16B16A16_FLOAT);
174175
TemporalEffects::ClearHistory(InitContext);
175176

176-
esram.PushStack(); // Begin motion blur
177+
g_TemporalMinBound.Create( L"Temporal Min Color", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R11G11B10_FLOAT);
178+
g_TemporalMaxBound.Create( L"Temporal Max Color", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R11G11B10_FLOAT);
179+
180+
esram.PushStack(); // Begin motion blur
177181
g_MotionPrepBuffer.Create( L"Motion Blur Prep", bufferWidth1, bufferHeight1, 1, HDR_MOTION_FORMAT, esram );
178-
esram.PopStack(); // End motion blur
182+
esram.PopStack(); // End motion blur
179183

180-
esram.PopStack(); // End opaque geometry
184+
esram.PopStack(); // End opaque geometry
181185

182-
esram.PopStack(); // End HDR image
186+
esram.PopStack(); // End HDR image
183187

184-
esram.PushStack(); // Begin post processing
188+
esram.PushStack(); // Begin post processing
185189

186190
// This is useful for storing per-pixel weights such as motion strength or pixel luminance
187191
g_LumaBuffer.Create( L"Luminance", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R8_UNORM, esram );
@@ -194,7 +198,7 @@ void Graphics::InitializeRenderingBuffers( uint32_t bufferWidth, uint32_t buffer
194198
uint32_t kBloomWidth = bufferWidth > 2560 ? 1280 : 640;
195199
uint32_t kBloomHeight = bufferHeight > 1440 ? 768 : 384;
196200

197-
esram.PushStack(); // Begin bloom and tone mapping
201+
esram.PushStack(); // Begin bloom and tone mapping
198202
g_LumaLR.Create( L"Luma Buffer", kBloomWidth, kBloomHeight, 1, DXGI_FORMAT_R8_UINT, esram );
199203
g_aBloomUAV1[0].Create( L"Bloom Buffer 1a", kBloomWidth, kBloomHeight, 1, DefaultHdrColorFormat, esram );
200204
g_aBloomUAV1[1].Create( L"Bloom Buffer 1b", kBloomWidth, kBloomHeight, 1, DefaultHdrColorFormat, esram);
@@ -206,17 +210,15 @@ void Graphics::InitializeRenderingBuffers( uint32_t bufferWidth, uint32_t buffer
206210
g_aBloomUAV4[1].Create( L"Bloom Buffer 4b", kBloomWidth/8, kBloomHeight/8, 1, DefaultHdrColorFormat, esram );
207211
g_aBloomUAV5[0].Create( L"Bloom Buffer 5a", kBloomWidth/16, kBloomHeight/16, 1, DefaultHdrColorFormat, esram );
208212
g_aBloomUAV5[1].Create( L"Bloom Buffer 5b", kBloomWidth/16, kBloomHeight/16, 1, DefaultHdrColorFormat, esram );
209-
esram.PopStack(); // End tone mapping
213+
esram.PopStack(); // End tone mapping
210214

211-
esram.PushStack(); // Begin antialiasing
215+
esram.PushStack(); // Begin antialiasing
212216
const uint32_t kFXAAWorkSize = bufferWidth * bufferHeight / 4 + 128;
213217
g_FXAAWorkQueue.Create( L"FXAA Work Queue", kFXAAWorkSize, sizeof(uint32_t), esram );
214218
g_FXAAColorQueue.Create( L"FXAA Color Queue", kFXAAWorkSize, sizeof(uint32_t), esram );
215-
g_FXAAWorkCounters.Create(L"FXAA Work Counters", 2, sizeof(uint32_t));
216-
InitContext.ClearUAV(g_FXAAWorkCounters);
217-
esram.PopStack(); // End antialiasing
219+
esram.PopStack(); // End antialiasing
218220

219-
esram.PopStack(); // End post processing
221+
esram.PopStack(); // End post processing
220222

221223
esram.PushStack(); // GenerateMipMaps() test
222224
g_GenMipsBuffer.Create(L"GenMips", bufferWidth, bufferHeight, 0, DXGI_FORMAT_R11G11B10_FLOAT, esram );
@@ -230,8 +232,9 @@ void Graphics::InitializeRenderingBuffers( uint32_t bufferWidth, uint32_t buffer
230232
InitContext.Finish();
231233
}
232234

233-
void Graphics::ResizeDisplayDependentBuffers(uint32_t /*NativeWidth*/, uint32_t NativeHeight)
235+
void Graphics::ResizeDisplayDependentBuffers(uint32_t NativeWidth, uint32_t NativeHeight)
234236
{
237+
(NativeWidth);
235238
g_OverlayBuffer.Create( L"UI Overlay", g_DisplayWidth, g_DisplayHeight, 1, DXGI_FORMAT_R8G8B8A8_UNORM );
236239
g_HorizontalBuffer.Create( L"Bicubic Intermediate", g_DisplayWidth, NativeHeight, 1, DefaultHdrColorFormat );
237240
}
@@ -289,6 +292,8 @@ void Graphics::DestroyRenderingBuffers()
289292
g_LumaBuffer.Destroy();
290293
g_TemporalColor[0].Destroy();
291294
g_TemporalColor[1].Destroy();
295+
g_TemporalMinBound.Destroy();
296+
g_TemporalMaxBound.Destroy();
292297
g_aBloomUAV1[0].Destroy();
293298
g_aBloomUAV1[1].Destroy();
294299
g_aBloomUAV2[0].Destroy();
@@ -301,7 +306,6 @@ void Graphics::DestroyRenderingBuffers()
301306
g_aBloomUAV5[1].Destroy();
302307
g_LumaLR.Destroy();
303308
g_Histogram.Destroy();
304-
g_FXAAWorkCounters.Destroy();
305309
g_FXAAWorkQueue.Destroy();
306310
g_FXAAColorQueue.Destroy();
307311

MiniEngine/Core/BufferManager.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ namespace Graphics
2727
extern ColorBuffer g_OverlayBuffer; // R8G8B8A8_UNORM
2828
extern ColorBuffer g_HorizontalBuffer; // For separable (bicubic) upsampling
2929

30-
extern ColorBuffer g_VelocityBuffer; // R10G10B10 (3D velocity)
30+
extern ColorBuffer g_VelocityBuffer; // R10G10B10 (3D velocity)
3131
extern ShadowBuffer g_ShadowBuffer;
3232

33-
extern ColorBuffer g_SSAOFullScreen; // R8_UNORM
34-
extern ColorBuffer g_LinearDepth[2]; // Normalized planar distance (0 at eye, 1 at far plane) computed from the SceneDepthBuffer
35-
extern ColorBuffer g_MinMaxDepth8; // Min and max depth values of 8x8 tiles
36-
extern ColorBuffer g_MinMaxDepth16; // Min and max depth values of 16x16 tiles
37-
extern ColorBuffer g_MinMaxDepth32; // Min and max depth values of 16x16 tiles
33+
extern ColorBuffer g_SSAOFullScreen; // R8_UNORM
34+
extern ColorBuffer g_LinearDepth[2]; // Normalized planar distance (0 at eye, 1 at far plane) computed from the SceneDepthBuffer
35+
extern ColorBuffer g_MinMaxDepth8; // Min and max depth values of 8x8 tiles
36+
extern ColorBuffer g_MinMaxDepth16; // Min and max depth values of 16x16 tiles
37+
extern ColorBuffer g_MinMaxDepth32; // Min and max depth values of 16x16 tiles
3838
extern ColorBuffer g_DepthDownsize1;
3939
extern ColorBuffer g_DepthDownsize2;
4040
extern ColorBuffer g_DepthDownsize3;
@@ -64,18 +64,19 @@ namespace Graphics
6464
extern StructuredBuffer g_DoFFastQueue;
6565
extern StructuredBuffer g_DoFFixupQueue;
6666

67-
extern ColorBuffer g_MotionPrepBuffer; // R10G10B10A2
67+
extern ColorBuffer g_MotionPrepBuffer; // R10G10B10A2
6868
extern ColorBuffer g_LumaBuffer;
6969
extern ColorBuffer g_TemporalColor[2];
70+
extern ColorBuffer g_TemporalMinBound;
71+
extern ColorBuffer g_TemporalMaxBound;
7072

71-
extern ColorBuffer g_aBloomUAV1[2]; // 640x384 (1/3)
72-
extern ColorBuffer g_aBloomUAV2[2]; // 320x192 (1/6)
73-
extern ColorBuffer g_aBloomUAV3[2]; // 160x96 (1/12)
74-
extern ColorBuffer g_aBloomUAV4[2]; // 80x48 (1/24)
75-
extern ColorBuffer g_aBloomUAV5[2]; // 40x24 (1/48)
73+
extern ColorBuffer g_aBloomUAV1[2]; // 640x384 (1/3)
74+
extern ColorBuffer g_aBloomUAV2[2]; // 320x192 (1/6)
75+
extern ColorBuffer g_aBloomUAV3[2]; // 160x96 (1/12)
76+
extern ColorBuffer g_aBloomUAV4[2]; // 80x48 (1/24)
77+
extern ColorBuffer g_aBloomUAV5[2]; // 40x24 (1/48)
7678
extern ColorBuffer g_LumaLR;
7779
extern ByteAddressBuffer g_Histogram;
78-
extern ByteAddressBuffer g_FXAAWorkCounters;
7980
extern ByteAddressBuffer g_FXAAWorkQueue;
8081
extern TypedBuffer g_FXAAColorQueue;
8182

MiniEngine/Core/Camera.cpp

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,29 @@ void Camera::UpdateProjMatrix( void )
6262
// Some care must also be done to properly reconstruct linear W in a pixel shader from hyperbolic Z.
6363
if (m_ReverseZ)
6464
{
65-
Q1 = m_NearClip / (m_FarClip - m_NearClip);
66-
Q2 = Q1 * m_FarClip;
65+
if (m_InfiniteZ)
66+
{
67+
Q1 = 0.0f;
68+
Q2 = m_NearClip;
69+
}
70+
else
71+
{
72+
Q1 = m_NearClip / (m_FarClip - m_NearClip);
73+
Q2 = Q1 * m_FarClip;
74+
}
6775
}
6876
else
6977
{
70-
Q1 = m_FarClip / (m_NearClip - m_FarClip);
71-
Q2 = Q1 * m_NearClip;
78+
if (m_InfiniteZ)
79+
{
80+
Q1 = -1.0f;
81+
Q2 = -m_NearClip;
82+
}
83+
else
84+
{
85+
Q1 = m_FarClip / (m_NearClip - m_FarClip);
86+
Q2 = Q1 * m_NearClip;
87+
}
7288
}
7389

7490
SetProjMatrix( Matrix4(

MiniEngine/Core/Camera.h

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -63,25 +63,25 @@ namespace Math
6363
// Transforms homogeneous coordinates from world space to view space. In this case, view space is defined as +X is
6464
// to the right, +Y is up, and -Z is forward. This has to match what the projection matrix expects, but you might
6565
// also need to know what the convention is if you work in view space in a shader.
66-
Matrix4 m_ViewMatrix; // i.e. "World-to-View" matrix
66+
Matrix4 m_ViewMatrix; // i.e. "World-to-View" matrix
6767

6868
// The projection matrix transforms view space to clip space. Once division by W has occurred, the final coordinates
6969
// can be transformed by the viewport matrix to screen space. The projection matrix is determined by the screen aspect
7070
// and camera field of view. A projection matrix can also be orthographic. In that case, field of view would be defined
7171
// in linear units, not angles.
72-
Matrix4 m_ProjMatrix; // i.e. "View-to-Projection" matrix
72+
Matrix4 m_ProjMatrix; // i.e. "View-to-Projection" matrix
7373

7474
// A concatenation of the view and projection matrices.
75-
Matrix4 m_ViewProjMatrix; // i.e. "World-To-Projection" matrix.
75+
Matrix4 m_ViewProjMatrix; // i.e. "World-To-Projection" matrix.
7676

7777
// The view-projection matrix from the previous frame
7878
Matrix4 m_PreviousViewProjMatrix;
7979

8080
// Projects a clip-space coordinate to the previous frame (useful for temporal effects).
8181
Matrix4 m_ReprojectMatrix;
8282

83-
Frustum m_FrustumVS; // View-space view frustum
84-
Frustum m_FrustumWS; // World-space view frustum
83+
Frustum m_FrustumVS; // View-space view frustum
84+
Frustum m_FrustumWS; // World-space view frustum
8585

8686
};
8787

@@ -106,11 +106,12 @@ namespace Math
106106

107107
void UpdateProjMatrix( void );
108108

109-
float m_VerticalFOV; // Field of view angle in radians
109+
float m_VerticalFOV; // Field of view angle in radians
110110
float m_AspectRatio;
111111
float m_NearClip;
112112
float m_FarClip;
113-
bool m_ReverseZ; // Invert near and far clip distances so that Z=0 is the far plane
113+
bool m_ReverseZ; // Invert near and far clip distances so that Z=1 at the near plane
114+
bool m_InfiniteZ; // Move the far plane to infinity
114115
};
115116

116117
inline void BaseCamera::SetEyeAtUp( Vector3 eye, Vector3 at, Vector3 up )
@@ -137,7 +138,7 @@ namespace Math
137138
m_Basis = Matrix3(m_CameraToWorld.GetRotation());
138139
}
139140

140-
inline Camera::Camera() : m_ReverseZ(true)
141+
inline Camera::Camera() : m_ReverseZ(true), m_InfiniteZ(false)
141142
{
142143
SetPerspectiveMatrix( XM_PIDIV4, 9.0f / 16.0f, 1.0f, 1000.0f );
143144
}

0 commit comments

Comments
 (0)