41 lines
1002 B
HLSL
41 lines
1002 B
HLSL
RWTexture2D<float4> Result;
|
|
RWStructuredBuffer<float> Samples;
|
|
cbuffer Params : register(b0)
|
|
{
|
|
float4 WaveColor;
|
|
float4 BgColor;
|
|
float LineUV;
|
|
float PeaksPerPixel;
|
|
};
|
|
|
|
|
|
[numthreads(1, 1, 1)]
|
|
void Main(uint3 id : SV_DispatchThreadID)
|
|
{
|
|
uint width, height;
|
|
Result.GetDimensions(width, height);
|
|
|
|
int X = id.x;
|
|
int Y = id.y;
|
|
|
|
// float4 color = lerp(BgColor, WaveColor, min(step(value.x, uv.y), step(uv.y , value.y)));
|
|
|
|
// Resample
|
|
uint TopIndex = X * 2;
|
|
uint BottomIndex = TopIndex + 1;
|
|
float Top = Samples[TopIndex] + 1; // -1;
|
|
float Bottom = Samples[BottomIndex] + 1; // 1;
|
|
Top = min(Top, 1);
|
|
Bottom = max(Bottom, 0);
|
|
Top *= height;
|
|
Top *= 0.5;
|
|
Bottom *= height;
|
|
Bottom *= 0.5;
|
|
|
|
// (id.y >= Top && id.y <= Bottom)
|
|
float b1 = min(step(Top, Y), step(Y , Bottom));
|
|
// (Y == height / 2)
|
|
float b2 = min(step(Y, height / 2), step(height / 2, Y));
|
|
float b3 = max(b1, b2);
|
|
Result[id.xy] = lerp(BgColor, WaveColor, b3);
|
|
} |