forked from OctaForge/OctaCore
99 lines
2.6 KiB
INI
99 lines
2.6 KiB
INI
//////////////////////////////////////////////////////////////////////
|
|
//
|
|
// upscaling shaders
|
|
//
|
|
//////////////////////////////////////////////////////////////////////
|
|
|
|
shader 0 "scalelinear" [
|
|
attribute vec4 vvertex;
|
|
@(screentexcoord 0)
|
|
varying vec2 texcoord0;
|
|
|
|
void main(void)
|
|
{
|
|
gl_Position = vvertex;
|
|
texcoord0 = vtexcoord0;
|
|
}
|
|
] [
|
|
uniform sampler2DRect tex0;
|
|
varying vec2 texcoord0;
|
|
fragdata(0) vec4 fragcolor;
|
|
|
|
void main(void)
|
|
{
|
|
fragcolor = texture2DRect(tex0, texcoord0);
|
|
}
|
|
]
|
|
|
|
loop i 2 [
|
|
lazyshader 0 (? $i "scalecubicy" "scalecubicx") [
|
|
attribute vec4 vvertex;
|
|
@(screentexcoord 0)
|
|
varying vec2 texcoord0;
|
|
|
|
void main(void)
|
|
{
|
|
gl_Position = vvertex;
|
|
texcoord0 = vtexcoord0;
|
|
}
|
|
] [
|
|
uniform sampler2DRect tex0;
|
|
varying vec2 texcoord0;
|
|
fragdata(0) vec4 fragcolor;
|
|
|
|
vec4 cubic(float s)
|
|
{
|
|
const float B = @gscalecubicsoft, C = @(divf (-f 1 $gscalecubicsoft) 2);
|
|
float s2 = s*s, s3 = s2*s;
|
|
return vec4((-1.0/6.0*B - C) * s3 + (0.5*B + 2.0*C) * s2 + (-0.5*B - C) * s + 1.0/6.0*B,
|
|
(2.0 - 1.5*B - C) * s3 + (-3.0 + 2.0*B + C) * s2 + (1.0 - 1.0/3.0*B),
|
|
(-2.0 + 1.5*B + C) * s3 + (3.0 - 2.5*B - 2.0*C) * s2 + (0.5*B + C)*s + 1.0/6.0*B,
|
|
(1.0/6.0*B + C) * s3 - C * s2);
|
|
}
|
|
|
|
void main(void)
|
|
{
|
|
vec2 center = texcoord0;
|
|
@(if $i [result [
|
|
float offset = fract(texcoord0.y-0.5);
|
|
center.y -= offset;
|
|
#define texval(tap) texture2DRect(tex0, center + vec2(0.0, tap))
|
|
#define texvaloffset(tap) texture2DRectOffset(tex0, center, ivec2(0, tap))
|
|
]] [result [
|
|
float offset = fract(texcoord0.x-0.5);
|
|
center.x -= offset;
|
|
#define texval(tap) texture2DRect(tex0, center + vec2(tap, 0.0))
|
|
#define texvaloffset(tap) texture2DRectOffset(tex0, center, ivec2(tap, 0))
|
|
]])
|
|
vec4 weight = cubic(offset);
|
|
weight.y += weight.z;
|
|
weight.z /= weight.y;
|
|
fragcolor = weight.x*texvaloffset(-1) + weight.y*texval(weight.z) + weight.w*texvaloffset(2);
|
|
}
|
|
]
|
|
]
|
|
|
|
shader 0 "reorient" [
|
|
attribute vec4 vvertex;
|
|
uniform vec3 reorientx, reorienty;
|
|
varying vec2 texcoord0;
|
|
|
|
void main(void)
|
|
{
|
|
gl_Position = vvertex;
|
|
texcoord0.x = dot(vvertex.xy, reorientx.xy) + reorientx.z;
|
|
texcoord0.y = dot(vvertex.xy, reorienty.xy) + reorienty.z;
|
|
}
|
|
] [
|
|
uniform sampler2DRect tex0;
|
|
varying vec2 texcoord0;
|
|
fragdata(0) vec4 fragcolor;
|
|
|
|
void main(void)
|
|
{
|
|
fragcolor = texture2DRect(tex0, texcoord0);
|
|
}
|
|
]
|
|
|
|
|