more shader shenanigans

This commit is contained in:
minjaesong
2023-02-28 17:32:52 +09:00
parent 315b984d3b
commit 2c86c6a461
31 changed files with 97 additions and 92 deletions

View File

@@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
cd "${0%/*}" cd "${0%/*}"
./runtime-linux-arm/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar ./runtime-linux-arm/bin/java -Xms1G -Xmx6G -Dswing.aatext=true -Dawt.useSystemAAFontSettings=lcd -jar ./assets/TerrarumBuild.jar

View File

@@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
cd "${0%/*}" cd "${0%/*}"
./runtime-linux-x86/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar ./runtime-linux-x86/bin/java -Xms1G -Xmx6G -Dswing.aatext=true -Dawt.useSystemAAFontSettings=lcd -jar ./assets/TerrarumBuild.jar

View File

@@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
cd "${0%/*}" cd "${0%/*}"
./runtime-arm-x86/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar ./runtime-arm-x86/bin/java -XstartOnFirstThread -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar

View File

@@ -1,3 +1,3 @@
#!/bin/bash #!/bin/bash
cd "${0%/*}" cd "${0%/*}"
./runtime-osx-x86/bin/java -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar ./runtime-osx-x86/bin/java -XstartOnFirstThread -Xms1G -Xmx6G -jar ./assets/TerrarumBuild.jar

View File

