File: scale2x.frag

package info (click to toggle)
openmsx 20.0%2Bdfsg-1.2
  • links: PTS
  • area: main
  • in suites: forky, sid, trixie
  • size: 27,544 kB
  • sloc: cpp: 236,922; xml: 49,948; tcl: 15,056; python: 5,385; perl: 281; sh: 77; makefile: 53
file content (41 lines) | stat: -rw-r--r-- 876 bytes parent folder | download | duplicates (4)
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
// Scale2x scaler.

uniform sampler2D tex;
uniform sampler2D videoTex;

varying vec2 texStep; // could be uniform
varying vec2 coord2pi;
varying vec2 texCoord;
varying vec2 videoCoord;

vec4 scaleNx()
{
	vec4 delta;
	delta.xw = sin(coord2pi) * texStep;
	delta.yz = vec2(0.0);

	vec4 posLeftTop  = texCoord.stst - delta;
	vec4 posRightBot = texCoord.stst + delta;

	vec4 left  = texture2D(tex, posLeftTop.xy);
	vec4 top   = texture2D(tex, posLeftTop.zw);
	vec4 right = texture2D(tex, posRightBot.xy);
	vec4 bot   = texture2D(tex, posRightBot.zw);

	if (dot(left.rgb - right.rgb, top.rgb - bot.rgb) == 0.0 || left.rgb != top.rgb) {
		return texture2D(tex, texCoord.st);
	} else {
		return top;
	}
}

void main()
{
#if SUPERIMPOSE
	vec4 col = scaleNx();
	vec4 vid = texture2D(videoTex, videoCoord);
	gl_FragColor = mix(vid, col, col.a);
#else
	gl_FragColor = scaleNx();
#endif
}