mirror of
https://github.com/curioustorvald/Terrarum.git
synced 2026-06-12 19:44:05 +09:00
PostProcessor working: nested FBO won't work, use FrameBufferManager
This commit is contained in:
@@ -7,6 +7,7 @@ import com.badlogic.gdx.graphics.Texture
|
||||
import com.badlogic.gdx.graphics.g2d.SpriteBatch
|
||||
import com.badlogic.gdx.graphics.g2d.TextureRegion
|
||||
import com.badlogic.gdx.graphics.glutils.FrameBuffer
|
||||
import com.badlogic.gdx.math.Matrix4
|
||||
import kotlin.system.measureNanoTime
|
||||
|
||||
/**
|
||||
@@ -15,6 +16,7 @@ import kotlin.system.measureNanoTime
|
||||
object PostProcessor {
|
||||
|
||||
private lateinit var batch: SpriteBatch // not nulling to save some lines of code
|
||||
//private lateinit var camera: OrthographicCamera
|
||||
private var textureRegion: TextureRegion? = null
|
||||
|
||||
|
||||
@@ -24,37 +26,39 @@ object PostProcessor {
|
||||
lutTex = Texture(Gdx.files.internal("assets/clut/$filename"))
|
||||
}
|
||||
|
||||
fun draw(fbo: FrameBuffer) {
|
||||
fun draw(projMat: Matrix4, fbo: FrameBuffer) {
|
||||
|
||||
if (textureRegion == null) {
|
||||
textureRegion = TextureRegion(fbo.colorBufferTexture)
|
||||
batch = SpriteBatch()
|
||||
//camera = OrthographicCamera(AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
||||
|
||||
//camera.setToOrtho(true, AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
||||
//camera.update()
|
||||
Gdx.gl20.glViewport(0, 0, AppLoader.appConfig.width, AppLoader.appConfig.height)
|
||||
}
|
||||
|
||||
|
||||
// FIXME something's really fucked between sky_gradient and the actual_world_render,
|
||||
// maybe overlaying world over grad
|
||||
// OR mixing lightmap (less likely?)
|
||||
// known symptom: when localising the spritebatch, greyscale lightmap and the UI are the
|
||||
// only thing gets drawn
|
||||
|
||||
|
||||
|
||||
|
||||
Terrarum.debugTimers["GFX.PostProcessor"] = measureNanoTime {
|
||||
|
||||
//Gdx.gl.glClearColor(.094f, .094f, .094f, 0f)
|
||||
//Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||
//Gdx.gl.glEnable(GL20.GL_TEXTURE_2D)
|
||||
//Gdx.gl.glEnable(GL20.GL_BLEND)
|
||||
//Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
Gdx.gl.glClearColor(.094f, .094f, .094f, 0f)
|
||||
Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT)
|
||||
Gdx.gl.glEnable(GL20.GL_TEXTURE_2D)
|
||||
Gdx.gl.glEnable(GL20.GL_BLEND)
|
||||
Gdx.gl.glBlendFunc(GL20.GL_SRC_ALPHA, GL20.GL_ONE_MINUS_SRC_ALPHA)
|
||||
|
||||
val shader = AppLoader.shader18Bit
|
||||
|
||||
// no-screen screen renders but the game don't? wtf?
|
||||
|
||||
fbo.colorBufferTexture.bind(0)
|
||||
|
||||
shader.begin()
|
||||
shader.setUniformf("resolution", AppLoader.appConfig.width.toFloat(), AppLoader.appConfig.height.toFloat())
|
||||
shader.setUniformMatrix("u_projTrans", projMat)
|
||||
shader.setUniformi("u_texture", 0)
|
||||
AppLoader.fullscreenQuad.render(shader, GL20.GL_TRIANGLES)
|
||||
shader.end()
|
||||
|
||||
@@ -65,4 +69,13 @@ object PostProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Camera will be moved so that (newX, newY) would be sit on the top-left edge.
|
||||
*/
|
||||
/*private fun setCameraPosition(newX: Float, newY: Float) {
|
||||
camera.position.set((-newX + Terrarum.HALFW).round(), (-newY + Terrarum.HALFH).round(), 0f)
|
||||
camera.update()
|
||||
batch.projectionMatrix = camera.combined
|
||||
}*/
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user