Skip to content

Commit bf0495b

Browse files
+ 镜中世界的绘制
* 修复MiniEngine使用stencil缓冲的bug * 修复深度缓冲区默认值
1 parent 39fe9e5 commit bf0495b

File tree

7 files changed

+179
-39
lines changed

7 files changed

+179
-39
lines changed

Chapter 11 Stenciling/Core/Graphics/Command/CommandContext.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,8 @@ class GraphicsContext : public CommandContext
210210
void SetScissor( UINT left, UINT top, UINT right, UINT bottom );
211211
void SetViewportAndScissor( const D3D12_VIEWPORT& vp, const D3D12_RECT& rect );
212212
void SetViewportAndScissor( UINT x, UINT y, UINT w, UINT h );
213+
void SetStencilRef(UINT StencilRef);
214+
void SetBlendFactor(Color BlendFactor);
213215
void SetPrimitiveTopology(D3D12_PRIMITIVE_TOPOLOGY Topology);
214216

215217
// 设置流水线状态
@@ -342,6 +344,16 @@ inline void GraphicsContext::SetScissor(UINT left, UINT top, UINT right, UINT bo
342344
SetScissor(CD3DX12_RECT(left, top, right, bottom));
343345
}
344346

347+
inline void GraphicsContext::SetStencilRef(UINT ref)
348+
{
349+
m_CommandList->OMSetStencilRef(ref);
350+
}
351+
352+
inline void GraphicsContext::SetBlendFactor(Color BlendFactor)
353+
{
354+
m_CommandList->OMSetBlendFactor(BlendFactor.GetPtr());
355+
}
356+
345357
inline void GraphicsContext::SetPrimitiveTopology(D3D12_PRIMITIVE_TOPOLOGY Topology)
346358
{
347359
m_CommandList->IASetPrimitiveTopology(Topology);

Chapter 11 Stenciling/Core/Graphics/GraphicsCommon.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,9 @@ namespace Graphics
5757
D3D12_DEPTH_STENCIL_DESC DepthStateDisabled;
5858
D3D12_DEPTH_STENCIL_DESC DepthStateReadWrite;
5959
D3D12_DEPTH_STENCIL_DESC DepthStateReadOnly;
60-
D3D12_DEPTH_STENCIL_DESC DepthStateReadOnlyReversed;
6160
D3D12_DEPTH_STENCIL_DESC DepthStateTestEqual;
61+
D3D12_DEPTH_STENCIL_DESC StencilStateTest;
62+
D3D12_DEPTH_STENCIL_DESC StencilStateTestEqual;
6263

6364
// CommandSignature DispatchIndirectCommandSignature(1);
6465
// CommandSignature DrawIndirectCommandSignature(1);
@@ -164,12 +165,19 @@ void Graphics::InitializeCommonState(void)
164165
DepthStateReadOnly = DepthStateReadWrite;
165166
DepthStateReadOnly.DepthWriteMask = D3D12_DEPTH_WRITE_MASK_ZERO;
166167

167-
DepthStateReadOnlyReversed = DepthStateReadOnly;
168-
DepthStateReadOnlyReversed.DepthFunc = D3D12_COMPARISON_FUNC_LESS;
169-
170168
DepthStateTestEqual = DepthStateReadOnly;
171169
DepthStateTestEqual.DepthFunc = D3D12_COMPARISON_FUNC_EQUAL;
172170

171+
StencilStateTest = DepthStateReadOnly;
172+
StencilStateTest.StencilEnable = TRUE;
173+
StencilStateTest.FrontFace.StencilPassOp = D3D12_STENCIL_OP_REPLACE;
174+
StencilStateTest.BackFace = StencilStateTest.FrontFace;
175+
176+
StencilStateTestEqual = DepthStateReadWrite;
177+
StencilStateTestEqual.StencilEnable = TRUE;
178+
StencilStateTestEqual.FrontFace.StencilFunc = D3D12_COMPARISON_FUNC_EQUAL;
179+
StencilStateTestEqual.BackFace = StencilStateTestEqual.FrontFace;
180+
173181
D3D12_BLEND_DESC alphaBlend = {};
174182
alphaBlend.IndependentBlendEnable = FALSE;
175183
alphaBlend.RenderTarget[0].BlendEnable = FALSE;

Chapter 11 Stenciling/Core/Graphics/GraphicsCommon.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ namespace Graphics
5656
extern D3D12_DEPTH_STENCIL_DESC DepthStateDisabled;
5757
extern D3D12_DEPTH_STENCIL_DESC DepthStateReadWrite;
5858
extern D3D12_DEPTH_STENCIL_DESC DepthStateReadOnly;
59-
extern D3D12_DEPTH_STENCIL_DESC DepthStateReadOnlyReversed;
6059
extern D3D12_DEPTH_STENCIL_DESC DepthStateTestEqual;
60+
// 模板测试。禁止深度写入,只有通过了深度测试+模板测试的才写入值
61+
extern D3D12_DEPTH_STENCIL_DESC StencilStateTest;
62+
// 模板测试。只有模板值相同才允许写入
63+
extern D3D12_DEPTH_STENCIL_DESC StencilStateTestEqual;
6164

6265
// extern CommandSignature DispatchIndirectCommandSignature;
6366
// extern CommandSignature DrawIndirectCommandSignature;

Chapter 11 Stenciling/Core/Graphics/Resource/BufferManager.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ namespace Graphics
2929

3030
#define T2X_COLOR_FORMAT DXGI_FORMAT_R10G10B10A2_UNORM
3131
#define HDR_MOTION_FORMAT DXGI_FORMAT_R16G16B16A16_FLOAT
32-
#define DSV_FORMAT DXGI_FORMAT_D32_FLOAT
32+
#define DSV_FORMAT DXGI_FORMAT_D24_UNORM_S8_UINT
3333

3434
void Graphics::InitializeRenderingBuffers( uint32_t bufferWidth, uint32_t bufferHeight )
3535
{

Chapter 11 Stenciling/Core/Graphics/Resource/DepthBuffer.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ void DepthBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Hei
2525

2626
D3D12_CLEAR_VALUE ClearValue = {};
2727
ClearValue.Format = Format;
28+
ClearValue.DepthStencil.Depth = 1.0f;
29+
ClearValue.DepthStencil.Stencil = 0;
2830
CreateTextureResource(Graphics::g_Device, Name, ResourceDesc, ClearValue, VidMemPtr);
2931
CreateDerivedViews(Graphics::g_Device, Format);
3032
}
@@ -36,6 +38,8 @@ void DepthBuffer::Create( const std::wstring& Name, uint32_t Width, uint32_t Hei
3638

3739
D3D12_CLEAR_VALUE ClearValue = {};
3840
ClearValue.Format = Format;
41+
ClearValue.DepthStencil.Depth = 1.0f;
42+
ClearValue.DepthStencil.Stencil = 0;
3943
CreateTextureResource(Graphics::g_Device, Name, ResourceDesc, ClearValue, VidMemPtr);
4044
CreateDerivedViews(Graphics::g_Device, Format);
4145
}
@@ -123,6 +127,7 @@ void DepthBuffer::CreateDerivedViews( ID3D12Device* Device, DXGI_FORMAT Format )
123127
m_hStencilSRV = Graphics::AllocateDescriptor(D3D12_DESCRIPTOR_HEAP_TYPE_CBV_SRV_UAV);
124128

125129
SRVDesc.Format = stencilReadFormat;
130+
SRVDesc.Texture2D.PlaneSlice = 1;
126131
Device->CreateShaderResourceView( Resource, &SRVDesc, m_hStencilSRV );
127132
}
128133
}

