forked from ge9/IddSampleDriver
-
-
Notifications
You must be signed in to change notification settings - Fork 366
Expand file tree
/
Copy pathwave_shader.hlsl
More file actions
85 lines (68 loc) · 2.21 KB
/
wave_shader.hlsl
File metadata and controls
85 lines (68 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
// Wave Shader - Animated wave with bottom bar effect
// Vertex and Pixel Shaders for Virtual Display Driver
cbuffer PerFrameBuffer : register(b0)
{
float4 resolution;
float time;
float amplitude;
};
Texture2D InputTexture : register(t0);
SamplerState InputSampler : register(s0);
struct VS_INPUT
{
float4 position : POSITION;
float2 texcoord : TEXCOORD0;
};
struct PS_INPUT
{
float4 position : SV_POSITION;
float2 texcoord : TEXCOORD0;
};
// Standard fullscreen quad vertex shader
PS_INPUT VSMain(VS_INPUT input)
{
PS_INPUT output;
output.position = input.position;
output.texcoord = input.texcoord;
return output;
};
// Pixel shader - White bar at bottom + animated wave
float4 PSMain(PS_INPUT input) : SV_Target
{
float2 uv = input.texcoord;
// Get screen dimensions for pixel-perfect calculations
float screenHeight = resolution.y;
float screenWidth = resolution.x;
// Convert UV coordinates to pixel coordinates
float2 pixelPos = uv * resolution.xy;
// White horizontal bar at the bottom (3 pixels tall)
float barHeight = 3.0;
float barStart = screenHeight - barHeight;
float4 finalColor = InputTexture.Sample(InputSampler, uv);
// Draw bottom bar
if (pixelPos.y >= barStart)
{
finalColor = lerp(finalColor, float4(1.0, 1.0, 1.0, 1.0), 0.85);
}
else
{
// Animated wave that travels side-to-side
// Wave position based on time and UV coordinates
float waveFrequency = 0.05; // How many waves across screen
float waveSpeed = 2.0; // How fast wave moves
// Calculate wave position
float wavePos = sin(uv.x * 6.28318 * waveFrequency + time * waveSpeed);
// Wave center line (middle of screen)
float waveCenter = 0.5;
// Wave thickness (controls how thick wave line is)
float waveThickness = 0.02;
// Distance from wave center
float distanceFromWave = abs(uv.y - waveCenter - wavePos * amplitude * 0.1);
// If pixel is within wave thickness, make it white
if (distanceFromWave < waveThickness)
{
finalColor = lerp(finalColor, float4(1.0, 1.0, 1.0, 1.0), 0.85);
}
}
return finalColor;
};