Moved shaders to new directory

This commit is contained in:
Sascha Willems 2023-05-09 21:03:02 +02:00
parent 0b3f8340e3
commit 99b226237a
1244 changed files with 0 additions and 0 deletions

View file

@ -0,0 +1,64 @@
// Copyright 2020 Sascha Willems
#define MAX_FRAGMENT_COUNT 128
struct VSOutput
{
float4 Pos : SV_POSITION;
};
struct Node
{
float4 color;
float depth;
uint next;
};
RWTexture2D<uint> headIndexImage : register(u0);
struct Particle
{
float2 pos;
float2 vel;
float4 gradientPos;
};
// Binding 0 : Position storage buffer
RWStructuredBuffer<Node> nodes : register(u1);
float4 main(VSOutput input) : SV_TARGET
{
Node fragments[MAX_FRAGMENT_COUNT];
int count = 0;
uint nodeIdx = headIndexImage[uint2(input.Pos.xy)].r;
while (nodeIdx != 0xffffffff && count < MAX_FRAGMENT_COUNT)
{
fragments[count] = nodes[nodeIdx];
nodeIdx = fragments[count].next;
++count;
}
// Do the insertion sort
for (uint i = 1; i < count; ++i)
{
Node insert = fragments[i];
uint j = i;
while (j > 0 && insert.depth > fragments[j - 1].depth)
{
fragments[j] = fragments[j-1];
--j;
}
fragments[j] = insert;
}
// Do blending
float4 color = float4(0.025, 0.025, 0.025, 1.0f);
for (uint f = 0; f < count; ++f)
{
color = lerp(color, fragments[f].color, fragments[f].color.a);
}
return color;
}

Binary file not shown.

View file

@ -0,0 +1,14 @@
// Copyright 2020 Sascha Willems
struct VSOutput
{
float4 Pos : SV_POSITION;
};
VSOutput main(uint VertexIndex : SV_VertexID)
{
VSOutput output = (VSOutput)0;
float2 UV = float2((VertexIndex << 1) & 2, VertexIndex & 2);
output.Pos = float4(UV * 2.0f - 1.0f, 0.0f, 1.0f);
return output;
}

Binary file not shown.

View file

@ -0,0 +1,52 @@
// Copyright 2020 Sascha Willems
struct VSOutput
{
float4 Pos : SV_POSITION;
};
struct Node
{
float4 color;
float depth;
uint next;
};
struct GeometrySBO
{
uint count;
uint maxNodeCount;
};
// Binding 0 : Position storage buffer
RWStructuredBuffer<GeometrySBO> geometrySBO : register(u1);
RWTexture2D<uint> headIndexImage : register(u2);
RWStructuredBuffer<Node> nodes : register(u3);
struct PushConsts {
float4x4 model;
float4 color;
};
[[vk::push_constant]] PushConsts pushConsts;
[earlydepthstencil]
void main(VSOutput input)
{
// Increase the node count
uint nodeIdx;
InterlockedAdd(geometrySBO[0].count, 1, nodeIdx);
// Check LinkedListSBO is full
if (nodeIdx < geometrySBO[0].maxNodeCount)
{
// Exchange new head index and previous head index
uint prevHeadIdx;
InterlockedExchange(headIndexImage[uint2(input.Pos.xy)], nodeIdx, prevHeadIdx);
// Store node data
nodes[nodeIdx].color = pushConsts.color;
nodes[nodeIdx].depth = input.Pos.z;
nodes[nodeIdx].next = prevHeadIdx;
}
}

Binary file not shown.

View file

@ -0,0 +1,32 @@
// Copyright 2020 Sascha Willems
struct VSInput
{
[[vk::location(0)]] float4 Pos : POSITION0;
};
struct RenderPassUBO
{
float4x4 projection;
float4x4 view;
};
cbuffer renderPassUBO : register(b0) { RenderPassUBO renderPassUBO; }
struct PushConsts {
float4x4 model;
float4 color;
};
[[vk::push_constant]] PushConsts pushConsts;
struct VSOutput
{
float4 Pos : SV_POSITION;
};
VSOutput main(VSInput input)
{
VSOutput output = (VSOutput)0;
output.Pos = mul(renderPassUBO.projection, mul(renderPassUBO.view, mul(pushConsts.model, input.Pos)));
return output;
}

Binary file not shown.