42 lines
913 B
HLSL
42 lines
913 B
HLSL
RWTexture2D<float4> Result;
|
|
RWStructuredBuffer<float> Samples;
|
|
cbuffer Params : register(b0)
|
|
{
|
|
float4 WaveColor;
|
|
float4 BgColor;
|
|
float LineUV;
|
|
};
|
|
|
|
[numthreads(1, 1, 1)]
|
|
void Main(uint3 id : SV_DispatchThreadID)
|
|
{
|
|
uint width, height;
|
|
Result.GetDimensions(width, height);
|
|
|
|
// float2 uv = float2(id.xy / float2(width, height));
|
|
// uv.y = abs(((1.0 - uv.y) - 0.5) * 2); // 居中
|
|
|
|
int X = id.x;
|
|
int Y = id.y;
|
|
|
|
// float4 color = lerp(BgColor, WaveColor, min(step(value.x, uv.y), step(uv.y , value.y)));
|
|
|
|
float Top = Samples[X * 2] + 1; // -1;
|
|
float Bottom = Samples[X * 2 + 1] + 1; // 1;
|
|
Top = min(Top, 1);
|
|
Bottom = max(Bottom, 0);
|
|
Top *= height;
|
|
Top *= 0.5;
|
|
Bottom *= height;
|
|
Bottom *= 0.5;
|
|
|
|
|
|
if ((id.y <= Bottom && id.y >= Top) || (Y == height / 2))
|
|
{
|
|
Result[id.xy] = WaveColor;
|
|
}
|
|
else
|
|
{
|
|
Result[id.xy] = BgColor;
|
|
}
|
|
} |