Unverified Commit 75b44865 authored by hizzlekizzle's avatar hizzlekizzle Committed by GitHub
Browse files

Merge pull request #119 from RokkumanX/master

SameBoy palettes
parents 60d02f89 66005e6b
shaders = "2"
shader0 = "shaders/sameboy-palettes/response-time.glsl"
filter_linear0 = "true"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "false"
srgb_framebuffer0 = "false"
scale_type_x0 = "source"
scale_x0 = "1.000000"
scale_type_y0 = "source"
scale_y0 = "1.000000"
parameters = "response_time"
response_time = "0.333000"
shader1 = "shaders/sameboy-palettes/gb-palette.glsl"
filter_linear1 = "true"
wrap_mode1 = "clamp_to_border"
mipmap_input1 = "false"
alias1 = ""
float_framebuffer1 = "false"
srgb_framebuffer1 = "false"
scale_type_x1 = "source"
scale_x1 = "1.000000"
scale_type_y1 = "source"
scale_y1 = "1.000000"
textures = "COLOR_PALETTE"
COLOR_PALETTE = "shaders/sameboy-palettes/resources/DMG.png"
COLOR_PALETTE_linear = "false"
COLOR_PALETTE_wrap_mode = "clamp_to_border"
COLOR_PALETTE_mipmap = "false"
shaders = "2"
shader0 = "shaders/sameboy-palettes/response-time.glsl"
filter_linear0 = "true"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "false"
srgb_framebuffer0 = "false"
scale_type_x0 = "source"
scale_x0 = "1.000000"
scale_type_y0 = "source"
scale_y0 = "1.000000"
parameters = "response_time"
response_time = "0.333000"
shader1 = "shaders/sameboy-palettes/gb-palette.glsl"
filter_linear1 = "true"
wrap_mode1 = "clamp_to_border"
mipmap_input1 = "false"
alias1 = ""
float_framebuffer1 = "false"
srgb_framebuffer1 = "false"
scale_type_x1 = "source"
scale_x1 = "1.000000"
scale_type_y1 = "source"
scale_y1 = "1.000000"
textures = "COLOR_PALETTE"
COLOR_PALETTE = "shaders/sameboy-palettes/resources/GBL.png"
COLOR_PALETTE_linear = "false"
COLOR_PALETTE_wrap_mode = "clamp_to_border"
COLOR_PALETTE_mipmap = "false"
shaders = "2"
shader0 = "shaders/sameboy-palettes/response-time.glsl"
filter_linear0 = "true"
wrap_mode0 = "clamp_to_border"
mipmap_input0 = "false"
alias0 = ""
float_framebuffer0 = "false"
srgb_framebuffer0 = "false"
scale_type_x0 = "source"
scale_x0 = "1.000000"
scale_type_y0 = "source"
scale_y0 = "1.000000"
parameters = "response_time"
response_time = "0.333000"
shader1 = "shaders/sameboy-palettes/gb-palette.glsl"
filter_linear1 = "true"
wrap_mode1 = "clamp_to_border"
mipmap_input1 = "false"
alias1 = ""
float_framebuffer1 = "false"
srgb_framebuffer1 = "false"
scale_type_x1 = "source"
scale_x1 = "1.000000"
scale_type_y1 = "source"
scale_y1 = "1.000000"
textures = "COLOR_PALETTE"
COLOR_PALETTE = "shaders/sameboy-palettes/resources/GBP.png"
COLOR_PALETTE_linear = "false"
COLOR_PALETTE_wrap_mode = "clamp_to_border"
COLOR_PALETTE_mipmap = "false"
#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;
vec4 _oPosition1;
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;
// compatibility #defines
#define vTexCoord TEX0.xy
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
void main()
{
gl_Position = MVPMatrix * VertexCoord;
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;
uniform sampler2D COLOR_PALETTE;
COMPAT_VARYING vec4 TEX0;
// compatibility #defines
#define Source Texture
#define vTexCoord TEX0.xy
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
void main()
{
//sample the input textures
vec4 out_color = COMPAT_TEXTURE(Source, vTexCoord.xy);
//input grayscale values:
//0.000 black - 0.333 medium gray - 0.667 light gray - 1.000 white
//multiply grayscale value by 3 to obtain int value in range [0, 3], acts as index for arrays storing custom palette UV coordinates and alpha value
vec2 palette_coordinate = vec2(0.5, (abs(1.0 - out_color.r) * 0.75) + 0.125); //directly map input grayscale value to color palette y coordinate
out_color = vec4(COMPAT_TEXTURE(COLOR_PALETTE, palette_coordinate).rgb, ceil(abs(1.0 - out_color.r))); //sample color from palette, alpha = 1 if color is not transparent
FragColor = out_color;
}
#endif
/*
Response Time
Based on the response time function from Harlequin's Game Boy and LCD shaders
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.
*/
#pragma parameter response_time "LCD Response Time" 0.333 0.0 0.777 0.111
#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;
vec4 _oPosition1;
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;
// compatibility #defines
#define vTexCoord TEX0.xy
#define SourceSize vec4(TextureSize, 1.0 / TextureSize) //either TextureSize or InputSize
#define OutSize vec4(OutputSize, 1.0 / OutputSize)
// Vertex Shader
void main()
{
gl_Position = MVPMatrix * VertexCoord;
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;
uniform sampler2D PrevTexture;
uniform sampler2D Prev1Texture;
uniform sampler2D Prev2Texture;
uniform sampler2D Prev3Texture;
uniform sampler2D Prev4Texture;
uniform sampler2D Prev5Texture;
uniform sampler2D Prev6Texture;
COMPAT_VARYING vec4 TEX0;
// compatibility #defines
#define Source Texture
#define vTexCoord TEX0.xy
#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 response_time;
#else
#define response_time 0.333 //simulate response time, higher values result in longer color transition periods - [0, 1]
#endif
// Frame sampling definitions
#define curr_rgb COMPAT_TEXTURE(Source, vTexCoord).rgb
#define prev0_rgb COMPAT_TEXTURE(PrevTexture, vTexCoord).rgb
#define prev1_rgb COMPAT_TEXTURE(Prev1Texture, vTexCoord).rgb
#define prev2_rgb COMPAT_TEXTURE(Prev2Texture, vTexCoord).rgb
#define prev3_rgb COMPAT_TEXTURE(Prev3Texture, vTexCoord).rgb
#define prev4_rgb COMPAT_TEXTURE(Prev4Texture, vTexCoord).rgb
#define prev5_rgb COMPAT_TEXTURE(Prev5Texture, vTexCoord).rgb
#define prev6_rgb COMPAT_TEXTURE(Prev6Texture, vTexCoord).rgb
// Fragment Shader
void main()
{
// Sample color from the current and previous frames, apply response time modifier
// Response time effect implemented through an exponential dropoff algorithm
vec3 input_rgb = curr_rgb;
input_rgb += (prev0_rgb - input_rgb) * response_time;
input_rgb += (prev1_rgb - input_rgb) * pow(response_time, 2.0);
input_rgb += (prev2_rgb - input_rgb) * pow(response_time, 3.0);
input_rgb += (prev3_rgb - input_rgb) * pow(response_time, 4.0);
input_rgb += (prev4_rgb - input_rgb) * pow(response_time, 5.0);
input_rgb += (prev5_rgb - input_rgb) * pow(response_time, 6.0);
input_rgb += (prev6_rgb - input_rgb) * pow(response_time, 7.0);
FragColor = vec4(input_rgb, 0.0);
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment