mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-08 04:41:51 +09:00
moved essential resources out of the assets directory and into the jar
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package net.torvald.terrarum;
|
||||
|
||||
import com.badlogic.gdx.ApplicationListener;
|
||||
import com.badlogic.gdx.Files;
|
||||
import com.badlogic.gdx.Gdx;
|
||||
import com.badlogic.gdx.Screen;
|
||||
import com.badlogic.gdx.audio.AudioDevice;
|
||||
@@ -370,17 +371,17 @@ public class App implements ApplicationListener {
|
||||
//appConfig.samples = 4; // force the AA on, if the graphics driver didn't do already
|
||||
|
||||
// load app icon
|
||||
int[] appIconSizes = new int[]{256, 128, 64, 32, 16};
|
||||
ArrayList<String> appIconPaths = new ArrayList<>();
|
||||
for (int size : appIconSizes) {
|
||||
String name = "assets/appicon" + size + ".png";
|
||||
if (new File("./" + name).exists()) {
|
||||
appIconPaths.add("./" + name);
|
||||
}
|
||||
}
|
||||
|
||||
Object[] iconPathsTemp = appIconPaths.toArray();
|
||||
appConfig.setWindowIcon(Arrays.copyOf(iconPathsTemp, iconPathsTemp.length, String[].class));
|
||||
appConfig.setWindowIcon(Files.FileType.Classpath,
|
||||
"res/appicon512.png",
|
||||
"res/appicon256.png",
|
||||
"res/appicon144.png",
|
||||
"res/appicon128.png",
|
||||
"res/appicon96.png",
|
||||
"res/appicon64.png",
|
||||
"res/appicon48.png",
|
||||
"res/appicon32.png",
|
||||
"res/appicon16.png"
|
||||
);
|
||||
|
||||
// set some more configuration vars
|
||||
MULTITHREAD = THREAD_COUNT >= 3 && getConfigBoolean("multithread");
|
||||
@@ -431,20 +432,20 @@ public class App implements ApplicationListener {
|
||||
|
||||
// set GL graphics constants
|
||||
for (int i = 0; i < ditherPatterns.length; i++) {
|
||||
Texture t = new Texture(Gdx.files.internal("assets/shaders/dither_512_"+i+".tga"));
|
||||
Texture t = new Texture(Gdx.files.classpath("shaders/dither_512_"+i+".tga"));
|
||||
t.setFilter(Texture.TextureFilter.Nearest, Texture.TextureFilter.Linear);
|
||||
t.setWrap(Texture.TextureWrap.Repeat, Texture.TextureWrap.Repeat);
|
||||
ditherPatterns[i] = t;
|
||||
}
|
||||
|
||||
shaderBayerSkyboxFill = loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/4096_bayer_skyboxfill.frag");
|
||||
shaderHicolour = loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/hicolour.frag");
|
||||
shaderDebugDiff = loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/diff.frag");
|
||||
shaderBayerSkyboxFill = loadShaderFromClasspath("shaders/4096.vert", "shaders/4096_bayer_skyboxfill.frag");
|
||||
shaderHicolour = loadShaderFromClasspath("shaders/4096.vert", "shaders/hicolour.frag");
|
||||
shaderDebugDiff = loadShaderFromClasspath("shaders/4096.vert", "shaders/diff.frag");
|
||||
shaderPassthruRGBA = SpriteBatch.createDefaultShader();
|
||||
shaderDitherRGBA = loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/4096_bayer.frag"); // always load the shader regardless of config because the config may cange
|
||||
shaderColLUT = loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/passthrurgb.frag");
|
||||
shaderReflect = loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/reflect.frag");
|
||||
shaderGhastlyWhite = loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/ghastlywhite.frag");
|
||||
shaderDitherRGBA = loadShaderFromClasspath("shaders/4096.vert", "shaders/4096_bayer.frag"); // always load the shader regardless of config because the config may cange
|
||||
shaderColLUT = loadShaderFromClasspath("shaders/4096.vert", "shaders/passthrurgb.frag");
|
||||
shaderReflect = loadShaderFromClasspath("shaders/4096.vert", "shaders/reflect.frag");
|
||||
shaderGhastlyWhite = loadShaderFromClasspath("shaders/4096.vert", "shaders/ghastlywhite.frag");
|
||||
|
||||
fullscreenQuad = new Mesh(
|
||||
true, 4, 6,
|
||||
@@ -1362,6 +1363,16 @@ public class App implements ApplicationListener {
|
||||
System.out.println(csiR + "[" + out + "] " + message + csi0);
|
||||
}
|
||||
|
||||
public static ShaderProgram loadShaderFromClasspath(String vert, String frag) {
|
||||
ShaderProgram s = new ShaderProgram(Gdx.files.classpath(vert), Gdx.files.classpath(frag));
|
||||
|
||||
if (s.getLog().toLowerCase().contains("error")) {
|
||||
throw new Error(String.format("Shader program loaded with %s, %s failed:\n%s", vert, frag, s.getLog()));
|
||||
}
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
public static ShaderProgram loadShaderFromFile(String vert, String frag) {
|
||||
ShaderProgram s = new ShaderProgram(Gdx.files.internal(vert), Gdx.files.internal(frag));
|
||||
|
||||
|
||||
@@ -114,21 +114,21 @@ object IngameRenderer : Disposable {
|
||||
// these codes will run regardless of the invocation of the "initialise()" function
|
||||
// the "initialise()" function will also be called
|
||||
init {
|
||||
// shaderBlurDither = App.loadShaderFromFile("assets/shaders/blur.vert", "assets/shaders/blur_dither.frag")
|
||||
// shaderRGBOnlyDither = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/4096_bayer_rgb1.frag")
|
||||
// shaderAtoGreyDither = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/4096_bayer_aaa1.frag")
|
||||
// shaderBlurDither = App.loadShaderFromClasspath("shaders/blur.vert", "shaders/blur_dither.frag")
|
||||
// shaderRGBOnlyDither = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/4096_bayer_rgb1.frag")
|
||||
// shaderAtoGreyDither = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/4096_bayer_aaa1.frag")
|
||||
|
||||
shaderBlur = App.loadShaderFromFile("assets/shaders/blur.vert", "assets/shaders/blur.frag")
|
||||
shaderRGBOnly = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/rgbonly.frag")
|
||||
shaderAtoGrey = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/aonly.frag")
|
||||
shaderBlur = App.loadShaderFromClasspath("shaders/blur.vert", "shaders/blur.frag")
|
||||
shaderRGBOnly = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/rgbonly.frag")
|
||||
shaderAtoGrey = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/aonly.frag")
|
||||
|
||||
|
||||
shaderAlphaDither = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/alphadither.frag")
|
||||
shaderBlendGlow = App.loadShaderFromFile("assets/shaders/blendGlow.vert", "assets/shaders/blendGlow.frag")
|
||||
shaderAlphaDither = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/alphadither.frag")
|
||||
shaderBlendGlow = App.loadShaderFromClasspath("shaders/blendGlow.vert", "shaders/blendGlow.frag")
|
||||
|
||||
|
||||
shaderKawaseDown = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/kawasedown.frag")
|
||||
shaderKawaseUp = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/kawaseup.frag")
|
||||
shaderKawaseDown = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/kawasedown.frag")
|
||||
shaderKawaseUp = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/kawaseup.frag")
|
||||
|
||||
if (!shaderBlendGlow.isCompiled) {
|
||||
Gdx.app.log("shaderBlendGlow", shaderBlendGlow.log)
|
||||
|
||||
@@ -29,10 +29,10 @@ object Toolkit : Disposable {
|
||||
}
|
||||
|
||||
|
||||
private val shaderKawaseDown = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/kawasedown.frag")
|
||||
private val shaderKawaseUp = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/kawaseup.frag")
|
||||
private val shaderBoxDown = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/boxdown.frag")
|
||||
private val shaderBoxUp = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/boxup.frag")
|
||||
private val shaderKawaseDown = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/kawasedown.frag")
|
||||
private val shaderKawaseUp = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/kawaseup.frag")
|
||||
private val shaderBoxDown = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/boxdown.frag")
|
||||
private val shaderBoxUp = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/boxup.frag")
|
||||
|
||||
private lateinit var fboBlur: FloatFrameBuffer
|
||||
private lateinit var fboBlurHalf: FloatFrameBuffer
|
||||
|
||||
@@ -85,7 +85,7 @@ internal object BlocksDrawer {
|
||||
|
||||
|
||||
private lateinit var tilesQuad: Mesh
|
||||
private val shader = App.loadShaderFromFile("assets/shaders/4096.vert", "assets/shaders/tiling_dither.frag")
|
||||
private val shader = App.loadShaderFromClasspath("shaders/4096.vert", "shaders/tiling_dither.frag")
|
||||
|
||||
init {
|
||||
|
||||
|
||||
BIN
src/res/appicon128.png
LFS
Normal file
BIN
src/res/appicon128.png
LFS
Normal file
Binary file not shown.
BIN
src/res/appicon144.png
LFS
Normal file
BIN
src/res/appicon144.png
LFS
Normal file
Binary file not shown.
BIN
src/res/appicon16.png
LFS
Normal file
BIN
src/res/appicon16.png
LFS
Normal file
Binary file not shown.
BIN
src/res/appicon256.png
LFS
Normal file
BIN
src/res/appicon256.png
LFS
Normal file
Binary file not shown.
BIN
src/res/appicon32.png
LFS
Normal file
BIN
src/res/appicon32.png
LFS
Normal file
Binary file not shown.
BIN
src/res/appicon48.png
LFS
Normal file
BIN
src/res/appicon48.png
LFS
Normal file
Binary file not shown.
BIN
src/res/appicon512.png
LFS
Normal file
BIN
src/res/appicon512.png
LFS
Normal file
Binary file not shown.
BIN
src/res/appicon64.png
LFS
Normal file
BIN
src/res/appicon64.png
LFS
Normal file
Binary file not shown.
BIN
src/res/appicon96.png
LFS
Normal file
BIN
src/res/appicon96.png
LFS
Normal file
Binary file not shown.
14
src/shaders/4096.frag
Normal file
14
src/shaders/4096.frag
Normal file
@@ -0,0 +1,14 @@
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
void main(void) {
|
||||
vec4 color = texture2D(u_texture, v_texCoords).rgba;
|
||||
|
||||
color.r = floor(15.0 * color.r + 0.5) / 15.0;
|
||||
color.g = floor(15.0 * color.g + 0.5) / 15.0;
|
||||
color.b = floor(15.0 * color.b + 0.5) / 15.0;
|
||||
// a: passthrough
|
||||
|
||||
gl_FragColor = color;
|
||||
}
|
||||
14
src/shaders/4096.vert
Normal file
14
src/shaders/4096.vert
Normal file
@@ -0,0 +1,14 @@
|
||||
attribute vec4 a_position;
|
||||
attribute vec4 a_color;
|
||||
attribute vec2 a_texCoord0;
|
||||
|
||||
uniform mat4 u_projTrans;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
void main() {
|
||||
v_color = a_color;
|
||||
v_texCoords = a_texCoord0;
|
||||
gl_Position = u_projTrans * a_position;
|
||||
}
|
||||
52
src/shaders/4096_bayer.frag
Normal file
52
src/shaders/4096_bayer.frag
Normal file
@@ -0,0 +1,52 @@
|
||||
/**
|
||||
* Blue Noise texture created by Christoph Peters, released under CC0
|
||||
* http://momentsingraphics.de/BlueNoise.html
|
||||
*/
|
||||
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
vec4 gammaIn(vec4 col) {
|
||||
return pow(col, vec4(2.2));
|
||||
}
|
||||
|
||||
vec4 gammaOut(vec4 col) {
|
||||
return pow(col, vec4(1.0 / 2.2));
|
||||
}
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
uniform sampler2D u_pattern;
|
||||
uniform ivec2 rnd = ivec2(0,0);
|
||||
|
||||
float quant = 255.0; // 64 steps -> 63.0; 256 steps -> 255.0
|
||||
vec4 quantiser = vec4(quant);
|
||||
vec4 quantiserDivider = vec4(1.0 / quant);
|
||||
|
||||
vec2 boolean = vec2(0.0, 1.0);
|
||||
vec4 halfvec = vec4(0.5);
|
||||
|
||||
vec2 patternsize = vec2(1.0/512.0, 1.0/512.0);
|
||||
|
||||
vec4 nearestColour(vec4 inColor) {
|
||||
return floor(quantiser * inColor + halfvec) * quantiserDivider;
|
||||
}
|
||||
|
||||
vec4 getDitherredDot(vec4 inColor) {
|
||||
vec4 bayerThreshold = vec4(texture2D(u_pattern, (gl_FragCoord.xy + rnd) * patternsize) - 0.5);
|
||||
return nearestColour(bayerThreshold * quantiserDivider + inColor);
|
||||
}
|
||||
|
||||
|
||||
void main(void) {
|
||||
// create texture coordinates based on pixelSize //
|
||||
vec4 inColor = v_color * texture2D(u_texture, v_texCoords);
|
||||
vec4 selvec = getDitherredDot(inColor);
|
||||
|
||||
// gl_FragColor = inColor * boolean.yyyx + boolean.xxxy;
|
||||
gl_FragColor = selvec * boolean.yyyx + inColor * boolean.xxxy; // use quantised RGB but not the A
|
||||
}
|
||||
43
src/shaders/4096_bayer_aaa1.frag
Normal file
43
src/shaders/4096_bayer_aaa1.frag
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Blue Noise texture created by Christoph Peters, released under CC0
|
||||
* http://momentsingraphics.de/BlueNoise.html
|
||||
*/
|
||||
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
uniform sampler2D u_pattern;
|
||||
uniform ivec2 rnd = ivec2(0,0);
|
||||
|
||||
float quant = 127.0; // 64 steps -> 63.0; 256 steps -> 255.0
|
||||
vec4 quantiser = vec4(quant);
|
||||
vec4 quantiserDivider = vec4(1.0 / quant);
|
||||
|
||||
vec2 boolean = vec2(0.0, 1.0);
|
||||
vec4 halfvec = vec4(0.5);
|
||||
|
||||
vec2 patternsize = vec2(1.0/512.0, 1.0/512.0);
|
||||
|
||||
vec4 nearestColour(vec4 inColor) {
|
||||
return floor(quantiser * inColor + halfvec) * quantiserDivider;
|
||||
}
|
||||
|
||||
vec4 getDitherredDot(vec4 inColor) {
|
||||
vec4 bayerThreshold = vec4(texture2D(u_pattern, (gl_FragCoord.xy + rnd) * patternsize) - 0.5);
|
||||
return nearestColour(bayerThreshold * quantiserDivider + inColor);
|
||||
}
|
||||
|
||||
|
||||
void main(void) {
|
||||
// create texture coordinates based on pixelSize //
|
||||
vec4 inColor = v_color * (texture2D(u_texture, v_texCoords)).aaaa;
|
||||
vec4 selvec = getDitherredDot(inColor);
|
||||
|
||||
gl_FragColor = selvec * boolean.yyyx + boolean.xxxy; // use quantised RGB but not the A
|
||||
}
|
||||
43
src/shaders/4096_bayer_rgb1.frag
Normal file
43
src/shaders/4096_bayer_rgb1.frag
Normal file
@@ -0,0 +1,43 @@
|
||||
/**
|
||||
* Blue Noise texture created by Christoph Peters, released under CC0
|
||||
* http://momentsingraphics.de/BlueNoise.html
|
||||
*/
|
||||
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
uniform sampler2D u_pattern;
|
||||
uniform ivec2 rnd = ivec2(0,0);
|
||||
|
||||
float quant = 127.0; // 64 steps -> 63.0; 256 steps -> 255.0
|
||||
vec4 quantiser = vec4(quant);
|
||||
vec4 quantiserDivider = vec4(1.0 / quant);
|
||||
|
||||
vec2 boolean = vec2(0.0, 1.0);
|
||||
vec4 halfvec = vec4(0.5);
|
||||
|
||||
vec2 patternsize = vec2(1.0/512.0, 1.0/512.0);
|
||||
|
||||
vec4 nearestColour(vec4 inColor) {
|
||||
return floor(quantiser * inColor + halfvec) * quantiserDivider;
|
||||
}
|
||||
|
||||
vec4 getDitherredDot(vec4 inColor) {
|
||||
vec4 bayerThreshold = vec4(texture2D(u_pattern, (gl_FragCoord.xy + rnd) * patternsize) - 0.5);
|
||||
return nearestColour(bayerThreshold * quantiserDivider + inColor);
|
||||
}
|
||||
|
||||
|
||||
void main(void) {
|
||||
// create texture coordinates based on pixelSize //
|
||||
vec4 inColor = v_color * (texture2D(u_texture, v_texCoords));
|
||||
vec4 selvec = getDitherredDot(inColor);
|
||||
|
||||
gl_FragColor = selvec * boolean.yyyx + boolean.xxxy; // use quantised RGB but not the A
|
||||
}
|
||||
66
src/shaders/4096_bayer_skyboxfill.frag
Normal file
66
src/shaders/4096_bayer_skyboxfill.frag
Normal file
@@ -0,0 +1,66 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
uniform sampler2D u_pattern;
|
||||
|
||||
|
||||
uniform vec4 topColor;
|
||||
uniform vec4 bottomColor;
|
||||
uniform float parallax = 0.0; // +1.0: all top col, -1.0: all bototm col, 0.0: normal grad
|
||||
uniform float parallax_size = 1.0/3.0; // 0: no parallax
|
||||
|
||||
// inverted zoom; this value must set to (1f/zoom)
|
||||
uniform float zoomInv = 1.0;
|
||||
|
||||
|
||||
float quant = 63.0; // 64 steps -> 63.0; 256 steps -> 255.0
|
||||
vec4 quantiser = vec4(quant);
|
||||
vec4 quantiserDivider = vec4(1.0 / quant);
|
||||
|
||||
vec2 boolean = vec2(0.0, 1.0);
|
||||
vec4 halfvec = vec4(0.5);
|
||||
|
||||
vec2 patternsize = vec2(1.0/512.0, 1.0/512.0);
|
||||
|
||||
vec4 nearestColour(vec4 inColor) {
|
||||
return floor(quantiser * inColor + halfvec) * quantiserDivider;
|
||||
}
|
||||
|
||||
vec4 getDitherredDot(vec4 inColor) {
|
||||
vec4 bayerThreshold = vec4(texture2D(u_pattern, gl_FragCoord.xy * patternsize) - 0.5);
|
||||
return nearestColour(inColor + bayerThreshold * quantiserDivider);
|
||||
}
|
||||
|
||||
|
||||
void main(void) {
|
||||
float scale = v_texCoords.y * (1.0 - parallax_size) + (parallax_size / 2.0) + (parallax * parallax_size / 2.0);
|
||||
|
||||
float zoomSamplePoint = (1.0 - zoomInv) / 2.0;// will never quite exceed 0.5
|
||||
|
||||
// I don't even know if it works, and also not sure if I actually want it
|
||||
vec4 newBottom = mix(bottomColor, topColor, zoomSamplePoint);
|
||||
vec4 newTop = mix(topColor, bottomColor, zoomSamplePoint);
|
||||
|
||||
vec4 inColor = v_color * mix(newBottom, newTop, scale);
|
||||
vec4 selvec = getDitherredDot(inColor);
|
||||
|
||||
gl_FragColor = selvec;
|
||||
}
|
||||
|
||||
/*
|
||||
UV mapping coord.y
|
||||
|
||||
-+ <- 1.0 =
|
||||
D| = // parallax of +1
|
||||
i| = =
|
||||
s| = // parallax of 0
|
||||
p| = =
|
||||
.| = // parallax of -1
|
||||
-+ <- 0.0 =
|
||||
*/
|
||||
BIN
src/shaders/LDR_RGBA_21.png
LFS
Normal file
BIN
src/shaders/LDR_RGBA_21.png
LFS
Normal file
Binary file not shown.
20
src/shaders/aaaxmul.frag
Normal file
20
src/shaders/aaaxmul.frag
Normal file
@@ -0,0 +1,20 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture; // world texture, has alpha value that is meaningful
|
||||
|
||||
uniform sampler2D tex1; // lightmap texture
|
||||
uniform vec2 tex1Offset;
|
||||
|
||||
void main() {
|
||||
vec4 colorTex0 = texture2D(u_texture, v_texCoords); // world texture
|
||||
vec4 colorTex1 = texture2D(tex1, v_texCoords); // lightmap (RGBA)
|
||||
|
||||
colorTex1 = vec4(colorTex1.www, 1.0);
|
||||
|
||||
gl_FragColor = colorTex0 * colorTex1;
|
||||
}
|
||||
34
src/shaders/alphadither.frag
Normal file
34
src/shaders/alphadither.frag
Normal file
@@ -0,0 +1,34 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
int bayer[36] = int[](
|
||||
192,78,21,120,163,14,
|
||||
234,142,184,248,56,106,
|
||||
64,7,92,35,149,206,
|
||||
128,170,220,199,85,28,
|
||||
241,49,113,0,135,177,
|
||||
42,156,213,71,227,99
|
||||
);
|
||||
float bayerSize = 6.0;
|
||||
float bayerDivider = 256;
|
||||
|
||||
vec2 boolean = vec2(0.0, 1.0);
|
||||
|
||||
void main() {
|
||||
vec4 inColor = v_color * (texture2D(u_texture, v_texCoords));
|
||||
vec2 entry = mod(gl_FragCoord.xy, vec2(bayerSize, bayerSize));
|
||||
|
||||
float bayerThreshold = float(bayer[int(entry.y) * int(bayerSize) + int(entry.x)]) / bayerDivider;
|
||||
float alpha = inColor.a;
|
||||
|
||||
vec4 selvec = vec4(0.0, 0.0, 0.0, (alpha > bayerThreshold) ? 1.0 : 0.0);
|
||||
|
||||
gl_FragColor = inColor * boolean.yyyx + selvec;
|
||||
// gl_FragColor = inColor;
|
||||
}
|
||||
9
src/shaders/aonly.frag
Normal file
9
src/shaders/aonly.frag
Normal file
@@ -0,0 +1,9 @@
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
vec2 boolean = vec2(0.0, 1.0);
|
||||
|
||||
void main(void) {
|
||||
gl_FragColor = texture2D(u_texture, v_texCoords).aaaa * boolean.yyyx + boolean.xxxy;
|
||||
}
|
||||
18
src/shaders/blendGlow.frag
Normal file
18
src/shaders/blendGlow.frag
Normal file
@@ -0,0 +1,18 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture; // world texture, has alpha value that is meaningful
|
||||
|
||||
uniform sampler2D tex1; // glow texture, SHOULD contain alpha of all 1.0
|
||||
|
||||
void main(void) {
|
||||
vec4 colorTex0 = texture2D(u_texture, v_texCoords); // lightmap (RGB) pre-mixed
|
||||
vec4 colorTex1 = texture2D(tex1, v_texCoords); // lightmap (A) pre-mixed
|
||||
|
||||
gl_FragColor = vec4(max(colorTex0.rgb, colorTex1.rgb), colorTex0.a);
|
||||
}
|
||||
14
src/shaders/blendGlow.vert
Normal file
14
src/shaders/blendGlow.vert
Normal file
@@ -0,0 +1,14 @@
|
||||
attribute vec4 a_position;
|
||||
attribute vec4 a_color;
|
||||
attribute vec2 a_texCoord0;
|
||||
|
||||
uniform mat4 u_projTrans; // camera.combined
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
void main() {
|
||||
v_color = a_color;
|
||||
v_texCoords = a_texCoord0;
|
||||
gl_Position = u_projTrans * a_position;
|
||||
}
|
||||
35
src/shaders/blur.frag
Normal file
35
src/shaders/blur.frag
Normal file
@@ -0,0 +1,35 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
|
||||
|
||||
uniform vec2 iResolution;
|
||||
uniform float flip;
|
||||
uniform vec2 direction;
|
||||
|
||||
vec4 blur(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
|
||||
vec4 color = vec4(0.0);
|
||||
vec2 off1 = vec2(1.3846153846) * direction;
|
||||
vec2 off2 = vec2(3.2307692308) * direction;
|
||||
color += texture2D(image, uv) * 0.2270270270;
|
||||
color += texture2D(image, uv + (off1 / resolution)) * 0.3162162162;
|
||||
color += texture2D(image, uv - (off1 / resolution)) * 0.3162162162;
|
||||
color += texture2D(image, uv + (off2 / resolution)) * 0.0702702703;
|
||||
color += texture2D(image, uv - (off2 / resolution)) * 0.0702702703;
|
||||
return color;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = vec2(gl_FragCoord.xy / iResolution.xy);
|
||||
if (flip == 1.0) {
|
||||
uv.y = 1.0 - uv.y;
|
||||
}
|
||||
|
||||
gl_FragColor = blur(u_texture, uv, iResolution.xy, direction);
|
||||
}
|
||||
14
src/shaders/blur.vert
Normal file
14
src/shaders/blur.vert
Normal file
@@ -0,0 +1,14 @@
|
||||
attribute vec4 a_position;
|
||||
attribute vec4 a_color;
|
||||
attribute vec2 a_texCoord0;
|
||||
|
||||
uniform mat4 u_projTrans;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
void main() {
|
||||
v_color = a_color;
|
||||
v_texCoords = a_texCoord0;
|
||||
gl_Position = u_projTrans * a_position;
|
||||
}
|
||||
37
src/shaders/blur2.frag
Normal file
37
src/shaders/blur2.frag
Normal file
@@ -0,0 +1,37 @@
|
||||
#ifdef GL_ES
|
||||
precision highp float;
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
|
||||
uniform vec2 iResolution;
|
||||
uniform float flip;
|
||||
uniform vec2 direction;
|
||||
|
||||
vec4 blur(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
|
||||
vec4 color = vec4(0.0);
|
||||
vec2 off1 = vec2(1.411764705882353) * direction;
|
||||
vec2 off2 = vec2(3.2941176470588234) * direction;
|
||||
vec2 off3 = vec2(5.176470588235294) * direction;
|
||||
color += texture2D(image, uv) * 0.1964825501511404;
|
||||
color += texture2D(image, uv + (off1 / resolution)) * 0.2969069646728344;
|
||||
color += texture2D(image, uv - (off1 / resolution)) * 0.2969069646728344;
|
||||
color += texture2D(image, uv + (off2 / resolution)) * 0.09447039785044732;
|
||||
color += texture2D(image, uv - (off2 / resolution)) * 0.09447039785044732;
|
||||
color += texture2D(image, uv + (off3 / resolution)) * 0.010381362401148057;
|
||||
color += texture2D(image, uv - (off3 / resolution)) * 0.010381362401148057;
|
||||
return color;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = vec2(gl_FragCoord.xy / iResolution.xy);
|
||||
if (flip == 1.0) {
|
||||
uv.y = 1.0 - uv.y;
|
||||
}
|
||||
|
||||
gl_FragColor = blur(u_texture, uv, iResolution.xy, direction);
|
||||
}
|
||||
59
src/shaders/blur_dither.frag
Normal file
59
src/shaders/blur_dither.frag
Normal file
@@ -0,0 +1,59 @@
|
||||
/**
|
||||
* Blue Noise texture created by Christoph Peters, released under CC0
|
||||
* http://momentsingraphics.de/BlueNoise.html
|
||||
*/
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
uniform sampler2D u_pattern;
|
||||
uniform ivec2 rnd = ivec2(0,0);
|
||||
|
||||
float quant = 127.0; // 64 steps -> 63.0; 256 steps -> 255.0
|
||||
vec4 quantiser = vec4(quant);
|
||||
vec4 quantiserDivider = vec4(1.0 / quant);
|
||||
|
||||
vec2 boolean = vec2(0.0, 1.0);
|
||||
vec4 halfvec = vec4(0.5);
|
||||
|
||||
vec2 patternsize = vec2(1.0/512.0, 1.0/512.0);
|
||||
|
||||
vec4 nearestColour(vec4 inColor) {
|
||||
return floor(quantiser * inColor + halfvec) * quantiserDivider;
|
||||
}
|
||||
|
||||
vec4 getDitherredDot(vec4 inColor) {
|
||||
vec4 bayerThreshold = vec4(texture2D(u_pattern, (gl_FragCoord.xy + rnd) * patternsize) - 0.5);
|
||||
return nearestColour(bayerThreshold * quantiserDivider + inColor);
|
||||
}
|
||||
|
||||
|
||||
uniform vec2 iResolution;
|
||||
uniform float flip;
|
||||
uniform vec2 direction;
|
||||
|
||||
vec4 blur(sampler2D image, vec2 uv, vec2 resolution, vec2 direction) {
|
||||
vec4 color = vec4(0.0);
|
||||
vec2 off1 = vec2(1.3846153846) * direction;
|
||||
vec2 off2 = vec2(3.2307692308) * direction;
|
||||
color += texture2D(image, uv) * 0.2270270270;
|
||||
color += texture2D(image, uv + (off1 / resolution)) * 0.3162162162;
|
||||
color += texture2D(image, uv - (off1 / resolution)) * 0.3162162162;
|
||||
color += texture2D(image, uv + (off2 / resolution)) * 0.0702702703;
|
||||
color += texture2D(image, uv - (off2 / resolution)) * 0.0702702703;
|
||||
return color;
|
||||
}
|
||||
|
||||
void main() {
|
||||
vec2 uv = vec2(gl_FragCoord.xy / iResolution.xy);
|
||||
if (flip == 1.0) { uv.y = 1.0 - uv.y; }
|
||||
|
||||
vec4 inColor = blur(u_texture, uv, iResolution.xy, direction);
|
||||
vec4 selvec = getDitherredDot(inColor);
|
||||
|
||||
gl_FragColor = selvec; // quantise all four RGBA
|
||||
}
|
||||
31
src/shaders/boxdown.frag
Normal file
31
src/shaders/boxdown.frag
Normal file
@@ -0,0 +1,31 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
// recommended value: n / vec2(fbo_width, fbo_height) where n is something like {0.5, 1, 2, 4, ... }
|
||||
// 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);
|
||||
|
||||
void main() {
|
||||
vec4 sum = texture2D(u_texture, v_texCoords) +
|
||||
texture2D(u_texture, v_texCoords + halfpixel) +
|
||||
texture2D(u_texture, v_texCoords - halfpixel) +
|
||||
texture2D(u_texture, v_texCoords + halfpixel * twister) +
|
||||
texture2D(u_texture, v_texCoords - halfpixel * twister) +
|
||||
texture2D(u_texture, v_texCoords + halfpixel * boolean.xy) +
|
||||
texture2D(u_texture, v_texCoords - halfpixel * boolean.xy) +
|
||||
texture2D(u_texture, v_texCoords + halfpixel * boolean.yx) +
|
||||
texture2D(u_texture, v_texCoords - halfpixel * boolean.yx) ;
|
||||
|
||||
gl_FragColor = sum / 9.0;
|
||||
}
|
||||
31
src/shaders/boxup.frag
Normal file
31
src/shaders/boxup.frag
Normal file
@@ -0,0 +1,31 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
// recommended value: n / vec2(fbo_width, fbo_height) where n is something like {0.5, 1, 2, 4, ... }
|
||||
// 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);
|
||||
|
||||
void main() {
|
||||
vec4 sum = texture2D(u_texture, v_texCoords) +
|
||||
texture2D(u_texture, v_texCoords + halfpixel) +
|
||||
texture2D(u_texture, v_texCoords - halfpixel) +
|
||||
texture2D(u_texture, v_texCoords + halfpixel * twister) +
|
||||
texture2D(u_texture, v_texCoords - halfpixel * twister) +
|
||||
texture2D(u_texture, v_texCoords + halfpixel * boolean.xy) +
|
||||
texture2D(u_texture, v_texCoords - halfpixel * boolean.xy) +
|
||||
texture2D(u_texture, v_texCoords + halfpixel * boolean.yx) +
|
||||
texture2D(u_texture, v_texCoords - halfpixel * boolean.yx) ;
|
||||
|
||||
gl_FragColor = sum / 9.0;
|
||||
}
|
||||
45
src/shaders/crt.frag
Normal file
45
src/shaders/crt.frag
Normal file
@@ -0,0 +1,45 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
uniform vec2 resolution;
|
||||
|
||||
uniform vec3 phosphor_colour = vec3(1.3, 0.8567, 0.0);
|
||||
vec3 scanline_darkening = vec3(0.66, 0.66, 0.66);
|
||||
|
||||
// 0: every odd line will get darkened; 1: every even line will get darkened
|
||||
uniform float alternative_scanline = 0.0; // 1.0: true
|
||||
|
||||
uniform float blur_blend = 0.5;
|
||||
|
||||
void main(void) {
|
||||
vec4 color = texture2D(u_texture, v_texCoords).rgba;
|
||||
vec4 color_pre = texture2D(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;
|
||||
|
||||
color = color * (1.0 - blur_blend) + color_pre * (blur_blend / 2.0) + color_next * (blur_blend / 2.0);
|
||||
|
||||
bool is_scanline = mod(int(gl_FragCoord.y), 2) == int(alternative_scanline);
|
||||
|
||||
float color_luminosity = (
|
||||
3.0 * color.r +
|
||||
4.0 * color.g +
|
||||
1.0 * color.b
|
||||
) / 8.0;
|
||||
|
||||
// out colour
|
||||
vec3 out_color = vec3(color_luminosity) * phosphor_colour;
|
||||
|
||||
if (is_scanline) {
|
||||
out_color = out_color * scanline_darkening;
|
||||
}
|
||||
|
||||
gl_FragColor = vec4(out_color, 1);
|
||||
//gl_FragColor = texture2D(u_texture, v_texCoords);
|
||||
}
|
||||
17
src/shaders/diff.frag
Normal file
17
src/shaders/diff.frag
Normal file
@@ -0,0 +1,17 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
void main(void) {
|
||||
vec4 inColor = texture2D(u_texture, v_texCoords);
|
||||
ivec4 bytes = ivec4(255.0 * inColor);
|
||||
ivec4 mask = ivec4(0x55);
|
||||
gl_FragColor = (bytes ^ mask) / 255.0;
|
||||
}
|
||||
BIN
src/shaders/dither_512_0.tga
LFS
Normal file
BIN
src/shaders/dither_512_0.tga
LFS
Normal file
Binary file not shown.
BIN
src/shaders/dither_512_1.tga
LFS
Normal file
BIN
src/shaders/dither_512_1.tga
LFS
Normal file
Binary file not shown.
BIN
src/shaders/dither_512_2.tga
LFS
Normal file
BIN
src/shaders/dither_512_2.tga
LFS
Normal file
Binary file not shown.
BIN
src/shaders/dither_512_3.tga
LFS
Normal file
BIN
src/shaders/dither_512_3.tga
LFS
Normal file
Binary file not shown.
BIN
src/shaders/dither_512_4.tga
LFS
Normal file
BIN
src/shaders/dither_512_4.tga
LFS
Normal file
Binary file not shown.
BIN
src/shaders/dither_512_5.tga
LFS
Normal file
BIN
src/shaders/dither_512_5.tga
LFS
Normal file
Binary file not shown.
BIN
src/shaders/dither_512_6.tga
LFS
Normal file
BIN
src/shaders/dither_512_6.tga
LFS
Normal file
Binary file not shown.
BIN
src/shaders/dither_512_7.tga
LFS
Normal file
BIN
src/shaders/dither_512_7.tga
LFS
Normal file
Binary file not shown.
13
src/shaders/ghastlywhite.frag
Normal file
13
src/shaders/ghastlywhite.frag
Normal file
@@ -0,0 +1,13 @@
|
||||
varying vec4 v_color;
|
||||
varying 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);
|
||||
|
||||
void main(void) {
|
||||
vec4 incolour = texture2D(u_texture, v_texCoords);
|
||||
float lum = dot(incolour * desaturate, boolean.yyyx) * 0.5 + 0.5;
|
||||
|
||||
gl_FragColor = v_color * (vec4(lum) * boolean.yyyx + incolour * boolean.xxxy);
|
||||
}
|
||||
61
src/shaders/hicolour.frag
Normal file
61
src/shaders/hicolour.frag
Normal file
@@ -0,0 +1,61 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
|
||||
// "steps" of R, G and B. Must be integer && equal or greater than 2
|
||||
uniform float rcount = 8.0;
|
||||
uniform float gcount = 8.0;
|
||||
uniform float bcount = 8.0;
|
||||
uniform float acount = 1.0;
|
||||
|
||||
//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;
|
||||
|
||||
|
||||
float bayerDivider = bayerSize * bayerSize;
|
||||
|
||||
|
||||
vec4 gammaIn(vec4 col) {
|
||||
return pow(col, vec4(2.2));
|
||||
}
|
||||
|
||||
vec4 gammaOut(vec4 col) {
|
||||
return pow(col, vec4(1.0 / 2.2));
|
||||
}
|
||||
|
||||
vec4 nearestColour(vec4 incolor) {
|
||||
vec4 rgbaCounts = vec4(rcount, gcount, bcount, acount);
|
||||
|
||||
|
||||
vec4 color = incolor;
|
||||
|
||||
color.r = floor((rgbaCounts.r - 1.0) * color.r + 0.5) / (rgbaCounts.r - 1.0);
|
||||
color.g = floor((rgbaCounts.g - 1.0) * color.g + 0.5) / (rgbaCounts.g - 1.0);
|
||||
color.b = floor((rgbaCounts.b - 1.0) * color.b + 0.5) / (rgbaCounts.b - 1.0);
|
||||
color.a = 1.0;//floor((rgbaCounts.a - 1.0) * color.a + 0.5) / (rgbaCounts.a - 1.0);
|
||||
|
||||
return color;
|
||||
}
|
||||
|
||||
void main(void) {
|
||||
float spread = 1.0 / (0.299 * (rcount - 1.0) + 0.587 * (gcount - 1.0) + 0.114 * (bcount - 1.0)); // this spread value is optimised one -- try your own values for various effects!
|
||||
|
||||
|
||||
// create texture coordinates based on pixelSize //
|
||||
vec4 inColor = (texture2D(u_texture, v_texCoords));
|
||||
|
||||
vec2 entry = mod(gl_FragCoord.xy, vec2(bayerSize, bayerSize));
|
||||
|
||||
vec4 outColor = nearestColour(inColor + spread * (bayer[int(entry.y) * int(bayerSize) + int(entry.x)] / bayerDivider - 0.5));
|
||||
|
||||
gl_FragColor = outColor;
|
||||
}
|
||||
25
src/shaders/kawasedown.frag
Normal file
25
src/shaders/kawasedown.frag
Normal file
@@ -0,0 +1,25 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
// recommended value: n / vec2(fbo_width, fbo_height) where n is something like {0.5, 1, 2, 4, ... }
|
||||
// that, or simply 0.5, depending on how your uv coord works
|
||||
uniform vec2 halfpixel = vec2(0.0, 0.0);
|
||||
|
||||
vec2 twister = vec2(1.0, -1.0);
|
||||
|
||||
void main() {
|
||||
vec4 sum = texture2D(u_texture, v_texCoords) * 4.0;
|
||||
sum += texture2D(u_texture, v_texCoords - halfpixel);
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel);
|
||||
sum += texture2D(u_texture, v_texCoords - halfpixel * twister);
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel * twister);
|
||||
gl_FragColor = sum / 8.0;
|
||||
|
||||
// gl_FragColor = texture2D(u_texture, v_texCoords);
|
||||
}
|
||||
30
src/shaders/kawaseup.frag
Normal file
30
src/shaders/kawaseup.frag
Normal file
@@ -0,0 +1,30 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
// recommended value: n / vec2(fbo_width, fbo_height) where n is something like {0.5, 1, 2, 4, ... }
|
||||
// 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);
|
||||
|
||||
void main() {
|
||||
vec4 sum = texture2D(u_texture, v_texCoords - halfpixel * doublex);
|
||||
sum += texture2D(u_texture, v_texCoords - halfpixel * twister) * 2.0;
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel * doubley);
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel) * 2.0;
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel * doublex);
|
||||
sum += texture2D(u_texture, v_texCoords + halfpixel * twister) * 2.0;
|
||||
sum += texture2D(u_texture, v_texCoords - halfpixel * doubley);
|
||||
sum += texture2D(u_texture, v_texCoords - halfpixel) * 2.0;
|
||||
gl_FragColor = sum / 12.0;
|
||||
|
||||
// gl_FragColor = texture2D(u_texture, v_texCoords);
|
||||
}
|
||||
39
src/shaders/loadingCircle.frag
Normal file
39
src/shaders/loadingCircle.frag
Normal file
@@ -0,0 +1,39 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
uniform float rcount = 64.0;
|
||||
uniform float gcount = 64.0;
|
||||
uniform float bcount = 64.0;
|
||||
uniform float acount = 1.0;
|
||||
|
||||
uniform vec2 circleCentrePoint;
|
||||
uniform vec2 colorCentrePoint;
|
||||
uniform float circleSize;
|
||||
|
||||
void main() {
|
||||
vec2 screenCoord = gl_FragCoord.xy;
|
||||
|
||||
float distToCircleCentre =
|
||||
(screenCoord.x - circleCentrePoint.x + 0.5) * (screenCoord.x - circleCentrePoint.x + 0.5) +
|
||||
(screenCoord.y - circleCentrePoint.y + 0.5) * (screenCoord.y - circleCentrePoint.y + 0.5);
|
||||
float circleSizeSqr = circleSize * circleSize / 4;
|
||||
|
||||
|
||||
if (distToCircleCentre <= circleSizeSqr) {
|
||||
gl_FragColor = vec4(0.993, 0.993, 0.993, 1.0);
|
||||
}
|
||||
else if (distToCircleCentre <= circleSizeSqr + 200) { // dunno why it's 200; 2000 makes 10px feather
|
||||
gl_FragColor = vec4(0.993, 0.993, 0.993, 1 - (distToCircleCentre - circleSizeSqr) / 200);
|
||||
}
|
||||
else {
|
||||
gl_FragColor = vec4(0,0,0,1);
|
||||
}
|
||||
|
||||
}
|
||||
14
src/shaders/passthrurgb.frag
Normal file
14
src/shaders/passthrurgb.frag
Normal file
@@ -0,0 +1,14 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
|
||||
void main(void) {
|
||||
gl_FragColor = vec4(texture2D(u_texture, v_texCoords).rgb, 1.0);
|
||||
}
|
||||
16
src/shaders/quickgreyscale.frag
Normal file
16
src/shaders/quickgreyscale.frag
Normal file
@@ -0,0 +1,16 @@
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
uniform mat4 u_projTrans;
|
||||
|
||||
void main() {
|
||||
vec3 color = texture2D(u_texture, v_texCoords).rgb;
|
||||
float gray = (3.0 * color.r + 4.0 * color.g + color.b) / 8.0;
|
||||
vec3 grayscale = vec3(gray);
|
||||
|
||||
gl_FragColor = vec4(grayscale, 1.0);
|
||||
}
|
||||
14
src/shaders/quickgreyscale.vert
Normal file
14
src/shaders/quickgreyscale.vert
Normal file
@@ -0,0 +1,14 @@
|
||||
attribute vec4 a_position;
|
||||
attribute vec4 a_color;
|
||||
attribute vec2 a_texCoord0;
|
||||
|
||||
uniform mat4 u_projTrans;
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
void main() {
|
||||
v_color = a_color;
|
||||
v_texCoords = a_texCoord0;
|
||||
gl_Position = u_projTrans * a_position;
|
||||
}
|
||||
9
src/shaders/reflect.frag
Normal file
9
src/shaders/reflect.frag
Normal file
@@ -0,0 +1,9 @@
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
void main(void) {
|
||||
vec4 color = texture2D(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));
|
||||
gl_FragColor = color * alphamul;
|
||||
}
|
||||
9
src/shaders/rgbonly.frag
Normal file
9
src/shaders/rgbonly.frag
Normal file
@@ -0,0 +1,9 @@
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
vec2 boolean = vec2(0.0, 1.0);
|
||||
|
||||
void main(void) {
|
||||
gl_FragColor = texture2D(u_texture, v_texCoords).rgba * boolean.yyyx + boolean.xxxy;
|
||||
}
|
||||
21
src/shaders/rgbxmul.frag
Normal file
21
src/shaders/rgbxmul.frag
Normal file
@@ -0,0 +1,21 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture; // world texture, has alpha value that is meaningful
|
||||
|
||||
uniform sampler2D tex1; // lightmap texture
|
||||
uniform vec2 tex1Offset;
|
||||
uniform vec2 tex1Resolution;
|
||||
|
||||
void main() {
|
||||
vec4 colorTex0 = texture2D(u_texture, v_texCoords + vec2(0.5, 0.5)); // world texture
|
||||
vec4 colorTex1 = texture2D(tex1, v_texCoords); // lightmap (RGBA)
|
||||
|
||||
colorTex1 = vec4(colorTex1.xyz, 1.0);
|
||||
|
||||
gl_FragColor = colorTex0 * colorTex1;
|
||||
}
|
||||
38
src/shaders/skyboxfill.frag
Normal file
38
src/shaders/skyboxfill.frag
Normal file
@@ -0,0 +1,38 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
|
||||
uniform vec3 topColor;
|
||||
uniform vec3 bottomColor;
|
||||
uniform float parallax = 0.0; // +1.0: all top col, -1.0: all bototm col, 0.0: normal grad
|
||||
uniform float parallax_size = 1.0/3.0; // 0: no parallax
|
||||
|
||||
|
||||
|
||||
void main(void) {
|
||||
float scale = v_texCoords.y * (1.0 - parallax_size) + (parallax_size / 2.0) + (parallax * parallax_size / 2.0);
|
||||
|
||||
float inR = mix(bottomColor.r, topColor.r, scale);
|
||||
float inG = mix(bottomColor.g, topColor.g, scale);
|
||||
float inB = mix(bottomColor.b, topColor.b, scale);
|
||||
|
||||
gl_FragColor = vec4(inR, inG, inB, 1.0);
|
||||
}
|
||||
/*
|
||||
UV mapping coord.y
|
||||
|
||||
-+ <- 1.0 =
|
||||
D| = // parallax of +1
|
||||
i| = =
|
||||
s| = // parallax of 0
|
||||
p| = =
|
||||
.| = // parallax of -1
|
||||
-+ <- 0.0 =
|
||||
*/
|
||||
112
src/shaders/tiling.frag
Normal file
112
src/shaders/tiling.frag
Normal file
@@ -0,0 +1,112 @@
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
//layout(origin_upper_left) in vec4 gl_FragCoord; // commented; requires #version 150 or later
|
||||
// gl_FragCoord is origin to bottom-left
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
|
||||
uniform vec2 screenDimension;
|
||||
uniform vec2 tilesInAxes; // size of the tilemap texture; vec2(tiles_in_horizontal, tiles_in_vertical)
|
||||
|
||||
uniform sampler2D tilemap; // RGBA8888
|
||||
|
||||
uniform sampler2D tilesAtlas; // terrain, wire, fluids, etc.
|
||||
uniform sampler2D tilesBlendAtlas; // alternative terrain for the weather mix (e.g. yellowed grass)
|
||||
uniform float tilesBlend = 0.0; // percentage of blending [0f..1f]. 0: draws tilesAtlas, 1: draws tilesBlendAtlas
|
||||
|
||||
uniform vec2 tilesInAtlas = vec2(256.0, 256.0);
|
||||
uniform vec2 atlasTexSize = vec2(4096.0, 4096.0);
|
||||
|
||||
vec2 _tilesInAtlas = vec2(1.0, 1.0) / tilesInAtlas;
|
||||
vec2 tileSizeInPx = atlasTexSize * _tilesInAtlas; // should be like ivec2(16.0, 16.0)
|
||||
vec2 _tileSizeInPx = vec2(1.0, 1.0) / tileSizeInPx; // should be like ivec2(0.06125, 0.06125)
|
||||
|
||||
uniform vec4 colourFilter = vec4(1, 1, 1, 1); // used by WALL to darken it
|
||||
|
||||
uniform ivec2 cameraTranslation = ivec2(0, 0); // used to offset the drawing; it's integer because we want the drawing to be pixel-aligned
|
||||
|
||||
uniform float drawBreakage = 1.0; // set it to 0f to not draw breakage, 1f to draw it; NEVER set to any other values.
|
||||
|
||||
uniform float mulBlendIntensity = 1.0; // used my MUL-blending drawings; works about the same way as the Layer Opacity slider of Photoshop/Krita/etc.
|
||||
|
||||
const vec2 bc = vec2(1.0, 0.0); //binary constant
|
||||
|
||||
ivec2 getTileXY(int tileNumber) {
|
||||
return ivec2(tileNumber % int(tilesInAtlas.x), tileNumber / int(tilesInAtlas.x));
|
||||
}
|
||||
|
||||
// return: int=0xaarrggbb
|
||||
int _colToInt(vec4 color) {
|
||||
return int(color.b * 255) | (int(color.g * 255) << 8) | (int(color.r * 255) << 16) | (int(color.a * 255) << 24);
|
||||
}
|
||||
|
||||
// 0x0rggbb where int=0xaarrggbb
|
||||
// return: [0..1048575]
|
||||
int getTileFromColor(vec4 color) {
|
||||
return _colToInt(color) & 0xFFFFF;
|
||||
}
|
||||
|
||||
// 0x00r00000 where int=0xaarrggbb
|
||||
// return: [0..15]
|
||||
int getBreakageFromColor(vec4 color) {
|
||||
return (_colToInt(color) >> 20) & 0xF;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
// READ THE FUCKING MANUAL, YOU DONKEY !! //
|
||||
// This code purposedly uses flipped fragcoord. //
|
||||
// Make sure you don't use gl_FragCoord unknowingly! //
|
||||
// Remember, if there's a compile error, shader SILENTLY won't do anything //
|
||||
|
||||
|
||||
// default gl_FragCoord takes half-integer (represeting centre of the pixel) -- could be useful for phys solver?
|
||||
// This one, however, takes exact integer by rounding down. //
|
||||
vec2 overscannedScreenDimension = tilesInAxes * tileSizeInPx; // how many tiles will fit into a screen; one used by the tileFromMap; we need this because screen size is not integer multiple of the tile size
|
||||
vec2 flippedFragCoord = vec2(gl_FragCoord.x, screenDimension.y - gl_FragCoord.y) + cameraTranslation; // NO IVEC2!!; this flips Y
|
||||
|
||||
// get required tile numbers //
|
||||
|
||||
vec4 tileFromMap = texture2D(tilemap, flippedFragCoord / overscannedScreenDimension); // raw tile number
|
||||
int tile = getTileFromColor(tileFromMap);
|
||||
int breakage = getBreakageFromColor(tileFromMap);
|
||||
ivec2 tileXY = getTileXY(tile);
|
||||
ivec2 breakageXY = getTileXY(breakage + 5); // +5 is hard-coded constant that depends on the contents of the atlas
|
||||
|
||||
// calculate the UV coord value for texture sampling //
|
||||
|
||||
// don't really need highp here; read the GLES spec
|
||||
vec2 uvCoordForTile = (mod(flippedFragCoord, tileSizeInPx) * _tileSizeInPx) * _tilesInAtlas; // 0..0.00390625 regardless of tile position in atlas
|
||||
vec2 uvCoordOffsetTile = tileXY * _tilesInAtlas; // where the tile starts in the atlas, using uv coord (0..1)
|
||||
vec2 uvCoordOffsetBreakage = breakageXY * _tilesInAtlas;
|
||||
|
||||
// get final UV coord for the actual sampling //
|
||||
|
||||
vec2 finalUVCoordForTile = uvCoordForTile + uvCoordOffsetTile;// where we should be actually looking for in atlas, using UV coord (0..1)
|
||||
vec2 finalUVCoordForBreakage = uvCoordForTile + uvCoordOffsetBreakage;
|
||||
|
||||
// blending a breakage tex with main tex //
|
||||
|
||||
vec4 tileCol = texture2D(tilesAtlas, finalUVCoordForTile);
|
||||
vec4 tileAltCol = texture2D(tilesBlendAtlas, finalUVCoordForTile);
|
||||
|
||||
vec4 finalTile = mix(tileCol, tileAltCol, tilesBlend);
|
||||
|
||||
vec4 finalBreakage = drawBreakage * texture2D(tilesAtlas, finalUVCoordForBreakage); // drawBreakeage = 0 to not draw, = 1 to draw
|
||||
|
||||
vec4 finalColor =mix(finalTile, finalBreakage, finalBreakage.a) * bc.xxxy + (finalTile * bc.yyyx);
|
||||
|
||||
gl_FragColor = mix(colourFilter, colourFilter * finalColor, mulBlendIntensity);
|
||||
|
||||
}
|
||||
123
src/shaders/tiling_dither.frag
Normal file
123
src/shaders/tiling_dither.frag
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
|
||||
*/
|
||||
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
#extension GL_EXT_gpu_shader4 : enable
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
uniform sampler2D u_texture;
|
||||
|
||||
|
||||
uniform vec2 screenDimension;
|
||||
uniform vec2 tilesInAxes; // size of the tilemap texture; vec2(tiles_in_horizontal, tiles_in_vertical)
|
||||
|
||||
uniform sampler2D tilemap; // RGBA8888
|
||||
|
||||
uniform sampler2D tilesAtlas; // terrain, wire, fluids, etc.
|
||||
uniform sampler2D tilesBlendAtlas; // alternative terrain for the weather mix (e.g. yellowed grass)
|
||||
uniform float tilesBlend = 0.0; // percentage of blending [0f..1f]. 0: draws tilesAtlas, 1: draws tilesBlendAtlas
|
||||
|
||||
uniform vec2 tilesInAtlas = vec2(256.0, 256.0);
|
||||
uniform vec2 atlasTexSize = vec2(4096.0, 4096.0);
|
||||
|
||||
vec2 _tilesInAtlas = vec2(1.0, 1.0) / tilesInAtlas;
|
||||
vec2 tileSizeInPx = atlasTexSize * _tilesInAtlas; // should be like ivec2(16.0, 16.0)
|
||||
vec2 _tileSizeInPx = vec2(1.0, 1.0) / tileSizeInPx; // should be like ivec2(0.06125, 0.06125)
|
||||
|
||||
uniform vec4 colourFilter = vec4(1, 1, 1, 1); // used by WALL to darken it
|
||||
|
||||
uniform ivec2 cameraTranslation = ivec2(0, 0); // used to offset the drawing; it's integer because we want the drawing to be pixel-aligned
|
||||
|
||||
uniform float drawBreakage = 1.0; // set it to 0f to not draw breakage, 1f to draw it; NEVER set to any other values.
|
||||
|
||||
uniform float mulBlendIntensity = 1.0; // used my MUL-blending drawings; works about the same way as the Layer Opacity slider of Photoshop/Krita/etc.
|
||||
|
||||
const vec2 bc = vec2(1.0, 0.0); //binary constant
|
||||
|
||||
// man the traditional bayer crosshatch pattern looks really good on tiles...
|
||||
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;
|
||||
|
||||
ivec2 getTileXY(int tileNumber) {
|
||||
return ivec2(tileNumber % int(tilesInAtlas.x), tileNumber / int(tilesInAtlas.x));
|
||||
}
|
||||
|
||||
// return: int=0xaarrggbb
|
||||
int _colToInt(vec4 color) {
|
||||
return int(color.b * 255) | (int(color.g * 255) << 8) | (int(color.r * 255) << 16) | (int(color.a * 255) << 24);
|
||||
}
|
||||
|
||||
// 0x0rggbb where int=0xaarrggbb
|
||||
// return: [0..1048575]
|
||||
int getTileFromColor(vec4 color) {
|
||||
return _colToInt(color) & 0xFFFFF;
|
||||
}
|
||||
|
||||
// 0x00r00000 where int=0xaarrggbb
|
||||
// return: [0..15]
|
||||
int getBreakageFromColor(vec4 color) {
|
||||
return (_colToInt(color) >> 20) & 0xF;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
// READ THE FUCKING MANUAL, YOU DONKEY !! //
|
||||
// This code purposedly uses flipped fragcoord. //
|
||||
// Make sure you don't use gl_FragCoord unknowingly! //
|
||||
// Remember, if there's a compile error, shader SILENTLY won't do anything //
|
||||
|
||||
|
||||
// default gl_FragCoord takes half-integer (represeting centre of the pixel) -- could be useful for phys solver?
|
||||
// This one, however, takes exact integer by rounding down. //
|
||||
vec2 overscannedScreenDimension = tilesInAxes * tileSizeInPx; // how many tiles will fit into a screen; one used by the tileFromMap; we need this because screen size is not integer multiple of the tile size
|
||||
vec2 flippedFragCoord = vec2(gl_FragCoord.x, screenDimension.y - gl_FragCoord.y) + cameraTranslation; // NO IVEC2!!; this flips Y
|
||||
|
||||
// get required tile numbers //
|
||||
|
||||
vec4 tileFromMap = texture2D(tilemap, flippedFragCoord / overscannedScreenDimension); // raw tile number
|
||||
int tile = getTileFromColor(tileFromMap);
|
||||
int breakage = getBreakageFromColor(tileFromMap);
|
||||
ivec2 tileXY = getTileXY(tile);
|
||||
ivec2 breakageXY = getTileXY(breakage + 5); // +5 is hard-coded constant that depends on the contents of the atlas
|
||||
|
||||
// calculate the UV coord value for texture sampling //
|
||||
|
||||
// don't really need highp here; read the GLES spec
|
||||
vec2 uvCoordForTile = (mod(flippedFragCoord, tileSizeInPx) * _tileSizeInPx) * _tilesInAtlas; // 0..0.00390625 regardless of tile position in atlas
|
||||
vec2 uvCoordOffsetTile = tileXY * _tilesInAtlas; // where the tile starts in the atlas, using uv coord (0..1)
|
||||
vec2 uvCoordOffsetBreakage = breakageXY * _tilesInAtlas;
|
||||
|
||||
// get final UV coord for the actual sampling //
|
||||
|
||||
vec2 finalUVCoordForTile = uvCoordForTile + uvCoordOffsetTile;// where we should be actually looking for in atlas, using UV coord (0..1)
|
||||
vec2 finalUVCoordForBreakage = uvCoordForTile + uvCoordOffsetBreakage;
|
||||
|
||||
// blending a breakage tex with main tex //
|
||||
|
||||
vec4 tileCol = texture2D(tilesAtlas, finalUVCoordForTile);
|
||||
vec4 tileAltCol = texture2D(tilesBlendAtlas, finalUVCoordForTile);
|
||||
|
||||
vec4 finalTile = mix(tileCol, tileAltCol, tilesBlend);
|
||||
|
||||
vec4 finalBreakage = drawBreakage * texture2D(tilesAtlas, finalUVCoordForBreakage); // drawBreakeage = 0 to not draw, = 1 to draw
|
||||
|
||||
vec4 finalColor =mix(finalTile, finalBreakage, finalBreakage.a) * bc.xxxy + (finalTile * bc.yyyx);
|
||||
|
||||
vec4 undithered = mix(colourFilter, colourFilter * finalColor, mulBlendIntensity);
|
||||
|
||||
vec2 entry = mod(gl_FragCoord.xy, vec2(bayerSize, bayerSize));
|
||||
float bayerThreshold = float(bayer[int(entry.y) * int(bayerSize) + int(entry.x)]) / bayerDivider;
|
||||
|
||||
gl_FragColor = undithered * bc.xxxy + vec4((undithered.a > bayerThreshold) ? 1.0 : 0.0) * bc.yyyx;
|
||||
}
|
||||
Reference in New Issue
Block a user