mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-03-07 20:31:51 +09:00
closing issue #39
This commit is contained in:
@@ -35,6 +35,7 @@ uniform ivec2 cameraTranslation = ivec2(0, 0); // used to offset the drawing; it
|
||||
|
||||
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.
|
||||
|
||||
ivec2 getTileXY(int tileNumber) {
|
||||
return ivec2(tileNumber % int(tilesInAtlas.x), tileNumber / int(tilesInAtlas.x));
|
||||
@@ -101,6 +102,6 @@ void main() {
|
||||
|
||||
vec4 finalColor = vec4(mix(finalTile.rgb, finalBreakage.rgb, finalBreakage.a), finalTile.a);
|
||||
|
||||
gl_FragColor = colourFilter * finalColor;
|
||||
gl_FragColor = mix(colourFilter, colourFilter * finalColor, mulBlendIntensity);
|
||||
|
||||
}
|
||||
|
||||
@@ -439,6 +439,11 @@ fun gdxSetBlendNormal() {
|
||||
// - https://www.andersriggelsen.dk/glblendfunc.php
|
||||
}
|
||||
|
||||
fun gdxSetBlendMul() {
|
||||
gdxSetBlend()
|
||||
Gdx.gl.glBlendFunc(GL20.GL_DST_COLOR, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
}
|
||||
|
||||
object BlendMode {
|
||||
const val SCREEN = "screen"
|
||||
const val MULTIPLY = "multiply"
|
||||
|
||||
@@ -202,8 +202,10 @@ internal object BlocksDrawer {
|
||||
|
||||
internal fun drawWall(projectionMatrix: Matrix4, drawGlow: Boolean) {
|
||||
gdxSetBlendNormal()
|
||||
|
||||
renderUsingBuffer(WALL, projectionMatrix, drawGlow)
|
||||
|
||||
gdxSetBlendMul()
|
||||
renderUsingBuffer(OCCLUSION, projectionMatrix, false)
|
||||
}
|
||||
|
||||
internal fun drawTerrain(projectionMatrix: Matrix4, drawGlow: Boolean) {
|
||||
@@ -215,13 +217,7 @@ internal object BlocksDrawer {
|
||||
|
||||
|
||||
internal fun drawFront(projectionMatrix: Matrix4) {
|
||||
// blend mul
|
||||
Gdx.gl.glEnable(GL20.GL_TEXTURE_2D)
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND)
|
||||
Gdx.gl.glBlendFunc(GL20.GL_DST_COLOR, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
|
||||
// draw occlusion with MUL blend
|
||||
renderUsingBuffer(OCCLUSION, projectionMatrix, false)
|
||||
gdxSetBlendMul()
|
||||
|
||||
// let's just not MUL on terrain, make it FLUID only...
|
||||
renderUsingBuffer(FLUID, projectionMatrix, false)
|
||||
@@ -593,7 +589,7 @@ internal object BlocksDrawer {
|
||||
}
|
||||
|
||||
private var _tilesBufferAsTex: Texture = Texture(1, 1, Pixmap.Format.RGBA8888)
|
||||
private val fakeOcclusionColour = Color(.65f, .65f, .65f, 1f)
|
||||
private val occlusionIntensity = 0.3f
|
||||
|
||||
private fun renderUsingBuffer(mode: Int, projectionMatrix: Matrix4, drawGlow: Boolean) {
|
||||
//Gdx.gl.glClearColor(.094f, .094f, .094f, 0f)
|
||||
@@ -619,9 +615,8 @@ internal object BlocksDrawer {
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
val vertexColour = when (mode) {
|
||||
TERRAIN, WIRE, FLUID -> Color.WHITE
|
||||
TERRAIN, WIRE, FLUID, OCCLUSION -> Color.WHITE
|
||||
WALL -> AppLoader.tileMaker.wallOverlayColour
|
||||
OCCLUSION -> Color.WHITE //fakeOcclusionColour
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
@@ -670,6 +665,7 @@ internal object BlocksDrawer {
|
||||
else
|
||||
0f
|
||||
)
|
||||
shader.setUniformf("mulBlendIntensity", if (mode == OCCLUSION) occlusionIntensity else 1f)
|
||||
//shader.setUniformf("drawBreakage", if (mode == WIRE) 0f else 1f)
|
||||
tilesQuad.render(shader, GL20.GL_TRIANGLES)
|
||||
shader.end()
|
||||
|
||||
@@ -38,7 +38,7 @@ class CreateTileAtlas {
|
||||
|
||||
private val TOTAL_TILES = TILES_IN_X * TILES_IN_X
|
||||
|
||||
val wallOverlayColour = Color(.65f, .65f, .65f, 1f)
|
||||
val wallOverlayColour = Color(.8f, .8f, .8f, 1f)
|
||||
|
||||
lateinit var atlas: Pixmap
|
||||
lateinit var atlasAutumn: Pixmap
|
||||
|
||||
Reference in New Issue
Block a user