Chapter 11 Stenciling/GameApp.cpp

Lines changed: 133 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,38 @@ void GameApp::Startup(void)
5959

6060
// 默认PSO
6161
m_mapPSO[E_EPT_DEFAULT] = defaultPSO;
62+
63+
// 模板PSO 禁止深度写入。如果通过了深度+模板测试,则在对应的模板中写入预设值
64+
GraphicsPSO stencilTestPSO = defaultPSO;
65+
stencilTestPSO.SetDepthStencilState(Graphics::StencilStateTest);
66+
stencilTestPSO.Finalize();
67+
m_mapPSO[E_EPT_STENCILTEST] = stencilTestPSO;
68+
69+
// 模板绘制PSO 通过上一步写入了值,这一步进行判断,如果当前像素的模板值等于预设值,则通过测试
70+
// 因为要绘制镜子中的物体,所以需要顶点反向
71+
GraphicsPSO stencilDrawPSO = defaultPSO;
72+
stencilDrawPSO.SetRasterizerState(Graphics::RasterizerDefault);
73+
stencilDrawPSO.SetDepthStencilState(Graphics::StencilStateTestEqual);
74+
stencilDrawPSO.Finalize();
75+
m_mapPSO[E_EPT_STENCILDRAW] = stencilDrawPSO;
76+
77+
// 透明PSO 绘制半透明的镜子
78+
GraphicsPSO transparencyPSO = defaultPSO;
79+
auto blend = Graphics::BlendTraditional;
80+
// 目标的alpha用0,这样透过去的目标就不再变淡了
81+
blend.RenderTarget[0].DestBlendAlpha = D3D12_BLEND_ZERO;
82+
transparencyPSO.SetBlendState(blend);
83+
transparencyPSO.Finalize();
84+
m_mapPSO[E_EPT_TRANSPARENT] = transparencyPSO;
6285
}
6386