@@ -36,36 +36,41 @@ class UIHandler(//var UI: UICanvas,
companion object { companion object {
private val SHADER_PROG_FRAG = """ private val SHADER_PROG_FRAG = """
#version 130 #version 150
#ifdef GL_ES #ifdef GL_ES
precision mediump float; precision mediump float;
#endif #endif
varying vec4 v_color; in vec4 v_color;
varying vec2 v_texCoords; in vec2 v_texCoords;
uniform sampler2D u_texture; uniform sampler2D u_texture;
uniform float opacity; uniform float opacity;
out vec4 fragColor;
void main(void) { void main(void) {
vec4 color = texture2D(u_texture, v_texCoords).rgba; vec4 color = texture(u_texture, v_texCoords).rgba;
gl_FragColor = v_color * vec4(color.rgb, color.a * opacity); fragColor = v_color * vec4(color.rgb, color.a * opacity);
} }
""".trimIndent() """.trimIndent()
private val SHADER_PROG_VERT = """ private val SHADER_PROG_VERT = """
attribute vec4 a_position; #version 150
attribute vec4 a_color;
attribute vec2 a_texCoord0; in vec4 a_position;
in vec4 a_color;
in vec2 a_texCoord0;
uniform mat4 u_projTrans; uniform mat4 u_projTrans;
varying vec4 v_color; out vec4 v_color;
varying vec2 v_texCoords; out vec2 v_texCoords;
void main() { void main() {
v_color = a_color; v_color = a_color;
v_color.a = v_color.a * (255.0/254.0);
v_texCoords = a_texCoord0; v_texCoords = a_texCoord0;
gl_Position = u_projTrans * a_position; gl_Position = u_projTrans * a_position;
} }

View File

@@ -12,8 +12,8 @@ uniform vec2 tex1Offset;
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
vec4 colorTex0 = texture2D(u_texture, v_texCoords); // world texture vec4 colorTex0 = texture(u_texture, v_texCoords); // world texture
vec4 colorTex1 = texture2D(tex1, v_texCoords); // lightmap (RGBA) vec4 colorTex1 = texture(tex1, v_texCoords); // lightmap (RGBA)
colorTex1 = vec4(colorTex1.www, 1.0); colorTex1 = vec4(colorTex1.www, 1.0);

View File

@@ -22,7 +22,7 @@ vec2 boolean = vec2(0.0, 1.0);
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
vec4 inColor = v_color * (texture2D(u_texture, v_texCoords)); vec4 inColor = v_color * (texture(u_texture, v_texCoords));
vec2 entry = mod(gl_FragCoord.xy, vec2(bayerSize, bayerSize)); vec2 entry = mod(gl_FragCoord.xy, vec2(bayerSize, bayerSize));
float bayerThreshold = float(bayer[int(entry.y) * int(bayerSize) + int(entry.x)]) / bayerDivider; float bayerThreshold = float(bayer[int(entry.y) * int(bayerSize) + int(entry.x)]) / bayerDivider;

View File

@@ -8,5 +8,5 @@ vec2 boolean = vec2(0.0, 1.0);
out vec4 fragColor; out vec4 fragColor;
void main(void) { void main(void) {
fragColor = texture2D(u_texture, v_texCoords).aaaa * boolean.yyyx + boolean.xxxy; fragColor = texture(u_texture, v_texCoords).aaaa * boolean.yyyx + boolean.xxxy;
} }

View File

@@ -12,8 +12,8 @@ uniform sampler2D tex1; // glow texture, SHOULD contain alpha of all 1.0
out vec4 fragColor; out vec4 fragColor;
void main(void) { void main(void) {
vec4 colorTex0 = texture2D(u_texture, v_texCoords); // lightmap (RGB) pre-mixed vec4 colorTex0 = texture(u_texture, v_texCoords); // lightmap (RGB) pre-mixed
vec4 colorTex1 = texture2D(tex1, v_texCoords); // lightmap (A) pre-mixed vec4 colorTex1 = texture(tex1, v_texCoords); // lightmap (A) pre-mixed
fragColor = vec4(max(colorTex0.rgb, colorTex1.rgb), colorTex0.a); fragColor = vec4(max(colorTex0.rgb, colorTex1.rgb), colorTex0.a);
} }

View File

@@ -18,11 +18,11 @@ vec4 blur(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
vec4 color = vec4(0.0); vec4 color = vec4(0.0);
vec2 off1 = vec2(1.3846153846) * direction; vec2 off1 = vec2(1.3846153846) * direction;
vec2 off2 = vec2(3.2307692308) * direction; vec2 off2 = vec2(3.2307692308) * direction;
color += texture2D(image, uv) * 0.2270270270; color += texture(image, uv) * 0.2270270270;
color += texture2D(image, uv + (off1 / resolution)) * 0.3162162162; color += texture(image, uv + (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv - (off1 / resolution)) * 0.3162162162; color += texture(image, uv - (off1 / resolution)) * 0.3162162162;
color += texture2D(image, uv + (off2 / resolution)) * 0.0702702703; color += texture(image, uv + (off2 / resolution)) * 0.0702702703;
color += texture2D(image, uv - (off2 / resolution)) * 0.0702702703; color += texture(image, uv - (off2 / resolution)) * 0.0702702703;
return color; return color;
} }

View File

@@ -19,13 +19,13 @@ vec4 blur(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
vec2 off1 = vec2(1.411764705882353) * direction; vec2 off1 = vec2(1.411764705882353) * direction;
vec2 off2 = vec2(3.2941176470588234) * direction; vec2 off2 = vec2(3.2941176470588234) * direction;
vec2 off3 = vec2(5.176470588235294) * direction; vec2 off3 = vec2(5.176470588235294) * direction;
color += texture2D(image, uv) * 0.1964825501511404; color += texture(image, uv) * 0.1964825501511404;
color += texture2D(image, uv + (off1 / resolution)) * 0.2969069646728344; color += texture(image, uv + (off1 / resolution)) * 0.2969069646728344;
color += texture2D(image, uv - (off1 / resolution)) * 0.2969069646728344; color += texture(image, uv - (off1 / resolution)) * 0.2969069646728344;
color += texture2D(image, uv + (off2 / resolution)) * 0.09447039785044732; color += texture(image, uv + (off2 / resolution)) * 0.09447039785044732;
color += texture2D(image, uv - (off2 / resolution)) * 0.09447039785044732; color += texture(image, uv - (off2 / resolution)) * 0.09447039785044732;
color += texture2D(image, uv + (off3 / resolution)) * 0.010381362401148057; color += texture(image, uv + (off3 / resolution)) * 0.010381362401148057;
color += texture2D(image, uv - (off3 / resolution)) * 0.010381362401148057; color += texture(image, uv - (off3 / resolution)) * 0.010381362401148057;
return color; return color;
} }

View File

@@ -18,15 +18,15 @@ vec2 twister = vec2(1.0, -1.0);
vec2 boolean = vec2(1.0, 0.0); vec2 boolean = vec2(1.0, 0.0);
void main() { void main() {
vec4 sum = texture2D(u_texture, v_texCoords) + vec4 sum = texture(u_texture, v_texCoords) +
texture2D(u_texture, v_texCoords + halfpixel) + texture(u_texture, v_texCoords + halfpixel) +
texture2D(u_texture, v_texCoords - halfpixel) + texture(u_texture, v_texCoords - halfpixel) +
texture2D(u_texture, v_texCoords + halfpixel * twister) + texture(u_texture, v_texCoords + halfpixel * twister) +
texture2D(u_texture, v_texCoords - halfpixel * twister) + texture(u_texture, v_texCoords - halfpixel * twister) +
texture2D(u_texture, v_texCoords + halfpixel * boolean.xy) + texture(u_texture, v_texCoords + halfpixel * boolean.xy) +
texture2D(u_texture, v_texCoords - halfpixel * boolean.xy) + texture(u_texture, v_texCoords - halfpixel * boolean.xy) +
texture2D(u_texture, v_texCoords + halfpixel * boolean.yx) + texture(u_texture, v_texCoords + halfpixel * boolean.yx) +
texture2D(u_texture, v_texCoords - halfpixel * boolean.yx) ; texture(u_texture, v_texCoords - halfpixel * boolean.yx) ;
gl_FragColor = sum / 9.0; gl_FragColor = sum / 9.0;
} }

View File

@@ -19,15 +19,15 @@ vec2 boolean = vec2(1.0, 0.0);
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
vec4 sum = texture2D(u_texture, v_texCoords) + vec4 sum = texture(u_texture, v_texCoords) +
texture2D(u_texture, v_texCoords + halfpixel) + texture(u_texture, v_texCoords + halfpixel) +
texture2D(u_texture, v_texCoords - halfpixel) + texture(u_texture, v_texCoords - halfpixel) +
texture2D(u_texture, v_texCoords + halfpixel * twister) + texture(u_texture, v_texCoords + halfpixel * twister) +
texture2D(u_texture, v_texCoords - halfpixel * twister) + texture(u_texture, v_texCoords - halfpixel * twister) +
texture2D(u_texture, v_texCoords + halfpixel * boolean.xy) + texture(u_texture, v_texCoords + halfpixel * boolean.xy) +
texture2D(u_texture, v_texCoords - halfpixel * boolean.xy) + texture(u_texture, v_texCoords - halfpixel * boolean.xy) +
texture2D(u_texture, v_texCoords + halfpixel * boolean.yx) + texture(u_texture, v_texCoords + halfpixel * boolean.yx) +
texture2D(u_texture, v_texCoords - halfpixel * boolean.yx) ; texture(u_texture, v_texCoords - halfpixel * boolean.yx) ;
fragColor = sum / 9.0; fragColor = sum / 9.0;
} }

