now terrain also lives on its own framebuffer

This commit is contained in:
minjaesong
2024-11-24 13:19:20 +09:00
parent 5cc7db8ecc
commit 5bf60cfa82
2 changed files with 23 additions and 6 deletions

View File

@@ -77,7 +77,8 @@ object IngameRenderer : Disposable {
private lateinit var fboMixedOut: Float16FrameBuffer private lateinit var fboMixedOut: Float16FrameBuffer
private lateinit var fboRGBactorsBehind: Float16FrameBuffer // for small shadow eff; A channel is for glow effects so they don't get shadow effects private lateinit var fboRGBactorsBehind: Float16FrameBuffer // for small shadow eff; A channel is for glow effects so they don't get shadow effects
private lateinit var fboRGBactorsMiddle: Float16FrameBuffer // for large shadew eff; A channel is for glow effects so they don't get shadow effects private lateinit var fboRGBactorsMiddle: Float16FrameBuffer // for large shadow eff; A channel is for glow effects so they don't get shadow effects
private lateinit var fboRGBterrain: Float16FrameBuffer // for large shadow eff; A channel is for glow effects so they don't get shadow effects
private lateinit var rgbTex: TextureRegion private lateinit var rgbTex: TextureRegion
private lateinit var aTex: TextureRegion private lateinit var aTex: TextureRegion
@@ -526,6 +527,12 @@ object IngameRenderer : Disposable {
} }
} }
fboRGBterrain.inAction(camera, batch) {
clearBuffer()
setCameraPosition(0f, 0f)
BlocksDrawer.drawTerrain(batch.projectionMatrix, false)
}
fboRGB.inAction(camera, batch) { fboRGB.inAction(camera, batch) {
setCameraPosition(0f, 0f) setCameraPosition(0f, 0f)
@@ -546,10 +553,13 @@ object IngameRenderer : Disposable {
particlesContainer?.forEach { it.drawBody(frameDelta, batch) } particlesContainer?.forEach { it.drawBody(frameDelta, batch) }
} }
setCameraPosition(0f, 0f) batch.inUse {
BlocksDrawer.drawTerrain(batch.projectionMatrix, false) batch.shader = null
batch.color = Color.WHITE
setCameraPosition(0f, 0f)
batch.drawFlipped(fboRGBterrain.colorBufferTexture, 0f, 0f)
}
batch.shader = shaderForActors
batch.inUse { batch.inUse {
batch.shader = shaderForActors batch.shader = shaderForActors
batch.color = Color.WHITE batch.color = Color.WHITE
@@ -1250,6 +1260,7 @@ object IngameRenderer : Disposable {
fboMixedOut = Float16FrameBuffer(width, height, false) fboMixedOut = Float16FrameBuffer(width, height, false)
fboRGBactorsBehind = Float16FrameBuffer(width, height, false) fboRGBactorsBehind = Float16FrameBuffer(width, height, false)
fboRGBactorsMiddle = Float16FrameBuffer(width, height, false) fboRGBactorsMiddle = Float16FrameBuffer(width, height, false)
fboRGBterrain = Float16FrameBuffer(width, height, false)
lightmapFbo = Float16FrameBuffer( lightmapFbo = Float16FrameBuffer(
LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(), LightmapRenderer.lightBuffer.width * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(), LightmapRenderer.lightBuffer.height * LightmapRenderer.DRAW_TILE_SIZE.toInt(),
@@ -1314,6 +1325,7 @@ object IngameRenderer : Disposable {
if (::lightmapFbo.isInitialized) lightmapFbo.tryDispose() if (::lightmapFbo.isInitialized) lightmapFbo.tryDispose()
if (::fboRGBactorsBehind.isInitialized) fboRGBactorsBehind.tryDispose() if (::fboRGBactorsBehind.isInitialized) fboRGBactorsBehind.tryDispose()
if (::fboRGBactorsMiddle.isInitialized) fboRGBactorsMiddle.tryDispose() if (::fboRGBactorsMiddle.isInitialized) fboRGBactorsMiddle.tryDispose()
if (::fboRGBterrain.isInitialized) fboRGBterrain.tryDispose()
blurtex0.tryDispose() blurtex0.tryDispose()

View File

@@ -104,14 +104,19 @@ internal object ExportFBO : ConsoleCommand {
} }
@ExportFBOCmd("Framebuffer for render-behind actors used for creating shallow shadow effects") @ExportFBOCmd("Framebuffer for render-behind actors used for creating shallow shadow effects")
fun fboergbactorsbehind(): FrameBuffer { fun fborgbactorsbehind(): FrameBuffer {
return IngameRenderer.extortField<Float16FrameBuffer>("fboRGBactorsBehind")!! return IngameRenderer.extortField<Float16FrameBuffer>("fboRGBactorsBehind")!!
} }
@ExportFBOCmd("Framebuffer for render-middle actors used for creating large shadow effects") @ExportFBOCmd("Framebuffer for render-middle actors used for creating large shadow effects")
fun fboergbactorsmiddle(): FrameBuffer { fun fborgbactorsmiddle(): FrameBuffer {
return IngameRenderer.extortField<Float16FrameBuffer>("fboRGBactorsMiddle")!! return IngameRenderer.extortField<Float16FrameBuffer>("fboRGBactorsMiddle")!!
} }
@ExportFBOCmd("Framebuffer for terrain blocks used for creating large shadow effects")
fun fborgbterrain(): FrameBuffer {
return IngameRenderer.extortField<Float16FrameBuffer>("fboRGBterrain")!!
}
} }
internal annotation class ExportFBOCmd(val description: String) internal annotation class ExportFBOCmd(val description: String)