mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-10 16:01:50 -04:00
use different lightmaps
This commit is contained in:
parent
4933fd8756
commit
797a293c27
11
doc/Sky.md
11
doc/Sky.md
@ -41,5 +41,14 @@ Resources:
|
|||||||
- [x] sky texture
|
- [x] sky texture
|
||||||
- [ ] stars
|
- [ ] stars
|
||||||
- [ ] Wither
|
- [ ] Wither
|
||||||
- [ ] Clouds
|
- [x] Clouds
|
||||||
|
- [ ] interpolate world time
|
||||||
- [ ] Lightmap
|
- [ ] 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
|
||||||
|
@ -247,9 +247,10 @@ class RenderWindow(
|
|||||||
renderSystem.framebuffer = null
|
renderSystem.framebuffer = null
|
||||||
renderSystem.clear(IntegratedBufferTypes.COLOR_BUFFER, IntegratedBufferTypes.DEPTH_BUFFER)
|
renderSystem.clear(IntegratedBufferTypes.COLOR_BUFFER, IntegratedBufferTypes.DEPTH_BUFFER)
|
||||||
|
|
||||||
|
light.updateAsync() // ToDo: do async
|
||||||
light.update()
|
light.update()
|
||||||
|
|
||||||
|
|
||||||
val currentTickTime = millis()
|
val currentTickTime = millis()
|
||||||
if (currentTickTime - this.lastTickTimer > ProtocolDefinition.TICK_TIME) {
|
if (currentTickTime - this.lastTickTimer > ProtocolDefinition.TICK_TIME) {
|
||||||
tickCount++
|
tickCount++
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
|
|
||||||
package de.bixilon.minosoft.gui.rendering.system.base.texture
|
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.RenderSystem
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.buffer.uniform.IntUniformBuffer
|
import de.bixilon.minosoft.gui.rendering.system.base.buffer.uniform.IntUniformBuffer
|
||||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.Shader
|
import de.bixilon.minosoft.gui.rendering.system.base.shader.Shader
|
||||||
@ -38,7 +38,7 @@ class SpriteAnimator(val renderSystem: RenderSystem) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun recalculate() {
|
private fun recalculate() {
|
||||||
val currentTime = TimeUtil.millis
|
val currentTime = millis()
|
||||||
val deltaLastDraw = currentTime - lastRun
|
val deltaLastDraw = currentTime - lastRun
|
||||||
lastRun = currentTime
|
lastRun = currentTime
|
||||||
|
|
||||||
@ -66,9 +66,6 @@ class SpriteAnimator(val renderSystem: RenderSystem) {
|
|||||||
uniformBuffer.data[arrayOffset + 1] = nextFrame.texture.renderData.shaderTextureId
|
uniformBuffer.data[arrayOffset + 1] = nextFrame.texture.renderData.shaderTextureId
|
||||||
uniformBuffer.data[arrayOffset + 2] = interpolation.toInt()
|
uniformBuffer.data[arrayOffset + 2] = interpolation.toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uniformBuffer.upload()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
fun draw() {
|
fun draw() {
|
||||||
@ -76,6 +73,7 @@ class SpriteAnimator(val renderSystem: RenderSystem) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
recalculate()
|
recalculate()
|
||||||
|
uniformBuffer.upload()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -14,36 +14,57 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.world.light
|
package de.bixilon.minosoft.gui.rendering.world.light
|
||||||
|
|
||||||
import de.bixilon.minosoft.config.StaticConfiguration
|
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.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.LegacyLightmapUpdater
|
||||||
import de.bixilon.minosoft.gui.rendering.world.light.updater.LightmapUpdater
|
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 val buffer = LightmapBuffer(light.renderWindow.renderSystem)
|
||||||
private var updater: LightmapUpdater = LegacyLightmapUpdater(light.renderWindow.connection)
|
private var updater: LightmapUpdater = FullbrightLightUpdater
|
||||||
set(value) {
|
set(value) {
|
||||||
field = value
|
field = value
|
||||||
force = true
|
force = true
|
||||||
}
|
}
|
||||||
private var force: Boolean = true
|
private var force: Boolean = true
|
||||||
|
|
||||||
|
private val defaultUpdater: LightmapUpdater = LegacyLightmapUpdater(light.renderWindow.connection)
|
||||||
|
|
||||||
fun init() {
|
fun init() {
|
||||||
buffer.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") {
|
fun use(shader: Shader, bufferName: String = "uLightMapBuffer") {
|
||||||
buffer.use(shader, bufferName)
|
buffer.use(shader, bufferName)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun update() {
|
fun updateAsync() {
|
||||||
if (StaticConfiguration.LIGHT_DEBUG_MODE) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
updater.update(force, buffer)
|
updater.update(force, buffer)
|
||||||
if (force) {
|
if (force) {
|
||||||
force = false
|
force = false
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun update() {
|
||||||
buffer.upload()
|
buffer.upload()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,10 @@ class RenderLight(val renderWindow: RenderWindow) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun updateAsync() {
|
||||||
|
map.updateAsync()
|
||||||
|
}
|
||||||
|
|
||||||
fun update() {
|
fun update() {
|
||||||
map.update()
|
map.update()
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user