View File

@@ -20,9 +20,9 @@ uniform float blur_blend = 0.5;
out vec4 fragColor; out vec4 fragColor;
void main(void) { void main(void) {
vec4 color = texture2D(u_texture, v_texCoords).rgba; vec4 color = texture(u_texture, v_texCoords).rgba;
vec4 color_pre = texture2D(u_texture, (v_texCoords + (vec2(-1.0, 0.0) / resolution))).rgba; vec4 color_pre = texture(u_texture, (v_texCoords + (vec2(-1.0, 0.0) / resolution))).rgba;
vec4 color_next = texture2D(u_texture, (v_texCoords + (vec2( 1.0, 0.0) / resolution))).rgba; vec4 color_next = texture(u_texture, (v_texCoords + (vec2( 1.0, 0.0) / resolution))).rgba;
color = color * (1.0 - blur_blend) + color_pre * (blur_blend / 2.0) + color_next * (blur_blend / 2.0); color = color * (1.0 - blur_blend) + color_pre * (blur_blend / 2.0) + color_next * (blur_blend / 2.0);
@@ -42,5 +42,5 @@ void main(void) {
} }
fragColor = vec4(out_color, 1); fragColor = vec4(out_color, 1);
//fragColor = texture2D(u_texture, v_texCoords); //fragColor = texture(u_texture, v_texCoords);
} }

