fix: D3D12 sphere rendering - correct matrix math, enable depth test, add texture sampling

- Fix TranslationMatrix to use correct indices (m12/m13/m14 for translation)
- Fix PerspectiveMatrix projection formula
- Enable depth testing (was disabled)
- Add texture sampling in pixel shader
- Adjust sphere radius to 1.0 and position to z=5
- Fix D3D12Buffer copy size calculation
This commit is contained in:
2026-03-22 17:58:30 +08:00
parent fa2d2713d7
commit 6c92164a03
3 changed files with 36 additions and 23 deletions

View File

@@ -99,7 +99,7 @@ bool D3D12Buffer::InitializeWithData(ID3D12Device* device, ID3D12GraphicsCommand
D3D12_RESOURCE_DESC d3d12TempResourceDesc = {};
d3d12TempResourceDesc.Dimension = D3D12_RESOURCE_DIMENSION_BUFFER;
d3d12TempResourceDesc.Alignment = 0;
d3d12TempResourceDesc.Width = memorySizeUsed;
d3d12TempResourceDesc.Width = size;
d3d12TempResourceDesc.Height = 1;
d3d12TempResourceDesc.DepthOrArraySize = 1;
d3d12TempResourceDesc.MipLevels = 1;
@@ -129,7 +129,7 @@ bool D3D12Buffer::InitializeWithData(ID3D12Device* device, ID3D12GraphicsCommand
memcpy(pDstTempBuffer, pSrcData, size);
tempBufferObject->Unmap(0, nullptr);
commandList->CopyBufferRegion(m_resource.Get(), 0, tempBufferObject, 0, subresourceFootprint.Footprint.Width);
commandList->CopyBufferRegion(m_resource.Get(), 0, tempBufferObject, 0, size);
D3D12_RESOURCE_BARRIER barrier = {};
barrier.Type = D3D12_RESOURCE_BARRIER_TYPE_TRANSITION;