6487
void GameApp::Cleanup(void)
6588
{
6689
m_mapGeometries.clear();
6790
m_mapMaterial.clear();
6891
m_mapPSO.clear();
92+
93+
m_vecAll.clear();
6994
}
7095

7196
void GameApp::Update(float deltaT)
@@ -171,7 +196,14 @@ void GameApp::updateSkull(float deltaT)
171196
auto rotationMatrix = Math::AffineTransform::MakeYRotation(Math::XM_PIDIV2);
172197
auto scallMatrix = Math::AffineTransform::MakeScale({ 0.45f, 0.45f, 0.45f });
173198
auto translateMatrix = Math::AffineTransform::MakeTranslation(mSkullTranslation);
174-
mSkullRitem->modeToWorld = Math::Transpose(Math::Matrix4(translateMatrix * scallMatrix * rotationMatrix));
199+
auto world = Math::Matrix4(translateMatrix * scallMatrix * rotationMatrix);
200+
mSkullRitem->modeToWorld = Math::Transpose(world);
201+
202+
// xy平面
203+
XMVECTOR mirrorPlane = XMVectorSet(0.0f, 0.0f, 1.0f, 0.0f);
204+
XMMATRIX R = XMMatrixReflect(mirrorPlane);
205+
mReflectedSkullRitem->modeToWorld = Math::Transpose(Math::Matrix4(R) * world);
206+
mReflectedFloorlRItem->modeToWorld = Math::Transpose(Math::Matrix4(R));
175207
}
176208

177209
void GameApp::RenderScene(void)
@@ -185,40 +217,49 @@ void GameApp::RenderScene(void)
185217
gfxContext.ClearColor(Graphics::g_SceneColorBuffer);
186218

187219
gfxContext.TransitionResource(Graphics::g_SceneDepthBuffer, D3D12_RESOURCE_STATE_DEPTH_WRITE, true);
188-
gfxContext.ClearDepth(Graphics::g_SceneDepthBuffer);
220+
gfxContext.ClearDepthAndStencil(Graphics::g_SceneDepthBuffer);
189221

190222
gfxContext.SetRenderTarget(Graphics::g_SceneColorBuffer.GetRTV(), Graphics::g_SceneDepthBuffer.GetDSV());
191223

192-
// 设置渲染流水线
193-
gfxContext.SetPipelineState(m_mapPSO[E_EPT_DEFAULT]);
194-
195224
// 设置根签名
196225
gfxContext.SetRootSignature(m_RootSignature);
197226
// 设置顶点拓扑结构
198227
gfxContext.SetPrimitiveTopology(D3D_PRIMITIVE_TOPOLOGY_TRIANGLELIST);
199228

200-
// 设置通用的常量缓冲区
201-
PassConstants psc;
202-
psc.viewProj = Transpose(m_ViewProjMatrix);
203-
psc.eyePosW = m_Camera.GetPosition();
204-
psc.ambientLight = { 0.25f, 0.25f, 0.35f, 1.0f };
205-
psc.Lights[0].Direction = { 0.57735f, -0.57735f, 0.57735f };
206-
psc.Lights[0].Strength = { 0.6f, 0.6f, 0.6f };
207-
psc.Lights[1].Direction = { -0.57735f, -0.57735f, 0.57735f };
208-
psc.Lights[1].Strength = { 0.3f, 0.3f, 0.3f };
209-
psc.Lights[2].Direction = { 0.0f, -0.707f, -0.707f };
210-
psc.Lights[2].Strength = { 0.15f, 0.15f, 0.15f };
211-
gfxContext.SetDynamicConstantBufferView(1, sizeof(psc), &psc);
229+
// 设置显示物体的常量缓冲区
230+
setLightContantsBuff(gfxContext);
212231