View File

@@ -11,7 +11,7 @@ vec2 boolean = vec2(0.0, 1.0);
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
vec4 inColor = v_color * (texture2D(u_texture, v_texCoords)); vec4 inColor = v_color * (texture(u_texture, v_texCoords));
vec4 divided = inColor / pow(inColor.aaaa, vec4(2.0)); vec4 divided = inColor / pow(inColor.aaaa, vec4(2.0));
fragColor = divided * boolean.yyyx + inColor * boolean.xxxy; fragColor = divided * boolean.yyyx + inColor * boolean.xxxy;

View File

@@ -10,7 +10,7 @@ uniform sampler2D u_texture;
out vec4 fragColor; out vec4 fragColor;
void main(void) { void main(void) {
vec4 inColor = texture2D(u_texture, v_texCoords); vec4 inColor = texture(u_texture, v_texCoords);
ivec4 bytes = ivec4(255.0 * inColor); ivec4 bytes = ivec4(255.0 * inColor);
ivec4 mask = ivec4(0x55); ivec4 mask = ivec4(0x55);
fragColor = (bytes ^ mask) / 255.0; fragColor = (bytes ^ mask) / 255.0;

View File

@@ -35,7 +35,7 @@ vec4 nearestColour(vec4 inColor) {
} }
vec4 getDitherredDot(vec4 inColor) { vec4 getDitherredDot(vec4 inColor) {
vec4 bayerThreshold = vec4(texture2D(u_pattern, gl_FragCoord.xy * patternsize) - 0.5); vec4 bayerThreshold = vec4(texture(u_pattern, gl_FragCoord.xy * patternsize) - 0.5);
return nearestColour(inColor + bayerThreshold * quantiserDivider); return nearestColour(inColor + bayerThreshold * quantiserDivider);
} }

View File

@@ -8,7 +8,7 @@ vec4 desaturate = vec4(0.2126, 0.7152, 0.0722, 0.0);
out vec4 fragColor; out vec4 fragColor;
void main(void) { void main(void) {
vec4 incolour = texture2D(u_texture, v_texCoords); vec4 incolour = texture(u_texture, v_texCoords);
float lum = dot(incolour * desaturate, boolean.yyyx) * 0.5 + 0.5; float lum = dot(incolour * desaturate, boolean.yyyx) * 0.5 + 0.5;
fragColor = v_color * (vec4(lum) * boolean.yyyx + incolour * boolean.xxxy); fragColor = v_color * (vec4(lum) * boolean.yyyx + incolour * boolean.xxxy);

View File

@@ -53,7 +53,7 @@ void main(void) {
// create texture coordinates based on pixelSize // // create texture coordinates based on pixelSize //
vec4 inColor = (texture2D(u_texture, v_texCoords)); vec4 inColor = (texture(u_texture, v_texCoords));
vec2 entry = mod(gl_FragCoord.xy, vec2(bayerSize, bayerSize)); vec2 entry = mod(gl_FragCoord.xy, vec2(bayerSize, bayerSize));

View File

@@ -16,12 +16,12 @@ out vec4 fragColor;
vec2 twister = vec2(1.0, -1.0); vec2 twister = vec2(1.0, -1.0);
void main() { void main() {
vec4 sum = texture2D(u_texture, v_texCoords) * 4.0; vec4 sum = texture(u_texture, v_texCoords) * 4.0;
sum += texture2D(u_texture, v_texCoords - halfpixel); sum += texture(u_texture, v_texCoords - halfpixel);
sum += texture2D(u_texture, v_texCoords + halfpixel); sum += texture(u_texture, v_texCoords + halfpixel);
sum += texture2D(u_texture, v_texCoords - halfpixel * twister); sum += texture(u_texture, v_texCoords - halfpixel * twister);
sum += texture2D(u_texture, v_texCoords + halfpixel * twister); sum += texture(u_texture, v_texCoords + halfpixel * twister);
fragColor = sum / 8.0; fragColor = sum / 8.0;
// gl_FragColor = texture2D(u_texture, v_texCoords); // gl_FragColor = texture(u_texture, v_texCoords);
} }

View File

@@ -18,15 +18,15 @@ vec2 doubley = vec2(0.0, 2.0);
vec2 twister = vec2(1.0, -1.0); vec2 twister = vec2(1.0, -1.0);
void main() { void main() {
vec4 sum = texture2D(u_texture, v_texCoords - halfpixel * doublex); vec4 sum = texture(u_texture, v_texCoords - halfpixel * doublex);
sum += texture2D(u_texture, v_texCoords - halfpixel * twister) * 2.0; sum += texture(u_texture, v_texCoords - halfpixel * twister) * 2.0;
sum += texture2D(u_texture, v_texCoords + halfpixel * doubley); sum += texture(u_texture, v_texCoords + halfpixel * doubley);
sum += texture2D(u_texture, v_texCoords + halfpixel) * 2.0; sum += texture(u_texture, v_texCoords + halfpixel) * 2.0;
sum += texture2D(u_texture, v_texCoords + halfpixel * doublex); sum += texture(u_texture, v_texCoords + halfpixel * doublex);
sum += texture2D(u_texture, v_texCoords + halfpixel * twister) * 2.0; sum += texture(u_texture, v_texCoords + halfpixel * twister) * 2.0;
sum += texture2D(u_texture, v_texCoords - halfpixel * doubley); sum += texture(u_texture, v_texCoords - halfpixel * doubley);
sum += texture2D(u_texture, v_texCoords - halfpixel) * 2.0; sum += texture(u_texture, v_texCoords - halfpixel) * 2.0;
fragColor = sum / 12.0; fragColor = sum / 12.0;
// fragColor = texture2D(u_texture, v_texCoords); // fragColor = texture(u_texture, v_texCoords);
} }

View File

@@ -12,5 +12,5 @@ uniform sampler2D u_texture;
out vec4 fragColor; out vec4 fragColor;
void main(void) { void main(void) {
fragColor = vec4(texture2D(u_texture, v_texCoords).rgb, 1.0); fragColor = vec4(texture(u_texture, v_texCoords).rgb, 1.0);
} }

View File

@@ -58,7 +58,7 @@ vec4 nearestColour(vec4 inColor) {
} }
vec4 getDitherredDot(vec4 inColor) { vec4 getDitherredDot(vec4 inColor) {
vec4 bayerThreshold = swizzler * vec4(matrixNormaliser + texture2D(u_pattern, (gl_FragCoord.xy + rnd) * patternsize)); vec4 bayerThreshold = swizzler * vec4(matrixNormaliser + texture(u_pattern, (gl_FragCoord.xy + rnd) * patternsize));
return nearestColour(bayerThreshold * vec4(1.0 / quant) + inColor); return nearestColour(bayerThreshold * vec4(1.0 / quant) + inColor);
} }
@@ -67,7 +67,7 @@ uniform vec4 vibrancy = vec4(1.0);//vec4(1.0, 1.4, 1.2, 1.0);
void main(void) { void main(void) {
// convert input RGB into YCoCg // convert input RGB into YCoCg
vec4 incolour = texture2D(u_texture, v_texCoords); vec4 incolour = texture(u_texture, v_texCoords);
vec4 yog = rgb_to_ycocg * incolour; // vec4(Y, Co, Cg, A) where Y,A=[0,1]; Co,Cg=[-1,1] vec4 yog = rgb_to_ycocg * incolour; // vec4(Y, Co, Cg, A) where Y,A=[0,1]; Co,Cg=[-1,1]
// Do colour-grading magic // Do colour-grading magic

View File

@@ -49,7 +49,7 @@ out vec4 fragColor;
void main(void) { void main(void) {
// convert input RGB into YCoCg // convert input RGB into YCoCg
vec4 incolour = texture2D(u_texture, v_texCoords); vec4 incolour = texture(u_texture, v_texCoords);
vec4 yog = rgb_to_ycocg * incolour; // vec4(Y, Co, Cg, A) where Y,A=[0,1]; Co,Cg=[-1,1] vec4 yog = rgb_to_ycocg * incolour; // vec4(Y, Co, Cg, A) where Y,A=[0,1]; Co,Cg=[-1,1]
// Do colour-grading magic // Do colour-grading magic

View File

@@ -12,7 +12,7 @@ uniform mat4 u_projTrans;
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
vec3 color = texture2D(u_texture, v_texCoords).rgb; vec3 color = texture(u_texture, v_texCoords).rgb;
float gray = (3.0 * color.r + 4.0 * color.g + color.b) / 8.0; float gray = (3.0 * color.r + 4.0 * color.g + color.b) / 8.0;
vec3 grayscale = vec3(gray); vec3 grayscale = vec3(gray);

View File

@@ -6,7 +6,7 @@ uniform sampler2D u_texture;
out vec4 fragColor; out vec4 fragColor;
void main(void) { void main(void) {
vec4 color = texture2D(u_texture, vec2(v_texCoords.x, 1.0 - v_texCoords.y)); vec4 color = texture(u_texture, vec2(v_texCoords.x, 1.0 - v_texCoords.y));
vec4 alphamul = vec4(1.0, 1.0, 1.0, 0.5 * (1.0 - v_texCoords.y)); vec4 alphamul = vec4(1.0, 1.0, 1.0, 0.5 * (1.0 - v_texCoords.y));
fragColor = color * alphamul; fragColor = color * alphamul;
} }

View File

@@ -8,5 +8,5 @@ vec2 boolean = vec2(0.0, 1.0);
out vec4 fragColor; out vec4 fragColor;
void main(void) { void main(void) {
fragColor = texture2D(u_texture, v_texCoords).rgba * boolean.yyyx + boolean.xxxy; fragColor = texture(u_texture, v_texCoords).rgba * boolean.yyyx + boolean.xxxy;
} }

View File

@@ -15,8 +15,8 @@ uniform vec2 tex1Resolution;
out vec4 fragColor; out vec4 fragColor;
void main() { void main() {
vec4 colorTex0 = texture2D(u_texture, v_texCoords + vec2(0.5, 0.5)); // world texture vec4 colorTex0 = texture(u_texture, v_texCoords + vec2(0.5, 0.5)); // world texture
vec4 colorTex1 = texture2D(tex1, v_texCoords); // lightmap (RGBA) vec4 colorTex1 = texture(tex1, v_texCoords); // lightmap (RGBA)
colorTex1 = vec4(colorTex1.xyz, 1.0); colorTex1 = vec4(colorTex1.xyz, 1.0);

View File

@@ -80,7 +80,7 @@ void main() {
// get required tile numbers // // get required tile numbers //
vec4 tileFromMap = texture2D(tilemap, flippedFragCoord / overscannedScreenDimension); // raw tile number vec4 tileFromMap = texture(tilemap, flippedFragCoord / overscannedScreenDimension); // raw tile number
int tile = getTileFromColor(tileFromMap); int tile = getTileFromColor(tileFromMap);
int breakage = getBreakageFromColor(tileFromMap); int breakage = getBreakageFromColor(tileFromMap);
ivec2 tileXY = getTileXY(tile); ivec2 tileXY = getTileXY(tile);
@@ -100,12 +100,12 @@ void main() {
// blending a breakage tex with main tex // // blending a breakage tex with main tex //
vec4 tileCol = texture2D(tilesAtlas, finalUVCoordForTile); vec4 tileCol = texture(tilesAtlas, finalUVCoordForTile);
vec4 tileAltCol = texture2D(tilesBlendAtlas, finalUVCoordForTile); vec4 tileAltCol = texture(tilesBlendAtlas, finalUVCoordForTile);
vec4 finalTile = mix(tileCol, tileAltCol, tilesBlend); vec4 finalTile = mix(tileCol, tileAltCol, tilesBlend);
vec4 finalBreakage = drawBreakage * texture2D(tilesAtlas, finalUVCoordForBreakage); // drawBreakeage = 0 to not draw, = 1 to draw vec4 finalBreakage = drawBreakage * texture(tilesAtlas, finalUVCoordForBreakage); // drawBreakeage = 0 to not draw, = 1 to draw
vec4 finalColor =mix(finalTile, finalBreakage, finalBreakage.a) * bc.xxxy + (finalTile * bc.yyyx); vec4 finalColor =mix(finalTile, finalBreakage, finalBreakage.a) * bc.xxxy + (finalTile * bc.yyyx);

View File

@@ -87,7 +87,7 @@ void main() {
// get required tile numbers // // get required tile numbers //
vec4 tileFromMap = texture2D(tilemap, flippedFragCoord / overscannedScreenDimension); // raw tile number vec4 tileFromMap = texture(tilemap, flippedFragCoord / overscannedScreenDimension); // raw tile number
int tile = getTileFromColor(tileFromMap); int tile = getTileFromColor(tileFromMap);
int breakage = getBreakageFromColor(tileFromMap); int breakage = getBreakageFromColor(tileFromMap);
ivec2 tileXY = getTileXY(tile); ivec2 tileXY = getTileXY(tile);
@@ -107,12 +107,12 @@ void main() {
// blending a breakage tex with main tex // // blending a breakage tex with main tex //
vec4 tileCol = texture2D(tilesAtlas, finalUVCoordForTile); vec4 tileCol = texture(tilesAtlas, finalUVCoordForTile);
vec4 tileAltCol = texture2D(tilesBlendAtlas, finalUVCoordForTile); vec4 tileAltCol = texture(tilesBlendAtlas, finalUVCoordForTile);
vec4 finalTile = mix(tileCol, tileAltCol, tilesBlend); vec4 finalTile = mix(tileCol, tileAltCol, tilesBlend);
vec4 finalBreakage = drawBreakage * texture2D(tilesAtlas, finalUVCoordForBreakage); // drawBreakeage = 0 to not draw, = 1 to draw vec4 finalBreakage = drawBreakage * texture(tilesAtlas, finalUVCoordForBreakage); // drawBreakeage = 0 to not draw, = 1 to draw
vec4 finalColor =mix(finalTile, finalBreakage, finalBreakage.a) * bc.xxxy + (finalTile * bc.yyyx); vec4 finalColor =mix(finalTile, finalBreakage, finalBreakage.a) * bc.xxxy + (finalTile * bc.yyyx);

View File

@@ -27,7 +27,7 @@ mat4 ycocg_to_rgb = mat4(
vec2 boolean = vec2(0.0, 1.0); vec2 boolean = vec2(0.0, 1.0);
void main() { void main() {
vec4 incolour = texture2D(u_texture, v_texCoords); vec4 incolour = texture(u_texture, v_texCoords);
vec4 yog = rgb_to_ycocg * incolour; // vec4(Y, Co, Cg, A) where Y,A=[0,1]; Co,Cg=[-1,1] vec4 yog = rgb_to_ycocg * incolour; // vec4(Y, Co, Cg, A) where Y,A=[0,1]; Co,Cg=[-1,1]
vec4 scalar = vec4(1.0, 2.0, 2.0, 1.0); vec4 scalar = vec4(1.0, 2.0, 2.0, 1.0);