Commit 07b11592 authored by hunterk's avatar hunterk
Browse files

more cleanups and COMPAT_PRECISION redef fixes

parent f5645639
......@@ -66,7 +66,6 @@ COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;
// out variables go here as COMPAT_VARYING whatever
COMPAT_VARYING vec4 t1;
COMPAT_VARYING vec2 loc;
......@@ -126,7 +125,6 @@ uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform sampler2D Texture;
COMPAT_VARYING vec4 TEX0;
// in variables go here as COMPAT_VARYING whatever
COMPAT_VARYING vec4 t1;
COMPAT_VARYING vec2 loc;
......@@ -143,7 +141,7 @@ const COMPAT_PRECISION float3 Y = float3(.2126, .7152, .0722);
float luma(float3 color)
{
return dot(color, Y);
return dot(color, Y);
}
COMPAT_PRECISION float3 bilinear(float p, float q, float3 A, float3 B, float3 C, float3 D)
......@@ -153,7 +151,7 @@ COMPAT_PRECISION float3 bilinear(float p, float q, float3 A, float3 B, float3 C,
void main()
{
float2 pos = frac(loc * 1.00001)-float2(0.4999, 0.4999); // pos = pixel position
float2 pos = frac(loc * 1.00001)-float2(0.4999, 0.4999); // pos = pixel position
float2 dir = sign(pos); // dir = pixel direction
float2 g1 = dir*t1.xy;
......@@ -195,6 +193,6 @@ float2 pos = frac(loc * 1.00001)-float2(0.4999, 0.4999); // pos = pixel position
}
float3 color = bilinear(p, q, A, B, C, D);
FragColor = vec4(color, 1.0);
FragColor = vec4(color, 1.0);
}
#endif
......@@ -26,24 +26,9 @@
*/
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter TWO_D_SCALE "2D Filter Scale" 2.0 1.0 8.0 1.0
#pragma parameter THREE_D_SCALE "3D Filter Scale" 4.0 1.0 8.0 1.0
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float TWO_D_SCALE;
uniform COMPAT_PRECISION float THREE_D_SCALE;
#else
#define TWO_D_SCALE 2.0
#define THREE_D_SCALE 4.0
#endif
#if defined(VERTEX)
......@@ -68,7 +53,6 @@ COMPAT_ATTRIBUTE vec4 COLOR;
COMPAT_ATTRIBUTE vec4 TexCoord;
COMPAT_VARYING vec4 COL0;
COMPAT_VARYING vec4 TEX0;
// out variables go here as COMPAT_VARYING whatever
vec4 _oPosition1;
uniform mat4 MVPMatrix;
......@@ -115,7 +99,6 @@ uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
uniform sampler2D Texture;
COMPAT_VARYING vec4 TEX0;
// in variables go here as COMPAT_VARYING whatever
// compatibility #defines
#define Source Texture
......@@ -124,6 +107,15 @@ COMPAT_VARYING vec4 TEX0;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float TWO_D_SCALE;
uniform COMPAT_PRECISION float THREE_D_SCALE;
#else
#define TWO_D_SCALE 2.0
#define THREE_D_SCALE 4.0
#endif
vec2 Size1D = vec2( SourceSize.x, SourceSize.y );
vec2 InvSize1D = 1.0 / Size1D;//vec2(0.000976562,0.001953125);
vec4 Size2D = vec4(vec2(TWO_D_SCALE * Size1D), vec2(1.0 / (TWO_D_SCALE * Size1D)));//vec4( 2048.0, 1024.0, 0.00048828125 , 0.0009765625 );
......
......@@ -21,59 +21,8 @@
*/
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
precision highp float;
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter filterparam "Edge Size" 7.0 1.0 25.0 1.0
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float filterparam;
#else
#define filterparam 7.0
#endif
//const vec4 Size = vec4( 1024.0, 512.0, 0.0009765625, 0.001953125 );
const vec4 Size = vec4( 2048.0, 1024.0, 0.00048828125, 0.0009765625 );
float CLength(vec3 c1){
float rmean = c1.r*0.5;
c1*= c1;
return sqrt((2.0+rmean)*c1.r+4.0*c1.g+(3.0-rmean)*c1.b);
}
float Cdistance(vec3 c1, vec3 c2){
float rmean = (c1.r+c2.r)*0.5;
c1 = pow(c1-c2,vec3(2.0));
return sqrt((2.0+rmean)*c1.r+4.0*c1.g+(3.0-rmean)*c1.b);
}
vec3 ColMin(vec3 a, vec3 b){
float dist = step(0.01,sign(CLength(a) - CLength(b)));
return mix(a,b,dist);
}
vec3 ColMax(vec3 a, vec3 b){
float dist = step(0.01,sign(CLength(a) - CLength(b)));
return mix(b,a,dist);
}
#if defined(VERTEX)
......@@ -152,6 +101,50 @@ COMPAT_VARYING vec4 TEX0;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutputSize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float filterparam;
#else
#define filterparam 7.0
#endif
//const vec4 Size = vec4( 1024.0, 512.0, 0.0009765625, 0.001953125 );
const vec4 Size = vec4( 2048.0, 1024.0, 0.00048828125, 0.0009765625 );
float CLength(vec3 c1){
float rmean = c1.r*0.5;
c1*= c1;
return sqrt((2.0+rmean)*c1.r+4.0*c1.g+(3.0-rmean)*c1.b);
}
float Cdistance(vec3 c1, vec3 c2){
float rmean = (c1.r+c2.r)*0.5;
c1 = pow(c1-c2,vec3(2.0));
return sqrt((2.0+rmean)*c1.r+4.0*c1.g+(3.0-rmean)*c1.b);
}
vec3 ColMin(vec3 a, vec3 b){
float dist = step(0.01,sign(CLength(a) - CLength(b)));
return mix(a,b,dist);
}
vec3 ColMax(vec3 a, vec3 b){
float dist = step(0.01,sign(CLength(a) - CLength(b)));
return mix(b,a,dist);
}
vec3 Blur( sampler2D Frame, vec2 TexCoord ) {
vec2 shift = Size.zw * 0.5;
......
......@@ -25,22 +25,8 @@
*/
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
precision COMPAT_PRECISION float;
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter SIGMA_R "Bilateral Blur" 0.4 0.0 1.0 0.1
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float SIGMA_R;
#else
#define SIGMA_R 0.4
#endif
#define saturate(c) clamp(c, 0.0, 1.0)
#define lerp(c) mix(c)
......@@ -141,6 +127,13 @@ COMPAT_VARYING vec4 TEX0;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define outsize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float SIGMA_R;
#else
#define SIGMA_R 0.4
#endif
#define GET(M,K) (tex2D(decal,tc+M*dx+K*dy).xyz)
void main()
......
......@@ -6,47 +6,9 @@
// url: http://devlog-martinsh.blogspot.com/2011/03/glsl-8x8-bayer-matrix-dithering.html
// adapted for RetroArch by hunterk
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter animate "Dithering Animation" 0.0 0.0 1.0 1.0
#pragma parameter dither_size "Dither Size" 0.0 0.0 0.95 0.05
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float animate;
uniform COMPAT_PRECISION float dither_size;
#else
#define animate 0.0
#define dither_size 0.0
#endif
float find_closest(int x, int y, float c0)
{
int dither[8][8] = {
{ 0, 32, 8, 40, 2, 34, 10, 42}, /* 8x8 Bayer ordered dithering */
{48, 16, 56, 24, 50, 18, 58, 26}, /* pattern. Each input pixel */
{12, 44, 4, 36, 14, 46, 6, 38}, /* is scaled to the 0..63 range */
{60, 28, 52, 20, 62, 30, 54, 22}, /* before looking in this table */
{ 3, 35, 11, 43, 1, 33, 9, 41}, /* to determine the action. */
{51, 19, 59, 27, 49, 17, 57, 25},
{15, 47, 7, 39, 13, 45, 5, 37},
{63, 31, 55, 23, 61, 29, 53, 21} };
float limit = 0.0;
if(x < 8)
{
limit = (dither[x][y]+1)/64.0;
}
if(c0 < limit)
return 0.0;
return 1.0;
}
#if defined(VERTEX)
......@@ -124,6 +86,38 @@ COMPAT_VARYING vec4 TEX0;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define outsize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float animate;
uniform COMPAT_PRECISION float dither_size;
#else
#define animate 0.0
#define dither_size 0.0
#endif
float find_closest(int x, int y, float c0)
{
int dither[8][8] = {
{ 0, 32, 8, 40, 2, 34, 10, 42}, /* 8x8 Bayer ordered dithering */
{48, 16, 56, 24, 50, 18, 58, 26}, /* pattern. Each input pixel */
{12, 44, 4, 36, 14, 46, 6, 38}, /* is scaled to the 0..63 range */
{60, 28, 52, 20, 62, 30, 54, 22}, /* before looking in this table */
{ 3, 35, 11, 43, 1, 33, 9, 41}, /* to determine the action. */
{51, 19, 59, 27, 49, 17, 57, 25},
{15, 47, 7, 39, 13, 45, 5, 37},
{63, 31, 55, 23, 61, 29, 53, 21} };
float limit = 0.0;
if(x < 8)
{
limit = (dither[x][y]+1)/64.0;
}
if(c0 < limit)
return 0.0;
return 1.0;
}
void main()
{
float Scale = 3.0 + mod(2.0 * FrameCount, 32.0) * animate + dither_size;
......
......@@ -26,13 +26,6 @@
/ POSSIBILITY OF SUCH DAMAGE.
*/
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
#if defined(VERTEX)
#if __VERSION__ >= 130
......
......@@ -26,13 +26,6 @@
/ POSSIBILITY OF SUCH DAMAGE.
*/
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
#if defined(VERTEX)
#if __VERSION__ >= 130
......
......@@ -6,24 +6,9 @@
*/
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter MODE "GDAPT Monochrome Analysis" 0.0 0.0 1.0 1.0
#pragma parameter PWR "GDAPT Color Metric Exp" 2.0 0.0 10.0 0.1
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float MODE;
uniform COMPAT_PRECISION float PWR;
#else
#define MODE 0.0
#define PWR 2.0
#endif
#if defined(VERTEX)
......@@ -109,6 +94,15 @@ COMPAT_VARYING vec2 t1;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define outsize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float MODE;
uniform COMPAT_PRECISION float PWR;
#else
#define MODE 0.0
#define PWR 2.0
#endif
#define dot(x,y) clamp(dot(x,y), 0.0, 1.0) // NVIDIA Fix
#define TEX(dx,dy) texture(Source, vTexCoord+vec2((dx),(dy))*t1).xyz
......
......@@ -6,27 +6,10 @@
*/
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter STEPS "GDAPT Error Prevention LVL" 1.0 0.0 5.0 1.0
#pragma parameter DEBUG "GDAPT Adjust View" 0.0 0.0 1.0 1.0
#pragma parameter linear_gamma "Use Linear Gamma" 0.0 0.0 1.0 1.0
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float STEPS;
uniform COMPAT_PRECISION float DEBUG;
uniform COMPAT_PRECISION float linear_gamma;
#else
#define STEPS 1.0
#define DEBUG 0.0
#define linear_gamma 0.0
#endif
#if defined(VERTEX)
......@@ -111,6 +94,17 @@ COMPAT_VARYING vec2 t1;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define outsize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float STEPS;
uniform COMPAT_PRECISION float DEBUG;
uniform COMPAT_PRECISION float linear_gamma;
#else
#define STEPS 1.0
#define DEBUG 0.0
#define linear_gamma 0.0
#endif
#define TEX(dx,dy) texture(Source, vTexCoord+vec2((dx),(dy))*t1)
void main()
......
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter box_scale "Image Scale" 4.0 1.0 10.0 1.0
#pragma parameter location_x "Viewport X Pos." 0.5 0.0 1.0 0.05
......@@ -14,26 +7,6 @@
#pragma parameter border_on_top "Show Viewport" 1.0 0.0 1.0 1.0
#pragma parameter border_zoom_x "Border Zoom X" 1.0 0.0 4.0 0.01
#pragma parameter border_zoom_y "Border Zoom Y" 1.0 0.0 4.0 0.01
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float box_scale;
uniform COMPAT_PRECISION float location_x;
uniform COMPAT_PRECISION float location_y;
uniform COMPAT_PRECISION float in_res_x;
uniform COMPAT_PRECISION float in_res_y;
uniform COMPAT_PRECISION float border_on_top;
uniform COMPAT_PRECISION float border_zoom_x;
uniform COMPAT_PRECISION float border_zoom_y;
#else
#define box_scale 4.0
#define location_x 0.5
#define location_y 0.5
#define in_res_x 320.0
#define in_res_y 240.0
#define border_on_top 1.0
#define border_zoom_x 1.0
#define border_zoom_y 1.0
#endif
#if defined(VERTEX)
......@@ -67,6 +40,27 @@ uniform COMPAT_PRECISION vec2 TextureSize;
uniform COMPAT_PRECISION vec2 InputSize;
COMPAT_VARYING vec2 screen_coord;
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float box_scale;
uniform COMPAT_PRECISION float location_x;
uniform COMPAT_PRECISION float location_y;
uniform COMPAT_PRECISION float in_res_x;
uniform COMPAT_PRECISION float in_res_y;
uniform COMPAT_PRECISION float border_on_top;
uniform COMPAT_PRECISION float border_zoom_x;
uniform COMPAT_PRECISION float border_zoom_y;
#else
#define box_scale 4.0
#define location_x 0.5
#define location_y 0.5
#define in_res_x 320.0
#define in_res_y 240.0
#define border_on_top 1.0
#define border_zoom_x 1.0
#define border_zoom_y 1.0
#endif
void main()
{
gl_Position = MVPMatrix * VertexCoord;
......@@ -120,6 +114,17 @@ COMPAT_VARYING vec2 screen_coord;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define outsize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
uniform COMPAT_PRECISION float box_scale;
uniform COMPAT_PRECISION float location_x;
uniform COMPAT_PRECISION float location_y;
uniform COMPAT_PRECISION float in_res_x;
uniform COMPAT_PRECISION float in_res_y;
uniform COMPAT_PRECISION float border_on_top;
uniform COMPAT_PRECISION float border_zoom_x;
uniform COMPAT_PRECISION float border_zoom_y;
#endif
void main()
{
vec4 screen = texture(Source, screen_coord); //the main video screen
......
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter SCALE "Box Scale" 0.6667 0.6667 1.5 0.33333
#pragma parameter OUT_X "Out X" 1600.0 1600.0 4800.0 8000.0
#pragma parameter OUT_Y "Out Y" 800.0 800.0 2400.0 400.0
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float SCALE;
uniform COMPAT_PRECISION float OUT_X;
uniform COMPAT_PRECISION float OUT_Y;
#else
#define SCALE 0.66667
#define OUT_X 1600.0
#define OUT_Y 800.0
#endif
#if defined(VERTEX)
......@@ -56,6 +39,17 @@ COMPAT_VARYING vec2 tex_border;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define outsize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float SCALE;
uniform COMPAT_PRECISION float OUT_X;
uniform COMPAT_PRECISION float OUT_Y;
#else
#define SCALE 0.66667
#define OUT_X 1600.0
#define OUT_Y 800.0
#endif
void main()
{
gl_Position = MVPMatrix * VertexCoord;
......
......@@ -6,21 +6,8 @@
*/
// Shader that replicates the LCD dynamics from a GameBoy Advance
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif
// Parameter lines go here:
#pragma parameter darken_screen "Darken Screen" 0.5 0.0 1.0 0.05
#ifdef PARAMETER_UNIFORM
// All parameter floats need to have COMPAT_PRECISION in front of them
uniform COMPAT_PRECISION float darken_screen;
#else
#define darken_screen 0.5
#endif
#define target_gamma 2.2
#define display_gamma 2.5
......@@ -118,6 +105,12 @@ COMPAT_VARYING vec4 TEX0;
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define outsize vec4(OutputSize, 1.0 / OutputSize)
#ifdef PARAMETER_UNIFORM
uniform COMPAT_PRECISION float darken_screen;
#else
#define darken_screen 0.5
#endif
void main()
{
vec4 screen = pow(texture(Source, vTexCoord), vec4(target_gamma + darken_screen)).rgba;
......
......@@ -6,21 +6,8 @@
*/
// Shader that replicates the LCD dynamics from a Nintendo DS Phat
// Compatibility #ifdefs needed for parameters
#ifdef GL_ES
#define COMPAT_PRECISION mediump
#else
#define COMPAT_PRECISION
#endif