-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scanlines-Sine-Abs-SmartRes.fx
100 lines (72 loc) · 2.26 KB
/
Scanlines-Sine-Abs-SmartRes.fx
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
/*
Scanlines Sine Absolute Value
An ultra light scanline shader
by RiskyJumps
license: public domain
*/
#define amp 1.250000
#define phase 0.500000
#define lines_black 0.000000
#define lines_white 1.000000
#define freq 0.500000
#define offset 0.000000
#define pi 3.141592654
string name : NAME = "point";
float2 ps1 : TEXELSIZE;
float2 ir : sourcescale;
float4x4 World : WORLD;
float4x4 View : VIEW;
float4x4 Projection : PROJECTION;
float4x4 Worldview : WORLDVIEW; // world * view
float4x4 ViewProjection : VIEWPROJECTION; // view * projection
float4x4 WorldViewProjection : WORLDVIEWPROJECTION; // world * view * projection
string combineTechique : COMBINETECHNIQUE = "POINT";
texture SourceTexture : SOURCETEXTURE;
sampler decal = sampler_state
{
Texture = (SourceTexture);
MinFilter = POINT;
MagFilter = POINT;
};
struct out_vertex {
float4 position : POSITION;
float4 color : COLOR;
float2 t0 : TEXCOORD0;
float angle : TEXCOORD1;
};
out_vertex VS_VERTEX(float3 position : POSITION, float2 texCoord : TEXCOORD0 )
{
float2 tmp = (ir.x < 1.0) ? float2(1.0,1.0) : ir;
float2 ps = ps1*tmp;
out_vertex OUT = (out_vertex)0;
OUT.position = mul(float4(position,1.0),WorldViewProjection);
OUT.t0 = texCoord;
float omega = 2.0 * pi * freq; // Angular frequency
OUT.angle = texCoord.y * omega / ps.y + phase;
return OUT;
}
float4 scanline_sine_abs(float angle, float2 texCoord)
{
float3 color = tex2D(decal, texCoord).xyz;
float grid;
float lines;
lines = sin(angle);
lines *= amp;
lines += offset;
lines = abs(lines) * (lines_white - lines_black) + lines_black;
color *= lines;
return color.xyzz;
}
float4 PS_FRAGMENT (in out_vertex VAR) : COLOR
{
return scanline_sine_abs(VAR.angle, VAR.t0);
}
technique POINT
{
pass P0
{
// shaders
VertexShader = compile vs_2_0 VS_VERTEX();
PixelShader = compile ps_2_0 PS_FRAGMENT();
}
}