diff --git a/assets/graphics/sprites/.gitattributes b/assets/graphics/sprites/.gitattributes deleted file mode 100644 index ca82ef549..000000000 --- a/assets/graphics/sprites/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -*.{psd,tga,ogg} filter=lfs diff=lfs merge=lfs -text \ No newline at end of file diff --git a/assets/graphics/sprites/test_player_glow.png b/assets/graphics/sprites/test_player_glow.png new file mode 100644 index 000000000..81fe21069 Binary files /dev/null and b/assets/graphics/sprites/test_player_glow.png differ diff --git a/src/net/torvald/terrarum/StateInGame.kt b/src/net/torvald/terrarum/StateInGame.kt index 3972d4bf6..276314658 100644 --- a/src/net/torvald/terrarum/StateInGame.kt +++ b/src/net/torvald/terrarum/StateInGame.kt @@ -72,8 +72,7 @@ constructor() : BasicGameState() { val ZOOM_MAX = 2.0f val ZOOM_MIN = 0.5f - val tilesDrawFrameBuffer = Image(Terrarum.WIDTH.div(ZOOM_MIN).ceilInt(), Terrarum.HEIGHT.div(ZOOM_MIN).ceilInt()) - val actorsDrawFrameBuffer = Image(Terrarum.WIDTH.div(ZOOM_MIN).ceilInt(), Terrarum.HEIGHT.div(ZOOM_MIN).ceilInt()) + val worldDrawFrameBuffer = Image(Terrarum.WIDTH.div(ZOOM_MIN).ceilInt(), Terrarum.HEIGHT.div(ZOOM_MIN).ceilInt()) val uisDrawFrameBuffer = Image(Terrarum.WIDTH, Terrarum.HEIGHT) //private lateinit var shader12BitCol: Shader // grab LibGDX if you want some shader @@ -274,27 +273,26 @@ constructor() : BasicGameState() { override fun render(gc: GameContainer, sbg: StateBasedGame, gwin: Graphics) { // clean the shit beforehand - tilesDrawFrameBuffer.graphics.clear() - actorsDrawFrameBuffer.graphics.clear() + worldDrawFrameBuffer.graphics.clear() uisDrawFrameBuffer.graphics.clear() blendNormal() - drawSkybox(tilesDrawFrameBuffer.graphics) + // FIXME skybox is not scaled at all + drawSkybox(worldDrawFrameBuffer.graphics) // make camara work // // compensate for zoom. UIs must be treated specially! (see UIHandler) //g.translate(-MapCamera.cameraX * screenZoom, -MapCamera.cameraY * screenZoom) - tilesDrawFrameBuffer.graphics.translate(-MapCamera.cameraX.toFloat(), -MapCamera.cameraY.toFloat()) - actorsDrawFrameBuffer.graphics.translate(-MapCamera.cameraX.toFloat(), -MapCamera.cameraY.toFloat()) + worldDrawFrameBuffer.graphics.translate(-MapCamera.cameraX.toFloat(), -MapCamera.cameraY.toFloat()) ///////////////////////////// // draw map related stuffs // ///////////////////////////// - MapCamera.renderBehind(gc, tilesDrawFrameBuffer.graphics) + MapCamera.renderBehind(gc, worldDrawFrameBuffer.graphics) ///////////////// @@ -302,10 +300,10 @@ constructor() : BasicGameState() { ///////////////// actorContainer.forEach { actor -> if (actor is ActorWithBody && actor.inScreen() && actor !is Player) { - actor.drawBody(gc, actorsDrawFrameBuffer.graphics) + actor.drawBody(gc, worldDrawFrameBuffer.graphics) } } - player.drawBody(gc, actorsDrawFrameBuffer.graphics) + player.drawBody(gc, worldDrawFrameBuffer.graphics) ///////////////////////////// @@ -313,15 +311,15 @@ constructor() : BasicGameState() { ///////////////////////////// LightmapRenderer.renderLightMap() - MapCamera.renderFront(gc, tilesDrawFrameBuffer.graphics) - MapDrawer.render(gc, tilesDrawFrameBuffer.graphics) + MapCamera.renderFront(gc, worldDrawFrameBuffer.graphics) + MapDrawer.render(gc, worldDrawFrameBuffer.graphics) blendMul() - MapDrawer.drawEnvOverlay(actorsDrawFrameBuffer.graphics) + MapDrawer.drawEnvOverlay(worldDrawFrameBuffer.graphics) if (!KeyToggler.isOn(KEY_LIGHTMAP_RENDER)) blendMul() else blendNormal() - LightmapRenderer.draw(actorsDrawFrameBuffer.graphics) + LightmapRenderer.draw(worldDrawFrameBuffer.graphics) blendNormal() @@ -330,10 +328,10 @@ constructor() : BasicGameState() { ////////////////////// actorContainer.forEach { actor -> if (actor is ActorWithBody && actor.inScreen() && actor !is Player) { - actor.drawGlow(gc, actorsDrawFrameBuffer.graphics) + actor.drawGlow(gc, worldDrawFrameBuffer.graphics) } } - player.drawGlow(gc, actorsDrawFrameBuffer.graphics) + player.drawGlow(gc, worldDrawFrameBuffer.graphics) //////////////////////// @@ -343,17 +341,17 @@ constructor() : BasicGameState() { if (debugWindow.isVisible) { actorContainer.forEachIndexed { i, actor -> if (actor is ActorWithBody) { - actorsDrawFrameBuffer.graphics.color = Color.white - actorsDrawFrameBuffer.graphics.font = Terrarum.fontSmallNumbers - actorsDrawFrameBuffer.graphics.drawString( + worldDrawFrameBuffer.graphics.color = Color.white + worldDrawFrameBuffer.graphics.font = Terrarum.fontSmallNumbers + worldDrawFrameBuffer.graphics.drawString( actor.referenceID.toString(), actor.hitbox.posX.toFloat(), actor.hitbox.pointedY.toFloat() + 4 ) if (DEBUG_ARRAY) { - actorsDrawFrameBuffer.graphics.color = GameFontBase.codeToCol["g"] - actorsDrawFrameBuffer.graphics.drawString( + worldDrawFrameBuffer.graphics.color = GameFontBase.codeToCol["g"] + worldDrawFrameBuffer.graphics.drawString( i.toString(), actor.hitbox.posX.toFloat(), actor.hitbox.pointedY.toFloat() + 4 + 10 @@ -364,7 +362,7 @@ constructor() : BasicGameState() { } // fluidmap debug if (KeyToggler.isOn(Key.F4)) - WorldSimulator.drawFluidMapDebug(actorsDrawFrameBuffer.graphics) + WorldSimulator.drawFluidMapDebug(worldDrawFrameBuffer.graphics) ////////////// @@ -379,8 +377,7 @@ constructor() : BasicGameState() { ///////////////// // draw layers // ///////////////// - gwin.drawImage(tilesDrawFrameBuffer, 0f, 0f) - gwin.drawImage(actorsDrawFrameBuffer.getScaledCopy(screenZoom), 0f, 0f) + gwin.drawImage(worldDrawFrameBuffer.getScaledCopy(screenZoom), 0f, 0f) gwin.drawImage(uisDrawFrameBuffer, 0f, 0f) } diff --git a/src/net/torvald/terrarum/Terrarum.kt b/src/net/torvald/terrarum/Terrarum.kt index 02b660661..3e726d044 100644 --- a/src/net/torvald/terrarum/Terrarum.kt +++ b/src/net/torvald/terrarum/Terrarum.kt @@ -432,9 +432,12 @@ fun main(args: Array) { Terrarum.main(args) } -// I must say: What the fuck is wrong with you, Slick2D?! +/////////////////////////////////// +// customised blending functions // +/////////////////////////////////// fun blendMul() { + // I must say: What the fuck is wrong with you, Slick2D? Your built-it blending is just fucking wrong. GL11.glEnable(GL11.GL_BLEND) GL11.glColorMask(true, true, true, true) GL11.glBlendFunc(GL11.GL_DST_COLOR, GL11.GL_ONE_MINUS_SRC_ALPHA) @@ -445,13 +448,27 @@ fun blendNormal() { GL11.glColorMask(true, true, true, true) //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA) - // TODO seems working as intended (no more whitened-out semitransparent colour), but needs further investigation + // semitransparent textures working as intended with this, + // but needs further investigation in the case of: + // TODO blend semitransparent over semitransparent GL14.glBlendFuncSeparate( GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, // blend func for RGB channels GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA // blend func for alpha channels ) } +fun blendLightenOnly() { + GL11.glEnable(GL11.GL_BLEND) + GL14.glBlendFuncSeparate( + GL11.GL_ONE, GL11.GL_ONE, // blend func for RGB channels + GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA // blend func for alpha channels + ) + GL20.glBlendEquationSeparate( + GL14.GL_MAX, + GL14.GL_FUNC_ADD + ) +} + fun blendAlphaMap() { GL11.glDisable(GL11.GL_BLEND) GL11.glColorMask(false, false, false, true) diff --git a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt index ae79a449b..a133a3243 100644 --- a/src/net/torvald/terrarum/gameactors/ActorWithBody.kt +++ b/src/net/torvald/terrarum/gameactors/ActorWithBody.kt @@ -899,7 +899,7 @@ open class ActorWithBody : Actor() { open fun drawGlow(gc: GameContainer, g: Graphics) { if (isVisible && spriteGlow != null) { - blendNormal() + blendLightenOnly() if (!sprite!!.flippedHorizontal()) { spriteGlow!!.render(g, diff --git a/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt b/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt index a0fa2cf24..de7a0d6fc 100644 --- a/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt +++ b/src/net/torvald/terrarum/gameactors/PlayerBuilderSigrid.kt @@ -32,7 +32,7 @@ object PlayerBuilderSigrid { p.sprite!!.setRowsAndFrames(1, 1) p.makeNewSpriteGlow(28, 51) - p.spriteGlow!!.setSpriteImage("assets/graphics/sprites/test_player_glow.tga") + p.spriteGlow!!.setSpriteImage("assets/graphics/sprites/test_player_glow.png") p.spriteGlow!!.setDelay(200) p.spriteGlow!!.setRowsAndFrames(1, 1)