Added:
- Depth buffer - Debug display basics - Basic vector + matrix maths Made partially with gemini + antigravity
This commit is contained in:
BIN
Assets/compiled/Debug.frag.dxil
Normal file
BIN
Assets/compiled/Debug.frag.dxil
Normal file
Binary file not shown.
BIN
Assets/compiled/Debug.vert.dxil
Normal file
BIN
Assets/compiled/Debug.vert.dxil
Normal file
Binary file not shown.
Binary file not shown.
4
Assets/source/Debug.frag.hlsl
Normal file
4
Assets/source/Debug.frag.hlsl
Normal file
@@ -0,0 +1,4 @@
|
||||
float4 main(float4 Color : TEXCOORD0) : SV_Target0
|
||||
{
|
||||
return Color;
|
||||
}
|
||||
27
Assets/source/Debug.vert.hlsl
Normal file
27
Assets/source/Debug.vert.hlsl
Normal file
@@ -0,0 +1,27 @@
|
||||
struct Output
|
||||
{
|
||||
float4 Color : TEXCOORD0;
|
||||
float4 Position : SV_Position;
|
||||
};
|
||||
|
||||
#include "RootConstants.hlsl"
|
||||
|
||||
Output main(uint vertexIndex : SV_VertexID)
|
||||
{
|
||||
Output output;
|
||||
|
||||
// Retrieve the vertex buffer using SM6.6 bindless syntax
|
||||
ByteAddressBuffer buffer = ResourceDescriptorHeap[BufferIndex];
|
||||
|
||||
// Vertex layout: float3 Position (12 bytes) + float4 Color (16 bytes) = 28 bytes stride
|
||||
uint stride = 28;
|
||||
uint offset = vertexIndex * stride;
|
||||
|
||||
float3 pos = asfloat(buffer.Load3(offset));
|
||||
float4 col = asfloat(buffer.Load4(offset + 12));
|
||||
|
||||
// Standard row-major transformation
|
||||
output.Position = mul(ViewProjection, float4(pos, 1.0f));
|
||||
output.Color = col;
|
||||
return output;
|
||||
}
|
||||
11
Assets/source/RootConstants.hlsl
Normal file
11
Assets/source/RootConstants.hlsl
Normal file
@@ -0,0 +1,11 @@
|
||||
#ifndef ROOT_CONSTANTS_HLSL
|
||||
#define ROOT_CONSTANTS_HLSL
|
||||
|
||||
cbuffer RootConstants : register(b0, space0)
|
||||
{
|
||||
row_major float4x4 ViewProjection;
|
||||
uint BufferIndex;
|
||||
uint _Padding[3];
|
||||
};
|
||||
|
||||
#endif // ROOT_CONSTANTS_HLSL
|
||||
@@ -1,34 +1,25 @@
|
||||
struct Input
|
||||
{
|
||||
uint VertexIndex : SV_VertexID;
|
||||
};
|
||||
|
||||
struct Output
|
||||
{
|
||||
float4 Color : TEXCOORD0;
|
||||
float4 Position : SV_Position;
|
||||
};
|
||||
|
||||
// Bindless storage buffer access
|
||||
// We assume DescriptorIndex 0 is our buffer for this example, or passed via push constant
|
||||
// Since we don't have push constants hooked up in the C++ simplified example yet,
|
||||
// we will assume the First descriptor in the heap is our buffer (Index 0).
|
||||
// In a real app, 'bufferIndex' would be passed as a Root Constant.
|
||||
#include "RootConstants.hlsl"
|
||||
|
||||
Output main(Input input)
|
||||
Output main(uint vertexIndex : SV_VertexID)
|
||||
{
|
||||
Output output;
|
||||
|
||||
// Retrieve the buffer using SM6.6 bindless syntax
|
||||
// heap index 0 is used for simplicity.
|
||||
uint bufferIndex = 0;
|
||||
// We use index 0 as the sample app doesn't pass push constants yet.
|
||||
uint bufferIndex = 0;
|
||||
ByteAddressBuffer buffer = ResourceDescriptorHeap[bufferIndex];
|
||||
|
||||
// Read position from buffer (Index * stride)
|
||||
// Stride = 2 float (pos) + 4 float (color) = 6 * 4 = 24 bytes ?
|
||||
// Let's assume just position 2D (8 bytes) + Color (16 bytes)
|
||||
uint stride = 24;
|
||||
uint offset = input.VertexIndex * stride;
|
||||
uint offset = vertexIndex * stride;
|
||||
|
||||
float2 pos = asfloat(buffer.Load2(offset));
|
||||
float4 col = asfloat(buffer.Load4(offset + 8));
|
||||
|
||||
Reference in New Issue
Block a user