const-ifying shaders

This commit is contained in:
minjaesong
2023-08-03 18:37:23 +09:00
parent f7e4987785
commit c73461a407
17 changed files with 49 additions and 49 deletions

View File

@@ -7,7 +7,7 @@ in vec4 v_color;
in vec2 v_texCoords;
uniform sampler2D u_texture;
int bayer[36] = int[](
const int bayer[36] = int[](
192,78,21,120,163,14,
234,142,184,248,56,106,
64,7,92,35,149,206,
@@ -15,10 +15,10 @@ int bayer[36] = int[](
241,49,113,0,135,177,
42,156,213,71,227,99
);
float bayerSize = 6.0;
float bayerDivider = 256;
const float bayerSize = 6.0;
const float bayerDivider = 256;
vec2 boolean = vec2(0.0, 1.0);
const vec2 boolean = vec2(0.0, 1.0);
out vec4 fragColor;
void main() {

View File

@@ -4,7 +4,7 @@ in vec4 v_color;
in vec2 v_texCoords;
uniform sampler2D u_texture;
vec2 boolean = vec2(0.0, 1.0);
const vec2 boolean = vec2(0.0, 1.0);
out vec4 fragColor;
void main(void) {

View File

@@ -11,7 +11,7 @@ uniform sampler2D u_texture; // world texture, has alpha value that is meaningfu
uniform sampler2D tex1; // glow texture, SHOULD contain alpha of all 1.0
out vec4 fragColor;
vec2 boolean = vec2(0.0, 1.0);
const vec2 boolean = vec2(0.0, 1.0);
void main(void) {
vec4 colorTex0 = texture(u_texture, v_texCoords); // lightmap (RGB) pre-mixed

View File

@@ -11,7 +11,7 @@ uniform sampler2D u_texture; // world texture, has alpha value that is meaningfu
uniform sampler2D tex1; // glow texture, SHOULD contain alpha of all 1.0
out vec4 fragColor;
vec2 boolean = vec2(0.0, 1.0);
const vec2 boolean = vec2(0.0, 1.0);
uniform vec2 drawOffset; // value of the 'gradY'
uniform vec2 drawOffsetSize; // value of the 'gradH'

View File

@@ -12,10 +12,10 @@ uniform sampler2D u_texture;
// that, or simply 0.5, depending on how your uv coord works
uniform vec2 halfpixel = vec2(0.0, 0.0);
vec2 doublex = vec2(2.0, 0.0);
vec2 doubley = vec2(0.0, 2.0);
vec2 twister = vec2(1.0, -1.0);
vec2 boolean = vec2(1.0, 0.0);
const vec2 doublex = vec2(2.0, 0.0);
const vec2 doubley = vec2(0.0, 2.0);
const vec2 twister = vec2(1.0, -1.0);
const vec2 boolean = vec2(1.0, 0.0);
out vec4 fragColor;

View File

@@ -11,10 +11,10 @@ uniform sampler2D u_texture;
// that, or simply 0.5, depending on how your uv coord works
uniform vec2 halfpixel = vec2(0.0, 0.0);
vec2 doublex = vec2(2.0, 0.0);
vec2 doubley = vec2(0.0, 2.0);
vec2 twister = vec2(1.0, -1.0);
vec2 boolean = vec2(1.0, 0.0);
const vec2 doublex = vec2(2.0, 0.0);
const vec2 doubley = vec2(0.0, 2.0);
const vec2 twister = vec2(1.0, -1.0);
const vec2 boolean = vec2(1.0, 0.0);
out vec4 fragColor;

View File

@@ -7,7 +7,7 @@ in vec4 v_color;
in vec2 v_texCoords;
uniform sampler2D u_texture;
vec2 boolean = vec2(0.0, 1.0);
const vec2 boolean = vec2(0.0, 1.0);
out vec4 fragColor;
void main() {

View File

@@ -21,14 +21,14 @@ uniform float zoomInv = 1.0;
out vec4 fragColor;
float quant = 255.0; // 64 steps -> 63.0; 256 steps -> 255.0
vec4 quantiser = vec4(quant);
vec4 quantiserDivider = vec4(1.0 / quant);
const float quant = 255.0; // 64 steps -> 63.0; 256 steps -> 255.0
const vec4 quantiser = vec4(quant);
const vec4 quantiserDivider = vec4(1.0 / quant);
vec2 boolean = vec2(0.0, 1.0);
vec4 halfvec = vec4(0.5);
const vec2 boolean = vec2(0.0, 1.0);
const vec4 halfvec = vec4(0.5);
vec2 patternsize = vec2(1.0/512.0, 1.0/512.0);
const vec2 patternsize = vec2(1.0/512.0, 1.0/512.0);
vec4 nearestColour(vec4 inColor) {
return floor(quantiser * inColor + halfvec) * quantiserDivider;

View File

@@ -3,8 +3,8 @@ in vec4 v_color;
in vec2 v_texCoords;
uniform sampler2D u_texture;
vec2 boolean = vec2(0.0, 1.0);
vec4 desaturate = vec4(0.2126, 0.7152, 0.0722, 0.0);
const vec2 boolean = vec2(0.0, 1.0);
const vec4 desaturate = vec4(0.2126, 0.7152, 0.0722, 0.0);
out vec4 fragColor;
void main(void) {

View File

@@ -17,13 +17,13 @@ uniform float acount = 1.0;
out vec4 fragColor;
//int bayer[14 * 14] = int[](131,187,8,78,50,18,134,89,155,102,29,95,184,73,22,86,113,171,142,105,34,166,9,60,151,128,40,110,168,137,45,28,64,188,82,54,124,189,80,13,156,56,7,61,186,121,154,6,108,177,24,100,38,176,93,123,83,148,96,17,88,133,44,145,69,161,139,72,30,181,115,27,163,47,178,65,164,14,120,48,5,127,153,52,190,58,126,81,116,21,106,77,173,92,191,63,99,12,76,144,4,185,37,149,192,39,135,23,117,31,170,132,35,172,103,66,129,79,3,97,57,159,70,141,53,94,114,20,49,158,19,146,169,122,183,11,104,180,2,165,152,87,182,118,91,42,67,25,84,147,43,85,125,68,16,136,71,10,193,112,160,138,51,111,162,26,194,46,174,107,41,143,33,74,1,101,195,15,75,140,109,90,32,62,157,98,167,119,179,59,36,130,175,55,0,150);
//float bayerSize = 14.0;
int bayer[4 * 4] = int[](0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5);
float bayerSize = 4.0;
//const int bayer[14 * 14] = int[](131,187,8,78,50,18,134,89,155,102,29,95,184,73,22,86,113,171,142,105,34,166,9,60,151,128,40,110,168,137,45,28,64,188,82,54,124,189,80,13,156,56,7,61,186,121,154,6,108,177,24,100,38,176,93,123,83,148,96,17,88,133,44,145,69,161,139,72,30,181,115,27,163,47,178,65,164,14,120,48,5,127,153,52,190,58,126,81,116,21,106,77,173,92,191,63,99,12,76,144,4,185,37,149,192,39,135,23,117,31,170,132,35,172,103,66,129,79,3,97,57,159,70,141,53,94,114,20,49,158,19,146,169,122,183,11,104,180,2,165,152,87,182,118,91,42,67,25,84,147,43,85,125,68,16,136,71,10,193,112,160,138,51,111,162,26,194,46,174,107,41,143,33,74,1,101,195,15,75,140,109,90,32,62,157,98,167,119,179,59,36,130,175,55,0,150);
//const float bayerSize = 14.0;
const int bayer[4 * 4] = int[](0,8,2,10,12,4,14,6,3,11,1,9,15,7,13,5);
const float bayerSize = 4.0;
float bayerDivider = bayerSize * bayerSize;
const float bayerDivider = bayerSize * bayerSize;
vec4 gammaIn(vec4 col) {

View File

@@ -13,7 +13,7 @@ uniform sampler2D u_texture;
uniform vec2 halfpixel = vec2(0.0, 0.0);
out vec4 fragColor;
vec2 twister = vec2(1.0, -1.0);
const vec2 twister = vec2(1.0, -1.0);
void main() {
vec4 sum = texture(u_texture, v_texCoords) * 4.0;

View File

@@ -13,9 +13,9 @@ uniform sampler2D u_texture;
uniform vec2 halfpixel = vec2(0.0, 0.0);
out vec4 fragColor;
vec2 doublex = vec2(2.0, 0.0);
vec2 doubley = vec2(0.0, 2.0);
vec2 twister = vec2(1.0, -1.0);
const vec2 doublex = vec2(2.0, 0.0);
const vec2 doubley = vec2(0.0, 2.0);
const vec2 twister = vec2(1.0, -1.0);
void main() {
vec4 sum = texture(u_texture, v_texCoords - halfpixel * doublex);

View File

@@ -23,7 +23,7 @@ in vec2 v_texCoords;
uniform sampler2D u_texture;
uniform sampler2D u_pattern;
uniform ivec2 rnd = ivec2(0,0);
uniform mat4 swizzler = mat4(
const mat4 swizzler = mat4(
1.0,0.0,0.0,0.0,
0.0,1.0,0.0,0.0,
0.0,0.0,1.0,0.0,
@@ -33,19 +33,19 @@ uniform float quant = 255.0; // 64 steps -> 63.0; 256 steps -> 255.0
out vec4 fragColor;
vec2 boolean = vec2(0.0, 1.0);
vec4 matrixNormaliser = vec4(0.5 / 256.0);
const vec2 boolean = vec2(0.0, 1.0);
const vec4 matrixNormaliser = vec4(0.5 / 256.0);
vec2 patternsize = vec2(1.0/512.0, 1.0/512.0);
const vec2 patternsize = vec2(1.0/512.0, 1.0/512.0);
mat4 rgb_to_ycocg = mat4(
const mat4 rgb_to_ycocg = mat4(
0.25, 1.0, -0.5, 0.0,
0.5, 0.0, 1.0, 0.0,
0.25, -1.0, -0.5, 0.0,
0.0, 0.0, 0.0, 1.0
);
mat4 ycocg_to_rgb = mat4(
const mat4 ycocg_to_rgb = mat4(
1.0, 1.0, 1.0, 0.0,
0.5, 0.0, -0.5, 0.0,
-0.5, 0.5, -0.5, 0.0,

View File

@@ -26,16 +26,16 @@ uniform ivec2 rnd = ivec2(0,0);
uniform float quant = 255.0; // 64 steps -> 63.0; 256 steps -> 255.0
vec2 boolean = vec2(0.0, 1.0);
const vec2 boolean = vec2(0.0, 1.0);
mat4 rgb_to_ycocg = mat4(
const mat4 rgb_to_ycocg = mat4(
0.25, 1.0, -0.5, 0.0,
0.5, 0.0, 1.0, 0.0,
0.25, -1.0, -0.5, 0.0,
0.0, 0.0, 0.0, 1.0
);
mat4 ycocg_to_rgb = mat4(
const mat4 ycocg_to_rgb = mat4(
1.0, 1.0, 1.0, 0.0,
0.5, 0.0, -0.5, 0.0,
-0.5, 0.5, -0.5, 0.0,

View File

@@ -3,7 +3,7 @@ in vec4 v_color;
in vec2 v_texCoords;
uniform sampler2D u_texture;
vec2 boolean = vec2(0.0, 1.0);
const vec2 boolean = vec2(0.0, 1.0);
out vec4 fragColor;

View File

@@ -42,14 +42,14 @@ const vec2 bc = vec2(1.0, 0.0); //binary constant
out vec4 fragColor;
// man the traditional bayer crosshatch pattern looks really good on tiles...
int bayer[16] = int[](
const int bayer[16] = int[](
0,8,2,10,
12,4,14,6,
3,11,1,9,
15,7,13,5
);
float bayerSize = 4.0;
float bayerDivider = 16;
const float bayerSize = 4.0;
const float bayerDivider = 16;
ivec2 getTileXY(int tileNumber) {
return ivec2(tileNumber % int(tilesInAtlas.x), tileNumber / int(tilesInAtlas.x));

View File

@@ -10,21 +10,21 @@ uniform sampler2D u_texture;
out vec4 fragColor;
mat4 rgb_to_ycocg = mat4(
const mat4 rgb_to_ycocg = mat4(
0.25, 1.0, -0.5, 0.0,
0.5, 0.0, 1.0, 0.0,
0.25, -1.0, -0.5, 0.0,
0.0, 0.0, 0.0, 1.0
);
mat4 ycocg_to_rgb = mat4(
const mat4 ycocg_to_rgb = mat4(
1.0, 1.0, 1.0, 0.0,
0.5, 0.0, -0.5, 0.0,
-0.5, 0.5, -0.5, 0.0,
0.0, 0.0, 0.0, 1.0
);
vec2 boolean = vec2(0.0, 1.0);
const vec2 boolean = vec2(0.0, 1.0);
void main() {
vec4 incolour = texture(u_texture, v_texCoords);