213232
// 开始绘制
233+
// 渲染普通目标
234+
gfxContext.SetPipelineState(m_mapPSO[E_EPT_DEFAULT]);
214235
drawRenderItems(gfxContext, m_vecRenderItems[(int)RenderLayer::Opaque]);
215236

237+
// 设置模板写入PSO,对于镜子区域,进行模板+深度测试,通过的话,在模板缓冲区写入1
238+
gfxContext.SetStencilRef(1);
239+
gfxContext.SetPipelineState(m_mapPSO[E_EPT_STENCILTEST]);
240+
drawRenderItems(gfxContext, m_vecRenderItems[(int)RenderLayer::Mirrors]);
241+
242+
// 设置镜中物体的常量缓冲区
243+
setLightContantsBuff(gfxContext, true);
244+
245+
// 绘制镜中物体,只有通过了模板测试,也就是会处于镜中才会绘制
246+
gfxContext.SetPipelineState(m_mapPSO[E_EPT_STENCILDRAW]);
247+
drawRenderItems(gfxContext, m_vecRenderItems[(int)RenderLayer::Reflected]);
248+
gfxContext.SetStencilRef(0);
249+
250+
// 设置显示物体的常量缓冲区
251+
setLightContantsBuff(gfxContext);
252+
253+
// 绘制镜子
254+
gfxContext.SetPipelineState(m_mapPSO[E_EPT_TRANSPARENT]);
255+
drawRenderItems(gfxContext, m_vecRenderItems[(int)RenderLayer::Transparent]);
256+
216257
gfxContext.TransitionResource(Graphics::g_SceneColorBuffer, D3D12_RESOURCE_STATE_PRESENT);
217258

218259
gfxContext.Finish(true);
219260
}
220261

