mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-09 13:21:51 +09:00
nice try, but it crashes the gpu AND I get <1 fps :(
This commit is contained in:
@@ -496,7 +496,7 @@ public class AppLoader implements ApplicationListener {
|
||||
logoBatch.setProjectionMatrix(camera.combined);
|
||||
}
|
||||
|
||||
private void updateFullscreenQuad(int WIDTH, int HEIGHT) {
|
||||
private void updateFullscreenQuad(int WIDTH, int HEIGHT) { // NOT y-flipped quads!
|
||||
fullscreenQuad.setVertices(new float[]{
|
||||
0f, 0f, 0f, 1f, 1f, 1f, 1f, 0f, 1f,
|
||||
WIDTH, 0f, 0f, 1f, 1f, 1f, 1f, 1f, 1f,
|
||||
@@ -650,16 +650,19 @@ public class AppLoader implements ApplicationListener {
|
||||
* Return config from config set. If the config does not exist, default value will be returned.
|
||||
* @param key
|
||||
* *
|
||||
* @return Config from config set or default config if it does not exist.
|
||||
* *
|
||||
* @throws NullPointerException if the specified config simply does not exist.
|
||||
* @return Config from config set or default config if it does not exist. If the default value is undefined, will return false.
|
||||
*/
|
||||
public static boolean getConfigBoolean(String key) {
|
||||
Object cfg = getConfigMaster(key);
|
||||
if (cfg instanceof JsonPrimitive)
|
||||
return ((JsonPrimitive) cfg).getAsBoolean();
|
||||
else
|
||||
return ((boolean) cfg);
|
||||
try {
|
||||
Object cfg = getConfigMaster(key);
|
||||
if (cfg instanceof JsonPrimitive)
|
||||
return ((JsonPrimitive) cfg).getAsBoolean();
|
||||
else
|
||||
return ((boolean) cfg);
|
||||
}
|
||||
catch (NullPointerException keyNotFound) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static int[] getConfigIntArray(String key) {
|
||||
|
||||
@@ -24,7 +24,6 @@ object DefaultConfig {
|
||||
jsonObject.addProperty("notificationshowuptime", 6500)
|
||||
jsonObject.addProperty("multithread", true) // experimental!
|
||||
jsonObject.addProperty("multithreadedlight", false) // experimental!
|
||||
jsonObject.addProperty("gpulightcalc", true) // experimental!
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -105,10 +105,6 @@ object LightmapRenderer {
|
||||
|
||||
if (SHADER_LIGHTING) {
|
||||
lightCalcShader = AppLoader.loadShader("assets/4096.vert", "assets/raytracelight.frag")
|
||||
lightCalcShader.setUniformf("outSize", LIGHTMAP_WIDTH.toFloat(), LIGHTMAP_HEIGHT.toFloat())
|
||||
lightCalcShader.setUniformi("shades", SHADEMAP_UNIT)
|
||||
lightCalcShader.setUniformi("lights", LIGHTMAP_UNIT)
|
||||
lightCalcShader.setUniformi("u_texture", 0)
|
||||
|
||||
texturedLightMap = FrameBuffer(Pixmap.Format.RGBA8888, LIGHTMAP_WIDTH, LIGHTMAP_HEIGHT, false)
|
||||
//texturedLightMap = Texture(LIGHTMAP_WIDTH, LIGHTMAP_HEIGHT, Pixmap.Format.RGBA8888)
|
||||
@@ -133,11 +129,11 @@ object LightmapRenderer {
|
||||
VertexAttribute.ColorUnpacked(),
|
||||
VertexAttribute.TexCoords(0)
|
||||
)
|
||||
texturedLightQuad.setVertices(floatArrayOf(
|
||||
0f, 0f, 0f, 1f, 1f, 1f, 1f, 0f, 1f,
|
||||
LIGHTMAP_WIDTH.toFloat(), 0f, 0f, 1f, 1f, 1f, 1f, 1f, 1f,
|
||||
LIGHTMAP_WIDTH.toFloat(), LIGHTMAP_HEIGHT.toFloat(), 0f, 1f, 1f, 1f, 1f, 1f, 0f,
|
||||
0f, LIGHTMAP_HEIGHT.toFloat(), 0f, 1f, 1f, 1f, 1f, 0f, 0f))
|
||||
texturedLightQuad.setVertices(floatArrayOf( // y-flipped quads!
|
||||
0f, 0f, 0f, 1f, 1f, 1f, 1f, 0f, 0f,
|
||||
LIGHTMAP_WIDTH.toFloat(), 0f, 0f, 1f, 1f, 1f, 1f, 1f, 0f,
|
||||
LIGHTMAP_WIDTH.toFloat(), LIGHTMAP_HEIGHT.toFloat(), 0f, 1f, 1f, 1f, 1f, 1f, 1f,
|
||||
0f, LIGHTMAP_HEIGHT.toFloat(), 0f, 1f, 1f, 1f, 1f, 0f, 1f))
|
||||
texturedLightQuad.setIndices(shortArrayOf(0, 1, 2, 2, 3, 0))
|
||||
|
||||
texturedLightCamera = OrthographicCamera(LIGHTMAP_WIDTH.toFloat(), LIGHTMAP_HEIGHT.toFloat())
|
||||
@@ -433,7 +429,11 @@ object LightmapRenderer {
|
||||
texturedLightSources.bind(LIGHTMAP_UNIT)
|
||||
|
||||
lightCalcShader.begin()
|
||||
// it seems that every time shader ends, uniforms reset themselves.
|
||||
lightCalcShader.setUniformMatrix("u_projTrans", texturedLightCamera.combined)
|
||||
lightCalcShader.setUniformf("outSize", LIGHTMAP_WIDTH.toFloat(), LIGHTMAP_HEIGHT.toFloat())
|
||||
lightCalcShader.setUniformi("shades", SHADEMAP_UNIT)
|
||||
lightCalcShader.setUniformi("lights", LIGHTMAP_UNIT)
|
||||
texturedLightQuad.render(lightCalcShader, GL20.GL_TRIANGLES)
|
||||
lightCalcShader.end()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user