use different lightmaps

This commit is contained in:
Bixilon 2022-11-08 19:33:55 +01:00
parent 4933fd8756
commit 797a293c27
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
5 changed files with 46 additions and 13 deletions

View File

@ -41,5 +41,14 @@ Resources:
- [x] sky texture
- [ ] stars
- [ ] Wither
- [ ] Clouds
- [x] Clouds
- [ ] interpolate world time
- [ ] Lightmap
- potion effects (nigh vision, underwater visibility, conduit)
- submerged fluid
- gamma setting
- weather, thunder flashing
- wither
- dimension (e.g. fullbright)
- fullbright setting/key
- stars/moon

View File

@ -247,9 +247,10 @@ class RenderWindow(
renderSystem.framebuffer = null
renderSystem.clear(IntegratedBufferTypes.COLOR_BUFFER, IntegratedBufferTypes.DEPTH_BUFFER)
light.updateAsync() // ToDo: do async
light.update()
val currentTickTime = millis()
if (currentTickTime - this.lastTickTimer > ProtocolDefinition.TICK_TIME) {
tickCount++

View File

@ -13,7 +13,7 @@
package de.bixilon.minosoft.gui.rendering.system.base.texture
import de.bixilon.kutil.time.TimeUtil
import de.bixilon.kutil.time.TimeUtil.millis
import de.bixilon.minosoft.gui.rendering.system.base.RenderSystem
import de.bixilon.minosoft.gui.rendering.system.base.buffer.uniform.IntUniformBuffer
import de.bixilon.minosoft.gui.rendering.system.base.shader.Shader
@ -38,7 +38,7 @@ class SpriteAnimator(val renderSystem: RenderSystem) {
}
private fun recalculate() {
val currentTime = TimeUtil.millis
val currentTime = millis()
val deltaLastDraw = currentTime - lastRun
lastRun = currentTime
@ -66,9 +66,6 @@ class SpriteAnimator(val renderSystem: RenderSystem) {
uniformBuffer.data[arrayOffset + 1] = nextFrame.texture.renderData.shaderTextureId
uniformBuffer.data[arrayOffset + 2] = interpolation.toInt()
}
uniformBuffer.upload()
}
fun draw() {
@ -76,6 +73,7 @@ class SpriteAnimator(val renderSystem: RenderSystem) {
return
}
recalculate()
uniformBuffer.upload()
}

View File

@ -14,36 +14,57 @@
package de.bixilon.minosoft.gui.rendering.world.light
import de.bixilon.minosoft.config.StaticConfiguration
import de.bixilon.minosoft.config.profile.delegate.watcher.SimpleProfileDelegateWatcher.Companion.profileWatch
import de.bixilon.minosoft.gui.rendering.system.base.shader.Shader
import de.bixilon.minosoft.gui.rendering.world.light.updater.DebugLightUpdater
import de.bixilon.minosoft.gui.rendering.world.light.updater.FullbrightLightUpdater
import de.bixilon.minosoft.gui.rendering.world.light.updater.LegacyLightmapUpdater
import de.bixilon.minosoft.gui.rendering.world.light.updater.LightmapUpdater
class Lightmap(light: RenderLight) {
class Lightmap(private val light: RenderLight) {
private val profile = light.renderWindow.connection.profiles.rendering
private val buffer = LightmapBuffer(light.renderWindow.renderSystem)
private var updater: LightmapUpdater = LegacyLightmapUpdater(light.renderWindow.connection)
private var updater: LightmapUpdater = FullbrightLightUpdater
set(value) {
field = value
force = true
}
private var force: Boolean = true
private val defaultUpdater: LightmapUpdater = LegacyLightmapUpdater(light.renderWindow.connection)
fun init() {
buffer.init()
profile.light::fullbright.profileWatch(this, profile = profile) { setLightmapUpdater() }
setLightmapUpdater()
}
private fun setLightmapUpdater() {
this.updater = getLightmapUpdater()
}
private fun getLightmapUpdater(): LightmapUpdater {
if (StaticConfiguration.LIGHT_DEBUG_MODE) {
return DebugLightUpdater
}
if (profile.light.fullbright) {
return FullbrightLightUpdater
}
return defaultUpdater
}
fun use(shader: Shader, bufferName: String = "uLightMapBuffer") {
buffer.use(shader, bufferName)
}
fun update() {
if (StaticConfiguration.LIGHT_DEBUG_MODE) {
return
}
fun updateAsync() {
updater.update(force, buffer)
if (force) {
force = false
}
}
fun update() {
buffer.upload()
}
}

View File

@ -43,6 +43,10 @@ class RenderLight(val renderWindow: RenderWindow) {
}
}
fun updateAsync() {
map.updateAsync()
}
fun update() {
map.update()
}