-
Notifications
You must be signed in to change notification settings - Fork 223
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #202 from gizmo98/linear-interpolation
Add horizontal and vertical linear interpolation shaders
- Loading branch information
Showing
4 changed files
with
229 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
shaders = "1" | ||
shader0 = "shaders/horizontal-linear.glsl" | ||
filter_linear0 = "true" | ||
scale_type0 = viewport | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,110 @@ | ||
/* | ||
* gizmo98 horizontal-linear shader | ||
* Copyright (C) 2023 gizmo98 | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* version 0.1, 10.05.2023 | ||
* --------------------------------------------------------------------------------------- | ||
* - initial commit | ||
* | ||
* https://github.com/gizmo98/gizmo-crt-shader | ||
* | ||
* This shader uses texture AA shader code in vertical direction and linear interpolation in | ||
* horizontal direction with only one texel fetch. | ||
* | ||
* uses parts of texture anti-aliasing shader from Ikaros https://www.shadertoy.com/view/ldsSRX | ||
*/ | ||
|
||
#if defined(VERTEX) | ||
|
||
#if __VERSION__ >= 130 | ||
#define COMPAT_VARYING out | ||
#define COMPAT_ATTRIBUTE in | ||
#define COMPAT_TEXTURE texture | ||
#else | ||
#define COMPAT_VARYING varying | ||
#define COMPAT_ATTRIBUTE attribute | ||
#define COMPAT_TEXTURE texture2D | ||
#endif | ||
|
||
#ifdef GL_ES | ||
#define COMPAT_PRECISION mediump | ||
#else | ||
#define COMPAT_PRECISION | ||
#endif | ||
|
||
COMPAT_ATTRIBUTE vec4 VertexCoord; | ||
COMPAT_ATTRIBUTE vec4 COLOR; | ||
COMPAT_ATTRIBUTE vec4 TexCoord; | ||
COMPAT_VARYING vec4 COL0; | ||
COMPAT_VARYING vec4 TEX0; | ||
|
||
uniform mat4 MVPMatrix; | ||
uniform COMPAT_PRECISION int FrameDirection; | ||
uniform COMPAT_PRECISION int FrameCount; | ||
uniform COMPAT_PRECISION vec2 OutputSize; | ||
uniform COMPAT_PRECISION vec2 TextureSize; | ||
uniform COMPAT_PRECISION vec2 InputSize; | ||
|
||
void main() | ||
{ | ||
gl_Position = VertexCoord.x * MVPMatrix[0] + VertexCoord.y * MVPMatrix[1] + VertexCoord.z * MVPMatrix[2] + VertexCoord.w * MVPMatrix[3]; | ||
TEX0.xy = TexCoord.xy; | ||
} | ||
|
||
#elif defined(FRAGMENT) | ||
|
||
#if __VERSION__ >= 130 | ||
#define COMPAT_VARYING in | ||
#define COMPAT_TEXTURE texture | ||
out vec4 FragColor; | ||
#else | ||
#define COMPAT_VARYING varying | ||
#define FragColor gl_FragColor | ||
#define COMPAT_TEXTURE texture2D | ||
#endif | ||
|
||
#ifdef GL_ES | ||
#ifdef GL_FRAGMENT_PRECISION_HIGH | ||
precision highp float; | ||
#else | ||
precision mediump float; | ||
#endif | ||
#define COMPAT_PRECISION mediump | ||
#else | ||
#define COMPAT_PRECISION | ||
#endif | ||
|
||
uniform COMPAT_PRECISION int FrameDirection; | ||
uniform COMPAT_PRECISION int FrameCount; | ||
uniform COMPAT_PRECISION vec2 OutputSize; | ||
uniform COMPAT_PRECISION vec2 TextureSize; | ||
uniform COMPAT_PRECISION vec2 InputSize; | ||
uniform sampler2D Texture; | ||
COMPAT_VARYING vec4 TEX0; | ||
|
||
vec2 saturateA(in vec2 x) | ||
{ | ||
return clamp(x, 0.0, 1.0); | ||
} | ||
|
||
vec2 magnify(in vec2 uv, in vec2 res) | ||
{ | ||
uv *= res; | ||
return (saturateA(fract(uv) / saturateA(fwidth(uv))) + floor(uv) - 0.5) / res.xy; | ||
} | ||
vec4 textureAA(in vec2 uv){ | ||
uv.y = magnify(uv,TextureSize.xy).y; | ||
return COMPAT_TEXTURE( Texture, uv ); | ||
|
||
} | ||
|
||
void main() | ||
{ | ||
FragColor = textureAA(TEX0.xy); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
/* | ||
* gizmo98 vertical-linear shader | ||
* Copyright (C) 2023 gizmo98 | ||
* | ||
* This program is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License as published by the Free | ||
* Software Foundation; either version 2 of the License, or (at your option) | ||
* any later version. | ||
* | ||
* version 0.1, 10.05.2023 | ||
* --------------------------------------------------------------------------------------- | ||
* - initial commit | ||
* | ||
* https://github.com/gizmo98/gizmo-crt-shader | ||
* | ||
* This shader uses texture AA shader code in horizontal direction and linear interpolation in | ||
* vertical direction with only one texel fetch. | ||
* | ||
* uses parts of texture anti-aliasing shader from Ikaros https://www.shadertoy.com/view/ldsSRX | ||
*/ | ||
|
||
#if defined(VERTEX) | ||
|
||
#if __VERSION__ >= 130 | ||
#define COMPAT_VARYING out | ||
#define COMPAT_ATTRIBUTE in | ||
#define COMPAT_TEXTURE texture | ||
#else | ||
#define COMPAT_VARYING varying | ||
#define COMPAT_ATTRIBUTE attribute | ||
#define COMPAT_TEXTURE texture2D | ||
#endif | ||
|
||
#ifdef GL_ES | ||
#define COMPAT_PRECISION mediump | ||
#else | ||
#define COMPAT_PRECISION | ||
#endif | ||
|
||
COMPAT_ATTRIBUTE vec4 VertexCoord; | ||
COMPAT_ATTRIBUTE vec4 COLOR; | ||
COMPAT_ATTRIBUTE vec4 TexCoord; | ||
COMPAT_VARYING vec4 COL0; | ||
COMPAT_VARYING vec4 TEX0; | ||
|
||
uniform mat4 MVPMatrix; | ||
uniform COMPAT_PRECISION int FrameDirection; | ||
uniform COMPAT_PRECISION int FrameCount; | ||
uniform COMPAT_PRECISION vec2 OutputSize; | ||
uniform COMPAT_PRECISION vec2 TextureSize; | ||
uniform COMPAT_PRECISION vec2 InputSize; | ||
|
||
void main() | ||
{ | ||
gl_Position = VertexCoord.x * MVPMatrix[0] + VertexCoord.y * MVPMatrix[1] + VertexCoord.z * MVPMatrix[2] + VertexCoord.w * MVPMatrix[3]; | ||
TEX0.xy = TexCoord.xy; | ||
} | ||
|
||
#elif defined(FRAGMENT) | ||
|
||
#if __VERSION__ >= 130 | ||
#define COMPAT_VARYING in | ||
#define COMPAT_TEXTURE texture | ||
out vec4 FragColor; | ||
#else | ||
#define COMPAT_VARYING varying | ||
#define FragColor gl_FragColor | ||
#define COMPAT_TEXTURE texture2D | ||
#endif | ||
|
||
#ifdef GL_ES | ||
#ifdef GL_FRAGMENT_PRECISION_HIGH | ||
precision highp float; | ||
#else | ||
precision mediump float; | ||
#endif | ||
#define COMPAT_PRECISION mediump | ||
#else | ||
#define COMPAT_PRECISION | ||
#endif | ||
|
||
uniform COMPAT_PRECISION int FrameDirection; | ||
uniform COMPAT_PRECISION int FrameCount; | ||
uniform COMPAT_PRECISION vec2 OutputSize; | ||
uniform COMPAT_PRECISION vec2 TextureSize; | ||
uniform COMPAT_PRECISION vec2 InputSize; | ||
uniform sampler2D Texture; | ||
COMPAT_VARYING vec4 TEX0; | ||
|
||
vec2 saturateA(in vec2 x) | ||
{ | ||
return clamp(x, 0.0, 1.0); | ||
} | ||
|
||
vec2 magnify(in vec2 uv, in vec2 res) | ||
{ | ||
uv *= res; | ||
return (saturateA(fract(uv) / saturateA(fwidth(uv))) + floor(uv) - 0.5) / res.xy; | ||
} | ||
vec4 textureAA(in vec2 uv){ | ||
uv.x = magnify(uv,TextureSize.xy).x; | ||
return COMPAT_TEXTURE( Texture, uv ); | ||
} | ||
|
||
void main() | ||
{ | ||
FragColor = textureAA(TEX0.xy); | ||
} | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
shaders = "1" | ||
shader0 = "shaders/vertical-linear.glsl" | ||
filter_linear0 = "true" | ||
scale_type0 = viewport | ||
|