mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
split light renderer and lightmap
This commit is contained in:
parent
63dec03882
commit
617f21cfbd
@ -43,7 +43,7 @@ import de.bixilon.minosoft.gui.rendering.system.base.RenderSystem
|
||||
import de.bixilon.minosoft.gui.rendering.system.window.BaseWindow
|
||||
import de.bixilon.minosoft.gui.rendering.tint.TintManager
|
||||
import de.bixilon.minosoft.gui.rendering.util.ScreenshotTaker
|
||||
import de.bixilon.minosoft.gui.rendering.world.LightMap
|
||||
import de.bixilon.minosoft.gui.rendering.world.light.RenderLight
|
||||
import de.bixilon.minosoft.modding.event.listener.CallbackEventListener.Companion.listen
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection
|
||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionStates
|
||||
@ -80,7 +80,7 @@ class RenderWindow(
|
||||
|
||||
val skeletalManager = SkeletalManager(this)
|
||||
|
||||
val lightMap = LightMap(this)
|
||||
val light = RenderLight(this)
|
||||
|
||||
var initialized = false
|
||||
private set
|
||||
@ -168,7 +168,7 @@ class RenderWindow(
|
||||
|
||||
|
||||
Log.log(LogMessageType.RENDERING_LOADING, LogLevels.VERBOSE) { "Initializing renderer (after ${stopwatch.labTime()})..." }
|
||||
lightMap.init()
|
||||
light.init()
|
||||
skeletalManager.init()
|
||||
renderer.init(initLatch)
|
||||
|
||||
@ -248,7 +248,7 @@ class RenderWindow(
|
||||
renderSystem.clear(IntegratedBufferTypes.COLOR_BUFFER, IntegratedBufferTypes.DEPTH_BUFFER)
|
||||
|
||||
|
||||
lightMap.update()
|
||||
light.update()
|
||||
|
||||
val currentTickTime = millis()
|
||||
if (currentTickTime - this.lastTickTimer > ProtocolDefinition.TICK_TIME) {
|
||||
|
@ -35,7 +35,7 @@ class SkeletalManager(
|
||||
renderWindow.textureManager.dynamicTextures.use(shader)
|
||||
shader["uSkeletalBuffer"] = uniformBuffer
|
||||
shader.setUInt(LIGHT, 0xFF)
|
||||
renderWindow.lightMap.use(shader)
|
||||
renderWindow.light.map.use(shader)
|
||||
}
|
||||
|
||||
private fun prepareDraw() {
|
||||
|
@ -103,7 +103,7 @@ interface Shader {
|
||||
renderWindow.textureManager.staticTextures.animator.use(this)
|
||||
|
||||
if (light) {
|
||||
renderWindow.lightMap.use(this)
|
||||
renderWindow.light.map.use(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -152,7 +152,7 @@ class WorldRenderer(
|
||||
if (animations) {
|
||||
renderWindow.textureManager.staticTextures.animator.use(shader)
|
||||
}
|
||||
renderWindow.lightMap.use(shader)
|
||||
renderWindow.light.map.use(shader)
|
||||
}
|
||||
|
||||
override fun postInit(latch: CountUpAndDownLatch) {
|
||||
|
@ -11,17 +11,12 @@
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.world
|
||||
package de.bixilon.minosoft.gui.rendering.world.light
|
||||
|
||||
import de.bixilon.kotlinglm.GLM
|
||||
import de.bixilon.kotlinglm.vec3.Vec3
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.minosoft.config.StaticConfiguration
|
||||
import de.bixilon.minosoft.config.key.KeyActions
|
||||
import de.bixilon.minosoft.config.key.KeyBinding
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.data.registries.effects.DefaultStatusEffects
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.system.base.shader.Shader
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.clamp
|
||||
import de.bixilon.minosoft.gui.rendering.util.VecUtil.modify
|
||||
@ -29,7 +24,6 @@ import de.bixilon.minosoft.gui.rendering.util.VecUtil.toVec3
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.ONE
|
||||
import de.bixilon.minosoft.gui.rendering.util.vec.vec3.Vec3Util.interpolateLinear
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
import org.lwjgl.system.MemoryUtil.memAllocFloat
|
||||
import kotlin.math.max
|
||||
import kotlin.math.pow
|
||||
@ -37,12 +31,12 @@ import kotlin.math.sin
|
||||
import kotlin.random.Random
|
||||
|
||||
@Deprecated("Needs refactoring")
|
||||
class LightMap(private val renderWindow: RenderWindow) {
|
||||
private val connection = renderWindow.connection
|
||||
class LightMap(private val light: RenderLight) {
|
||||
private val connection = light.renderWindow.connection
|
||||
private val profile = connection.profiles.rendering.light
|
||||
private val uniformBuffer = light.renderWindow.renderSystem.createFloatUniformBuffer(memAllocFloat(UNIFORM_BUFFER_SIZE))
|
||||
private val nightVisionStatusEffect = connection.registries.statusEffectRegistry[DefaultStatusEffects.NIGHT_VISION]
|
||||
private val conduitPowerStatusEffect = connection.registries.statusEffectRegistry[DefaultStatusEffects.CONDUIT_POWER]
|
||||
private val uniformBuffer = renderWindow.renderSystem.createFloatUniformBuffer(memAllocFloat(UNIFORM_BUFFER_SIZE))
|
||||
|
||||
|
||||
fun init() {
|
||||
@ -56,20 +50,6 @@ class LightMap(private val renderWindow: RenderWindow) {
|
||||
}
|
||||
uniformBuffer.init()
|
||||
update()
|
||||
|
||||
renderWindow.inputHandler.registerKeyCallback(
|
||||
"minosoft:recalculate_light".toResourceLocation(),
|
||||
KeyBinding(
|
||||
KeyActions.MODIFIER to setOf(KeyCodes.KEY_F4),
|
||||
KeyActions.PRESS to setOf(KeyCodes.KEY_A),
|
||||
)
|
||||
) {
|
||||
DefaultThreadPool += {
|
||||
connection.world.recalculateLight()
|
||||
renderWindow.renderer[WorldRenderer]?.silentlyClearChunkCache()
|
||||
connection.util.sendDebugMessage("Light recalculated and chunk cache cleared!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun initDebugLight() {
|
@ -0,0 +1,49 @@
|
||||
/*
|
||||
* Minosoft
|
||||
* Copyright (C) 2020-2022 Moritz Zwerger
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
|
||||
*/
|
||||
|
||||
package de.bixilon.minosoft.gui.rendering.world.light
|
||||
|
||||
import de.bixilon.kutil.concurrent.pool.DefaultThreadPool
|
||||
import de.bixilon.minosoft.config.key.KeyActions
|
||||
import de.bixilon.minosoft.config.key.KeyBinding
|
||||
import de.bixilon.minosoft.config.key.KeyCodes
|
||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||
import de.bixilon.minosoft.gui.rendering.world.WorldRenderer
|
||||
import de.bixilon.minosoft.util.KUtil.toResourceLocation
|
||||
|
||||
class RenderLight(val renderWindow: RenderWindow) {
|
||||
private val connection = renderWindow.connection
|
||||
val map = LightMap(this)
|
||||
|
||||
fun init() {
|
||||
map.init()
|
||||
|
||||
renderWindow.inputHandler.registerKeyCallback(
|
||||
"minosoft:recalculate_light".toResourceLocation(),
|
||||
KeyBinding(
|
||||
KeyActions.MODIFIER to setOf(KeyCodes.KEY_F4),
|
||||
KeyActions.PRESS to setOf(KeyCodes.KEY_A),
|
||||
)
|
||||
) {
|
||||
DefaultThreadPool += {
|
||||
connection.world.recalculateLight()
|
||||
renderWindow.renderer[WorldRenderer]?.silentlyClearChunkCache()
|
||||
connection.util.sendDebugMessage("Light recalculated and chunk cache cleared!")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun update() {
|
||||
map.update()
|
||||
}
|
||||
}
|
@ -23,7 +23,6 @@ flat in float finBrightness;
|
||||
#include "minosoft:fog"
|
||||
|
||||
void main() {
|
||||
// TODO
|
||||
foutColor = uCloudsColor;
|
||||
foutColor.rgb *= finBrightness;
|
||||
set_fog();
|
||||
|
Loading…
x
Reference in New Issue
Block a user