-
Notifications
You must be signed in to change notification settings - Fork 218
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
125 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,9 @@ | ||
shaders = 1 | ||
shader0 = shaders/gb-palette/gb-palette.glsl //colorize image | ||
|
||
scale_type0 = source | ||
filter_linear0 = false | ||
|
||
textures = COLOR_PALETTE | ||
COLOR_PALETTE = shaders/gb-palette/resources/palette-dmg.png | ||
COLOR_PALETTE_linear = false |
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,9 @@ | ||
shaders = 1 | ||
shader0 = shaders/gb-palette/gb-palette.glsl //colorize image | ||
|
||
scale_type0 = source | ||
filter_linear0 = false | ||
|
||
textures = COLOR_PALETTE | ||
COLOR_PALETTE = shaders/gb-palette/resources/palette-light.png | ||
COLOR_PALETTE_linear = false |
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,9 @@ | ||
shaders = 1 | ||
shader0 = shaders/gb-palette/gb-palette.glsl //colorize image | ||
|
||
scale_type0 = source | ||
filter_linear0 = false | ||
|
||
textures = COLOR_PALETTE | ||
COLOR_PALETTE = shaders/gb-palette/resources/palette-pocket.png | ||
COLOR_PALETTE_linear = false |
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,98 @@ | ||
#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 - 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 |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.