OXYGENHUB
◆ main openmsx / share / shaders / rgb.frag
928 B · last changed chore(): initial commit 1 month ago source blame history raw
e8555c89 Andy McCall 1
uniform sampler2D tex;
2
uniform sampler2D videoTex;
3
uniform vec4 cnsts;
4
5
varying vec4 scaled;
6
varying vec2 pos;
7
varying vec2 videoCoord;
8
9
// saturate operations are free on nvidia hardware
10
vec3 saturate(vec3 x)
11
{
12
	return clamp(x, 0.0, 1.0);
13
}
14
15
void main()
16
{
17
	float scan_a    = cnsts.x;
18
	float scan_b_c2 = cnsts.y; // scan_b * c2
19
	float scan_c_c2 = cnsts.z; // scan_c * c2
20
	float c1_2_2    = cnsts.w; // (c1 - c2) / c2
21
22
	float scan_c2 = scan_c_c2 + scan_b_c2 * abs(fract(scaled.w) - scan_a);
23
24
	const float BIG = 128.0; // big number, actual value is not important
25
	vec3 m = saturate((-BIG * fract(scaled.zyx)) + vec3(2.0 * BIG / 3.0));
26
27
	vec4 col = texture2D(tex, pos);
28
#if SUPERIMPOSE
29
	vec4 vid = texture2D(videoTex, videoCoord);
30
	vec4 p = mix(vid, col, col.a);
31
#else
32
	vec4 p = col;
33
#endif
34
	vec3 n = p.rgb * scan_c2;
35
	vec3 s_n = n * c1_2_2 + saturate((n - 1.0) / 2.0);
36
	gl_FragColor.rgb = n + m * s_n;
37
	gl_FragColor.a   = p.a;
38
}