Skip to content

Commit 7299e9b

Browse files
committed
Updated MiniEngine to better support the Raytracing sample
1 parent 596a7e6 commit 7299e9b

14 files changed

+737
-307
lines changed

MiniEngine/Core/BufferManager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ namespace Graphics
2222
{
2323
DepthBuffer g_SceneDepthBuffer;
2424
ColorBuffer g_SceneColorBuffer;
25+
ColorBuffer g_SceneNormalBuffer;
2526
ColorBuffer g_PostEffectsBuffer;
2627
ColorBuffer g_VelocityBuffer;
2728
ColorBuffer g_OverlayBuffer;
@@ -110,6 +111,7 @@ void Graphics::InitializeRenderingBuffers( uint32_t bufferWidth, uint32_t buffer
110111
esram.PushStack();
111112

112113
g_SceneColorBuffer.Create( L"Main Color Buffer", bufferWidth, bufferHeight, 1, DefaultHdrColorFormat, esram );
114+
g_SceneNormalBuffer.Create( L"Normals Buffer", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R16G16B16A16_FLOAT, esram );
113115
g_VelocityBuffer.Create( L"Motion Vectors", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R32_UINT );
114116
g_PostEffectsBuffer.Create( L"Post Effects Buffer", bufferWidth, bufferHeight, 1, DXGI_FORMAT_R32_UINT );
115117

@@ -243,6 +245,7 @@ void Graphics::DestroyRenderingBuffers()
243245
{
244246
g_SceneDepthBuffer.Destroy();
245247
g_SceneColorBuffer.Destroy();
248+
g_SceneNormalBuffer.Destroy();
246249
g_VelocityBuffer.Destroy();
247250
g_OverlayBuffer.Destroy();
248251
g_HorizontalBuffer.Destroy();

MiniEngine/Core/BufferManager.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,14 @@
2121

2222
namespace Graphics
2323
{
24-
extern DepthBuffer g_SceneDepthBuffer; // D32_FLOAT_S8_UINT
25-
extern ColorBuffer g_SceneColorBuffer; // R11G11B10_FLOAT
26-
extern ColorBuffer g_PostEffectsBuffer; // R32_UINT (to support Read-Modify-Write with a UAV)
27-
extern ColorBuffer g_OverlayBuffer; // R8G8B8A8_UNORM
28-
extern ColorBuffer g_HorizontalBuffer; // For separable (bicubic) upsampling
24+
extern DepthBuffer g_SceneDepthBuffer; // D32_FLOAT_S8_UINT
25+
extern ColorBuffer g_SceneColorBuffer; // R11G11B10_FLOAT
26+
extern ColorBuffer g_SceneNormalBuffer; // R16G16B16A16_FLOAT
27+
extern ColorBuffer g_PostEffectsBuffer; // R32_UINT (to support Read-Modify-Write with a UAV)
28+
extern ColorBuffer g_OverlayBuffer; // R8G8B8A8_UNORM
29+
extern ColorBuffer g_HorizontalBuffer; // For separable (bicubic) upsampling
2930

30-
extern ColorBuffer g_VelocityBuffer; // R10G10B10 (3D velocity)
31+
extern ColorBuffer g_VelocityBuffer; // R10G10B10 (3D velocity)
3132
extern ShadowBuffer g_ShadowBuffer;
3233

3334
extern ColorBuffer g_SSAOFullScreen; // R8_UNORM

MiniEngine/Core/CameraController.cpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,28 @@ void FlyingFPSCamera::Update( float deltaTime )
116116
m_TargetCamera.Update();
117117
}
118118

119+
void FlyingFPSCamera::SetHeadingPitchAndPosition(float heading, float pitch, const Vector3& position)
120+
{
121+
m_CurrentHeading = heading;
122+
if (m_CurrentHeading > XM_PI)
123+
m_CurrentHeading -= XM_2PI;
124+
else if (m_CurrentHeading <= -XM_PI)
125+
m_CurrentHeading += XM_2PI;
126+
127+
m_CurrentPitch = pitch;
128+
m_CurrentPitch = XMMin( XM_PIDIV2, m_CurrentPitch);
129+
m_CurrentPitch = XMMax(-XM_PIDIV2, m_CurrentPitch);
130+
131+
Matrix3 orientation =
132+
Matrix3(m_WorldEast, m_WorldUp, -m_WorldNorth) *
133+
Matrix3::MakeYRotation( m_CurrentHeading ) *
134+
Matrix3::MakeXRotation( m_CurrentPitch );
135+
136+
m_TargetCamera.SetTransform( AffineTransform( orientation, position ) );
137+
m_TargetCamera.Update();
138+
}
139+
140+
119141
void CameraController::ApplyMomentum( float& oldValue, float& newValue, float deltaTime )
120142
{
121143
float blendedValue;

MiniEngine/Core/CameraController.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class FlyingFPSCamera : public CameraController
5454

5555
void EnableMomentum( bool enable ) { m_Momentum = enable; }
5656

57+
void SetHeadingPitchAndPosition(float heading, float pitch, const Vector3& position);
58+
5759
private:
5860

5961
Vector3 m_WorldUp;

0 commit comments

Comments
 (0)