Skip to content

Commit 485eeca

Browse files
committed
Mesh finally being renderer on the GBuffers. Need to print it to do de LightPass and "done"
1 parent 7947c16 commit 485eeca

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

src/Shader/GBufferPass.hlsl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
11
struct VertexOutput
22
{
33
float4 position : SV_Position;
4+
float4 normal : NORMAL;
45
float2 uv : TEXCOORD;
56
};
67

7-
VertexOutput VertexMain(float4 position : POSITION0, float2 uv : TEXCOORD0)
8+
VertexOutput VertexMain(float4 position : POSITION0, float4 normal : NORMAL0, float2 uv : TEXCOORD0)
89
{
910
VertexOutput output;
1011

1112
output.position = position;
13+
output.normal = normal;
1214
output.uv = uv;
1315

1416
return output;
@@ -24,6 +26,6 @@ PixelOutput PixelMain(VertexOutput input, uint index : SV_SampleIndex)
2426
{
2527
PixelOutput output;
2628
output.albedo = float4(1.f, 0.f, 0.f, 1.f);
27-
output.normal = float4(0.f, 0.f, 0.f, 1.f);
29+
output.normal = input.normal;
2830
return output;
2931
}

src/private/Core/GameObject/Component/Mesh.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,8 @@ void Mesh::InitPipeline() {
109109

110110
D3D12_INPUT_ELEMENT_DESC elements[] = {
111111
{ "POSITION", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 0, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, NULL },
112-
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, NULL }
112+
{ "NORMAL", 0, DXGI_FORMAT_R32G32B32_FLOAT, 0, 12, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, NULL },
113+
{ "TEXCOORD", 0, DXGI_FORMAT_R32G32_FLOAT, 0, 24, D3D12_INPUT_CLASSIFICATION_PER_VERTEX_DATA, NULL }
113114
};
114115

115116
D3D12_INPUT_LAYOUT_DESC layout = { };

src/private/Core/Renderer/D3D12.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ void D3D12::Init(HWND hwnd) {
9494
this->CreateTexture(this->m_nWidth, this->m_nHeight, 8, D3D12_RESOURCE_FLAG_ALLOW_RENDER_TARGET, this->m_positionBuff);
9595

9696
this->m_albedoBuff->SetName(L"Albedo");
97-
this->m_uvBuff->SetName(L"UV");
97+
this->m_uvBuff->SetName(L"Normal");
9898
this->m_positionBuff->SetName(L"Position");
9999

100100
this->m_nAlbedoIndex = this->m_rtvHeap->GetDescriptorCount();
@@ -202,20 +202,21 @@ void D3D12::Update() {
202202
Descriptor albedoDesc = this->m_rtvHeap->GetDescriptor(this->m_nAlbedoIndex);
203203
Descriptor UVDesc = this->m_rtvHeap->GetDescriptor(this->m_nUVIndex);
204204
Descriptor positionDesc = this->m_rtvHeap->GetDescriptor(this->m_nPositionIndex);
205+
Descriptor dsvDesc = this->m_dsvHeap->GetDescriptor(0);
205206
this->m_list->ClearRenderTargetView(albedoDesc.cpuHandle, RGBA{ 0.f, 0.f, 0.f, 1.f }, 0, nullptr);
206207
this->m_list->ClearRenderTargetView(UVDesc.cpuHandle, RGBA{ 0.f, 0.f, 0.f, 1.f }, 0, nullptr);
207208
this->m_list->ClearRenderTargetView(positionDesc.cpuHandle, RGBA{ 0.f, 0.f, 0.f, 1.f }, 0, nullptr);
209+
this->m_list->ClearDepthStencilView(dsvDesc.cpuHandle, D3D12_CLEAR_FLAG_DEPTH, 1.f, 0.f, 0, nullptr);
208210

209211
this->m_list->RSSetViewports(1, &this->m_viewport);
210212
this->m_list->RSSetScissorRects(1, &this->m_scissor);
211213

212-
Descriptor dsv = this->m_dsvHeap->GetDescriptor(0);
213214
D3D12_CPU_DESCRIPTOR_HANDLE gbuffers[] = {
214215
albedoDesc.cpuHandle,
215216
UVDesc.cpuHandle,
216217
positionDesc.cpuHandle
217218
};
218-
this->m_list->OMSetRenderTargets(_countof(gbuffers), gbuffers, FALSE, &dsv.cpuHandle);
219+
this->m_list->OMSetRenderTargets(_countof(gbuffers), gbuffers, FALSE, &dsvDesc.cpuHandle);
219220

220221
this->sceneMgr->Render();
221222

0 commit comments

Comments
 (0)