221-
void GameApp::drawRenderItems(GraphicsContext& gfxContext, std::vector<std::unique_ptr<RenderItem>>& ritems)
262+
void GameApp::drawRenderItems(GraphicsContext& gfxContext, std::vector<RenderItem*>& ritems)
222263
{
223264
for (auto& item : ritems)
224265
{
@@ -248,6 +289,40 @@ void GameApp::drawRenderItems(GraphicsContext& gfxContext, std::vector<std::uniq
248289
}
249290
}
250291

292+
void GameApp::setLightContantsBuff(GraphicsContext& gfxContext, bool inMirror /* = false */)
293+
{
294+
if (!inMirror)
295+
{
296+
// 设置通用的常量缓冲区
297+
PassConstants psc;
298+
psc.viewProj = Transpose(m_ViewProjMatrix);
299+
psc.eyePosW = m_Camera.GetPosition();
300+
psc.ambientLight = { 0.25f, 0.25f, 0.35f, 1.0f };
301+
psc.Lights[0].Direction = { 0.57735f, -0.57735f, 0.57735f };
302+
psc.Lights[0].Strength = { 0.6f, 0.6f, 0.6f };
303+
psc.Lights[1].Direction = { -0.57735f, -0.57735f, 0.57735f };
304+
psc.Lights[1].Strength = { 0.3f, 0.3f, 0.3f };
305+
psc.Lights[2].Direction = { 0.0f, -0.707f, -0.707f };
306+
psc.Lights[2].Strength = { 0.15f, 0.15f, 0.15f };
307+
gfxContext.SetDynamicConstantBufferView(1, sizeof(psc), &psc);
308+
}
309+
else
310+
{
311+
// 设置镜子中的光照,偷个懒,直接设置了
312+
PassConstants psc;
313+
psc.viewProj = Transpose(m_ViewProjMatrix);
314+
psc.eyePosW = m_Camera.GetPosition();
315+
psc.ambientLight = { 0.25f, 0.25f, 0.35f, 1.0f };
316+
psc.Lights[0].Direction = { 0.57735f, -0.57735f, -0.57735f };
317+
psc.Lights[0].Strength = { 0.6f, 0.6f, 0.6f };
318+
psc.Lights[1].Direction = { -0.57735f, -0.57735f, -0.57735f };
319+
psc.Lights[1].Strength = { 0.3f, 0.3f, 0.3f };
320+
psc.Lights[2].Direction = { 0.0f, -0.707f, 0.707f };
321+
psc.Lights[2].Strength = { 0.15f, 0.15f, 0.15f };
322+
gfxContext.SetDynamicConstantBufferView(1, sizeof(psc), &psc);
323+
}
324+
}
325+
251326
void GameApp::buildRoomGeo()
252327
{
253328
// Create and specify geometry. For this sample we draw a floor
@@ -448,7 +523,7 @@ void GameApp::buildRenderItem()
448523
floorRItem->BaseVertexLocation = m_mapGeometries["roomGeo"]->geoMap["floor"].BaseVertexLocation;
449524
floorRItem->geo = m_mapGeometries["roomGeo"].get();
450525
floorRItem->mat = m_mapMaterial["checkertile"].get();
451-
m_vecRenderItems[(int)RenderLayer::Opaque].push_back(std::move(floorRItem));
526+
m_vecRenderItems[(int)RenderLayer::Opaque].push_back(floorRItem.get());
452527

453528
// 墙壁
454529
auto wallRItem = std::make_unique<RenderItem>();
@@ -457,16 +532,7 @@ void GameApp::buildRenderItem()
457532
wallRItem->BaseVertexLocation = m_mapGeometries["roomGeo"]->geoMap["wall"].BaseVertexLocation;
458533
wallRItem->geo = m_mapGeometries["roomGeo"].get();
459534
wallRItem->mat = m_mapMaterial["bricks"].get();
460-
m_vecRenderItems[(int)RenderLayer::Opaque].push_back(std::move(wallRItem));
461-
462-
// 镜子
463-
auto mirrorRItem = std::make_unique<RenderItem>();
464-
mirrorRItem->IndexCount = m_mapGeometries["roomGeo"]->geoMap["mirror"].IndexCount;
465-
mirrorRItem->StartIndexLocation = m_mapGeometries["roomGeo"]->geoMap["mirror"].StartIndexLocation;
466-
mirrorRItem->BaseVertexLocation = m_mapGeometries["roomGeo"]->geoMap["mirror"].BaseVertexLocation;
467-
mirrorRItem->geo = m_mapGeometries["roomGeo"].get();
468-
mirrorRItem->mat = m_mapMaterial["icemirror"].get();
469-
m_vecRenderItems[(int)RenderLayer::Opaque].push_back(std::move(mirrorRItem));
535+
m_vecRenderItems[(int)RenderLayer::Opaque].push_back(wallRItem.get());
470536

471537
// skull
472538
auto skullRItem = std::make_unique<RenderItem>();
@@ -476,5 +542,42 @@ void GameApp::buildRenderItem()
476542
skullRItem->geo = m_mapGeometries["skullGeo"].get();
477543
skullRItem->mat = m_mapMaterial["skullMat"].get();
478544
mSkullRitem = skullRItem.get();
479-
m_vecRenderItems[(int)RenderLayer::Opaque].push_back(std::move(skullRItem));
545+
m_vecRenderItems[(int)RenderLayer::Opaque].push_back(skullRItem.get());
546+
547+
// 镜子
548+
auto mirrorRItem = std::make_unique<RenderItem>();
549+
mirrorRItem->IndexCount = m_mapGeometries["roomGeo"]->geoMap["mirror"].IndexCount;
550+
mirrorRItem->StartIndexLocation = m_mapGeometries["roomGeo"]->geoMap["mirror"].StartIndexLocation;
551+
mirrorRItem->BaseVertexLocation = m_mapGeometries["roomGeo"]->geoMap["mirror"].BaseVertexLocation;
552+
mirrorRItem->geo = m_mapGeometries["roomGeo"].get();
553+
mirrorRItem->mat = m_mapMaterial["icemirror"].get();
554+
m_vecRenderItems[(int)RenderLayer::Mirrors].push_back(mirrorRItem.get());
555+
m_vecRenderItems[(int)RenderLayer::Transparent].push_back(mirrorRItem.get());
556+
557+
// 镜子中的skull
558+
auto reflectedSkullRItem = std::make_unique<RenderItem>();
559+
reflectedSkullRItem->IndexCount = m_mapGeometries["skullGeo"]->geoMap["skull"].IndexCount;
560+
reflectedSkullRItem->StartIndexLocation = m_mapGeometries["skullGeo"]->geoMap["skull"].StartIndexLocation;
561+
reflectedSkullRItem->BaseVertexLocation = m_mapGeometries["skullGeo"]->geoMap["skull"].BaseVertexLocation;
562+
reflectedSkullRItem->geo = m_mapGeometries["skullGeo"].get();
563+
reflectedSkullRItem->mat = m_mapMaterial["skullMat"].get();
564+
mReflectedSkullRitem = reflectedSkullRItem.get();
565+
m_vecRenderItems[(int)RenderLayer::Reflected].push_back(reflectedSkullRItem.get());
566+
567+
// 镜子中的floor
568+
auto reflectedFloorlRItem = std::make_unique<RenderItem>();
569+
reflectedFloorlRItem->IndexCount = m_mapGeometries["roomGeo"]->geoMap["floor"].IndexCount;
570+
reflectedFloorlRItem->StartIndexLocation = m_mapGeometries["roomGeo"]->geoMap["floor"].StartIndexLocation;
571+
reflectedFloorlRItem->BaseVertexLocation = m_mapGeometries["roomGeo"]->geoMap["floor"].BaseVertexLocation;
572+
reflectedFloorlRItem->geo = m_mapGeometries["roomGeo"].get();
573+
reflectedFloorlRItem->mat = m_mapMaterial["checkertile"].get();
574+
mReflectedFloorlRItem = reflectedFloorlRItem.get();
575+
m_vecRenderItems[(int)RenderLayer::Reflected].push_back(reflectedFloorlRItem.get());
576+
577+
m_vecAll.push_back(std::move(floorRItem));
578+
m_vecAll.push_back(std::move(wallRItem));
579+
m_vecAll.push_back(std::move(skullRItem));
580+
m_vecAll.push_back(std::move(mirrorRItem));
581+
m_vecAll.push_back(std::move(reflectedSkullRItem));
582+
m_vecAll.push_back(std::move(reflectedFloorlRItem));
480583
}

Chapter 11 Stenciling/GameApp.h

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ class GameApp : public GameCore::IGameApp
3030

3131
void updateSkull(float deltaT);
3232

33-
void drawRenderItems(GraphicsContext& gfxContext, std::vector<std::unique_ptr<RenderItem>>& ritems);
33+
void drawRenderItems(GraphicsContext& gfxContext, std::vector<RenderItem*>& ritems);
34+
void setLightContantsBuff(GraphicsContext& gfxContext, bool inMirror = false);
3435

3536
private:
3637
// 几何结构map
@@ -48,7 +49,8 @@ class GameApp : public GameCore::IGameApp
4849
Shadow,
4950
Count
5051
};
51-
std::vector<std::unique_ptr<RenderItem>> m_vecRenderItems[(int)RenderLayer::Count];
52+
std::vector<RenderItem*> m_vecRenderItems[(int)RenderLayer::Count];
53+
std::vector<std::unique_ptr<RenderItem>> m_vecAll;
5254

5355
private:
5456
// 根签名
@@ -57,14 +59,21 @@ class GameApp : public GameCore::IGameApp
5759
// 渲染流水线
5860
enum ePSOType
5961
{
60-
E_EPT_DEFAULT = 1
62+
E_EPT_DEFAULT = 1,
63+
E_EPT_STENCILTEST = 2,
64+
E_EPT_STENCILDRAW = 3,
65+
E_EPT_TRANSPARENT = 4,
6166
};
6267
std::unordered_map<int, GraphicsPSO> m_mapPSO;
6368

6469
// render item skull point
6570
RenderItem* mSkullRitem = nullptr;
6671
Math::Vector3 mSkullTranslation = { 0.0f, 1.0f, -5.0f };
6772

73+
// 镜中的skull
74+
RenderItem* mReflectedSkullRitem = nullptr;
75+
RenderItem* mReflectedFloorlRItem = nullptr;
76+
6877
// 摄像机
6978
// 以(0, 0, -m_radius) 为初始位置
7079
Math::Camera m_Camera;

0 commit comments

Comments
 (0)