mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
moved essential resources out of the assets directory and into the jar
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 462 B |
Binary file not shown.
|
Before Width: | Height: | Size: 366 B |
Binary file not shown.
|
Before Width: | Height: | Size: 559 B |
Binary file not shown.
|
Before Width: | Height: | Size: 387 B |
Binary file not shown.
|
Before Width: | Height: | Size: 418 B |
@@ -1,108 +0,0 @@
|
||||
#version 120
|
||||
#ifdef GL_ES
|
||||
precision mediump float;
|
||||
#endif
|
||||
|
||||
varying vec4 v_color;
|
||||
varying vec2 v_texCoords;
|
||||
|
||||
// all 3 must have the same dimension!
|
||||
// the divisor of 2 input and an output must be the same. I.e. either divide all by 4, or not.
|
||||
uniform sampler2D shades;
|
||||
uniform sampler2D lights;
|
||||
// WARNING -- Gdx.Color.toIntBits returns ABGR, but GLSL expects RGBA. Use the function Color.toRGBA() in LightmapRenderNew
|
||||
uniform sampler2D u_texture;
|
||||
uniform vec2 outSize;
|
||||
uniform float multiplier = 4.0; // if divided by four, put 4.0 in there
|
||||
|
||||
#define TRAVERSE_SIZE 128 // should be good for screen size up to 1920 for tile size of 16
|
||||
|
||||
vec4 sampleFrom(sampler2D from, vec2 which) {
|
||||
return texture2D(from, which / outSize);
|
||||
}
|
||||
|
||||
int traceRayCount(vec2 delta) {
|
||||
vec2 absDelta = abs(delta);
|
||||
int arraySize = int(max(absDelta.x, absDelta.y));
|
||||
return arraySize + 1;
|
||||
}
|
||||
|
||||
vec2[TRAVERSE_SIZE] traceRay(int arraySize, vec2 from, vec2 to) {
|
||||
vec2 delta = to - from;
|
||||
vec2[TRAVERSE_SIZE] returnArray;
|
||||
int arri = 0;
|
||||
|
||||
// if the line is not vertical...
|
||||
if (delta.x != 0) {
|
||||
float deltaError = abs(delta.y / delta.x);
|
||||
float error = 0.0;
|
||||
float traceY = from.y;
|
||||
|
||||
for (float traceX = from.x; traceX <= to.x; traceX++) {
|
||||
// plot(traceX, traceY)
|
||||
returnArray[arri] = vec2(traceX, traceY);
|
||||
arri = arri + 1;
|
||||
|
||||
error = error + deltaError;
|
||||
if (error >= 0.5) {
|
||||
traceY = traceY + sign(delta.y);
|
||||
error = error - 1.0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (float traceY = from.y; traceY <= to.y; traceY++) {
|
||||
returnArray[arri] = vec2(from.x, traceY);
|
||||
}
|
||||
}
|
||||
|
||||
return returnArray;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
// this code will produce y-flipped image. It's your job to flip it again (e.g. using y-flipped fullscreen quad)
|
||||
|
||||
// Nice try, but it kills GPU :(
|
||||
// reason: looks like traceRayCount() returns value greater than TRAVERSE_SIZE.
|
||||
// even if I make traceRayCount() to return constant 3, I get less than 1 fps on GTX 970.
|
||||
|
||||
vec4 outColor = vec4(0.0,0.0,0.0,0.0);
|
||||
|
||||
// 1. pick a light source
|
||||
for (int y = 0; y < int(outSize.y); y++) {
|
||||
for (int x = 0; x < int(outSize.x); x++) {
|
||||
vec2 from = vec2(x + 0.5, y + 0.5); // +0.5 is used because gl_FragCoord does
|
||||
vec2 to = gl_FragCoord.xy;
|
||||
vec2 delta = to - from;
|
||||
int traceCount = traceRayCount(delta);
|
||||
vec4 light = sampleFrom(lights, from);
|
||||
|
||||
// 2. get a trace path
|
||||
vec2[TRAVERSE_SIZE] returnArray = traceRay(traceCount, from, to);
|
||||
|
||||
// 2.1 get angular darkening coefficient
|
||||
vec2 unitVec = delta / max(delta.x, delta.y);
|
||||
float angularDimming = sqrt(unitVec.x * unitVec.x + unitVec.y * unitVec.y);
|
||||
//float angularDimming = 1.0; // TODO depends on the angle of (lightPos, gl_FragCoord.x)
|
||||
|
||||
// 3. traverse the light path to dim the "light"
|
||||
// var "light" will be attenuated after this loop
|
||||
for (int i = 0; i < traceCount; i++) {
|
||||
vec4 shade = sampleFrom(shades, returnArray[i]) * angularDimming;
|
||||
|
||||
light = light - shade;
|
||||
}
|
||||
|
||||
// 4. mix the incoming light into the light buffer.
|
||||
outColor = max(outColor, light);
|
||||
}
|
||||
}
|
||||
|
||||
gl_FragColor = outColor * multiplier;
|
||||
//gl_FragColor = vec4(0,1,0,1);
|
||||
|
||||
//gl_FragColor = sampleFrom(lights, gl_FragCoord.xy) * multiplier;
|
||||
|
||||
|
||||
}
|
||||
@@ -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.
Reference in New Issue
Block a user