mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 12:21:52 +09:00
trying to optimise the rendering, this is BEFORE job
This commit is contained in:
17
assets/aaaxmul.frag
Normal file
17
assets/aaaxmul.frag
Normal file
@@ -0,0 +1,17 @@
|
||||
#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
|
||||
|
||||
void main() {
|
||||
vec4 colorTex0 = texture2D(u_texture, v_texCoords); // world texture
|
||||
vec4 colorTex1 = texture2D(tex1, v_texCoords); // lightmap (RGBA)
|
||||
|
||||
gl_FragColor = colorTex0 * vec4(colorTex1.aaa, 1.0);
|
||||
}
|
||||
17
assets/rgbxmul.frag
Normal file
17
assets/rgbxmul.frag
Normal file
@@ -0,0 +1,17 @@
|
||||
#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
|
||||
|
||||
void main() {
|
||||
vec4 colorTex0 = texture2D(u_texture, v_texCoords); // world texture
|
||||
vec4 colorTex1 = texture2D(tex1, v_texCoords); // lightmap (RGBA)
|
||||
|
||||
gl_FragColor = colorTex0 * vec4(colorTex1.rgb, 1.0);
|
||||
}
|
||||
@@ -192,11 +192,16 @@ object Terrarum : Screen {
|
||||
lateinit var shaderRGBOnly: ShaderProgram
|
||||
lateinit var shaderAtoGrey: ShaderProgram
|
||||
lateinit var shader18Bit: ShaderProgram
|
||||
lateinit var shaderMulRGBX: ShaderProgram
|
||||
lateinit var shaderMulAAAX: ShaderProgram
|
||||
|
||||
|
||||
lateinit var textureWhiteSquare: Texture
|
||||
|
||||
|
||||
lateinit var testTexture: Texture
|
||||
|
||||
|
||||
/** Actually just a mesh of four vertices, two triangles -- not a literal glQuad */
|
||||
lateinit var fullscreenQuad: Mesh; private set
|
||||
private var fullscreenQuadInit = false
|
||||
@@ -308,6 +313,9 @@ object Terrarum : Screen {
|
||||
assetManager = AssetManager()
|
||||
|
||||
|
||||
testTexture = Texture(Gdx.files.internal("./assets/test_texture.tga"))
|
||||
|
||||
|
||||
println("[Terrarum] GL_VERSION = $GL_VERSION")
|
||||
println("[Terrarum] GL_MAX_TEXTURE_SIZE = $GL_MAX_TEXTURE_SIZE")
|
||||
println("[Terrarum] GL info:\n${Gdx.graphics.glVersion.debugVersionString}") // debug info
|
||||
@@ -368,6 +376,10 @@ object Terrarum : Screen {
|
||||
shaderRGBOnly = ShaderProgram(Gdx.files.internal("assets/4096.vert"), Gdx.files.internal("assets/rgbonly.frag"))
|
||||
shaderAtoGrey = ShaderProgram(Gdx.files.internal("assets/4096.vert"), Gdx.files.internal("assets/aonly.frag"))
|
||||
|
||||
shaderMulRGBX = ShaderProgram(Gdx.files.internal("assets/4096.vert"), Gdx.files.internal("assets/rgbxmul.frag"))
|
||||
shaderMulAAAX = ShaderProgram(Gdx.files.internal("assets/4096.vert"), Gdx.files.internal("assets/aaaxmul.frag"))
|
||||
|
||||
|
||||
shader18Bit = ShaderProgram(Gdx.files.internal("assets/4096.vert"), Gdx.files.internal("assets/18BitColour.frag"))
|
||||
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ class EntryPoint : ModuleEntryPoint() {
|
||||
// load customised item loader //
|
||||
/////////////////////////////////
|
||||
|
||||
println("[ItemCodex] recording item ID ")
|
||||
println("[ModuleBaseGame.EntryPoint] recording item ID ")
|
||||
|
||||
// blocks.csvs are loaded by ModMgr beforehand
|
||||
// block items (blocks and walls are the same thing basically)
|
||||
|
||||
@@ -527,7 +527,10 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
else {
|
||||
var updateTries = 0
|
||||
while (updateDeltaCounter >= updateRate) {
|
||||
updateGame(delta)
|
||||
|
||||
//updateGame(delta)
|
||||
measureRuntime({ updateGame(delta) }, prependMsg = "Update Game: ")
|
||||
|
||||
updateDeltaCounter -= updateRate
|
||||
updateTries++
|
||||
|
||||
@@ -540,7 +543,15 @@ class Ingame(batch: SpriteBatch) : IngameInstance(batch) {
|
||||
|
||||
|
||||
/** RENDER CODE GOES HERE */
|
||||
renderGame(batch)
|
||||
//renderGame(batch)
|
||||
measureRuntime({ renderGame(batch) }, prependMsg = "Render Game: ")
|
||||
}
|
||||
|
||||
private fun measureRuntime(function: (() -> Unit), out: PrintStream = System.err, prependMsg: String = "", appendMsg: String = "") {
|
||||
val startTime = System.nanoTime()
|
||||
function.invoke()
|
||||
val endTime = System.nanoTime()
|
||||
println("$prependMsg${endTime - startTime} ns$appendMsg")
|
||||
}
|
||||
|
||||
protected fun updateGame(delta: Float) {
|
||||
|
||||
BIN
work_files/Terrarum_update_and_render_performance_test.xlsx
Normal file
BIN
work_files/Terrarum_update_and_render_performance_test.xlsx
Normal file
Binary file not shown.
Reference in New Issue
Block a user