profiles: light, experimental stuff

This commit is contained in:
Bixilon 2021-12-03 21:11:17 +01:00
parent 7fedff7d67
commit 17ee5ad834
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
15 changed files with 110 additions and 43 deletions

View File

@ -19,9 +19,7 @@ import de.bixilon.minosoft.config.config.game.hud.HUDGameConfig
data class GameConfig(
var graphics: GraphicsGameConfig = GraphicsGameConfig(),
var other: OtherGameConfig = OtherGameConfig(),
var hud: HUDGameConfig = HUDGameConfig(),
var controls: ControlsGameConfig = ControlsGameConfig(),
var light: LightConfig = LightConfig(),
var skin: SkinConfig = SkinConfig(),
)

View File

@ -4,6 +4,7 @@ import de.bixilon.minosoft.config.profile.profiles.Profile
import de.bixilon.minosoft.config.profile.profiles.block.BlockProfileManager.delegate
import de.bixilon.minosoft.config.profile.profiles.block.BlockProfileManager.latestVersion
import de.bixilon.minosoft.config.profile.profiles.block.outline.OutlineC
import de.bixilon.minosoft.config.profile.profiles.block.rendering.RenderingC
/**
* Profile for block rendering
@ -29,6 +30,7 @@ class BlockProfile(
var viewDistance by delegate(10) { check(it in 0..128) { "Invalid view distance $it" } }
val outline = OutlineC()
val rendering = RenderingC()
override fun toString(): String {
return BlockProfileManager.getName(this)

View File

@ -1,6 +1,6 @@
/*
* Minosoft
* Copyright (C) 2020 Moritz Zwerger
* Copyright (C) 2021 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.
*
@ -11,12 +11,15 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.config.config.game
package de.bixilon.minosoft.config.profile.profiles.block.rendering
import com.squareup.moshi.Json
import de.bixilon.minosoft.config.profile.profiles.block.BlockProfileManager.delegate
data class OtherGameConfig(
@Json(name = "anti_moire_pattern") var antiMoirePattern: Boolean = true,
@Json(name = "flower_random_offset") var flowerRandomOffset: Boolean = true,
@Json(name = "experimental_fps") var experimentalFPS: Boolean = false,
)
class RenderingC {
/**
* This option tries to do its best to fix any occurring [Moiré Patterns](https://en.wikipedia.org/wiki/Moir%C3%A9_pattern)
* If set position based random block models are disabled
*/
var antiMoirePattern by delegate(true)
}

View File

@ -6,6 +6,8 @@ import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileMan
import de.bixilon.minosoft.config.profile.profiles.rendering.advanced.AdvancedC
import de.bixilon.minosoft.config.profile.profiles.rendering.camera.CameraC
import de.bixilon.minosoft.config.profile.profiles.rendering.chunkborder.ChunkBorderC
import de.bixilon.minosoft.config.profile.profiles.rendering.experimental.ExperimentalC
import de.bixilon.minosoft.config.profile.profiles.rendering.light.LightC
import de.bixilon.minosoft.config.profile.profiles.rendering.movement.MovementC
/**
@ -24,6 +26,8 @@ class RenderingProfile(
val advanced = AdvancedC()
val movement = MovementC()
val chunkBorder = ChunkBorderC()
val light = LightC()
val experimental = ExperimentalC()
override fun toString(): String {

View File

@ -1,3 +1,16 @@
/*
* Minosoft
* Copyright (C) 2021 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.config.profile.profiles.rendering.advanced
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileManager.delegate

View File

@ -17,5 +17,8 @@ import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileMan
class ChunkBorderC {
/**
* Enables or disables chunk border lines
*/
var enabled by delegate(false)
}

View File

@ -11,8 +11,16 @@
* This software is not affiliated with Mojang AB, the original developer of Minecraft.
*/
package de.bixilon.minosoft.config.config.game
package de.bixilon.minosoft.config.profile.profiles.rendering.experimental
data class LightConfig(
var gamma: Float = 1.0f,
)
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileManager.delegate
class ExperimentalC {
/**
* Does some weird magic to improve your fps by 1-4 times.
* Recommended way to disable vsync
*/
// For further information take a look into the code at ExperimentalRenderStats
var fps by delegate(false)
}

View File

@ -0,0 +1,26 @@
/*
* Minosoft
* Copyright (C) 2021 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.config.profile.profiles.rendering.light
import de.bixilon.minosoft.config.profile.profiles.rendering.RenderingProfileManager.delegate
class LightC {
/**
* Changes the gamma value of the light map
* In original minecraft this setting is called brightness
* Must be non-negative and may not exceed 1
*/
var gamma by delegate(0.0f) { check(it in 0.0f..1.0f) { "Gama must be non negative and < 1" } }
}

View File

@ -16,6 +16,7 @@ package de.bixilon.minosoft.gui.rendering
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.config.profile.change.listener.SimpleChangeListener.Companion.listen
import de.bixilon.minosoft.data.registries.ResourceLocation
import de.bixilon.minosoft.data.text.BaseComponent
import de.bixilon.minosoft.data.text.ChatColors
@ -31,6 +32,8 @@ import de.bixilon.minosoft.gui.rendering.modding.events.*
import de.bixilon.minosoft.gui.rendering.particle.ParticleRenderer
import de.bixilon.minosoft.gui.rendering.sky.SkyRenderer
import de.bixilon.minosoft.gui.rendering.stats.AbstractRenderStats
import de.bixilon.minosoft.gui.rendering.stats.ExperimentalRenderStats
import de.bixilon.minosoft.gui.rendering.stats.RenderStats
import de.bixilon.minosoft.gui.rendering.system.base.IntegratedBufferTypes
import de.bixilon.minosoft.gui.rendering.system.base.PolygonModes
import de.bixilon.minosoft.gui.rendering.system.base.RenderSystem
@ -70,12 +73,14 @@ class RenderWindow(
val connection: PlayConnection,
val rendering: Rendering,
) {
private val profile = connection.profiles.rendering
val window: BaseWindow = GLFWWindow(connection)
val renderSystem: RenderSystem = OpenGLRenderSystem(this)
var initialized = false
private set
private lateinit var renderThread: Thread
val renderStats: AbstractRenderStats = AbstractRenderStats.createInstance()
lateinit var renderStats: AbstractRenderStats
private set
val inputHandler = RenderWindowInputHandler(this)
@ -128,6 +133,13 @@ class RenderWindow(
initialPositionReceived = true
}
})
profile.experimental::fps.listen(this, true, profile) {
renderStats = if (it) {
ExperimentalRenderStats()
} else {
RenderStats()
}
}
// order dependent (from back to front)
registerRenderer(SkyRenderer)

View File

@ -13,7 +13,6 @@
package de.bixilon.minosoft.gui.rendering.stats
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.util.avg.Average
interface AbstractRenderStats {
@ -27,16 +26,4 @@ interface AbstractRenderStats {
fun startFrame() = Unit
fun endDraw() = Unit
fun endFrame() = Unit
companion object {
fun createInstance(): AbstractRenderStats {
if (Minosoft.config.config.game.other.experimentalFPS) {
return ExperimentalRenderStats()
}
return RenderStats()
}
}
}

View File

@ -13,7 +13,6 @@
package de.bixilon.minosoft.gui.rendering.util
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.data.Axes
import de.bixilon.minosoft.data.direction.Directions
import de.bixilon.minosoft.data.registries.AABB
@ -224,7 +223,7 @@ object VecUtil {
}
fun Vec3i.getWorldOffset(block: Block): Vec3 {
if (block.randomOffsetType == null || !Minosoft.config.config.game.other.flowerRandomOffset) {
if (block.randomOffsetType == null) {
return Vec3.EMPTY
}

View File

@ -13,7 +13,6 @@
package de.bixilon.minosoft.gui.rendering.world
import de.bixilon.minosoft.Minosoft
import de.bixilon.minosoft.data.registries.effects.DefaultStatusEffects
import de.bixilon.minosoft.gui.rendering.system.base.shader.Shader
import de.bixilon.minosoft.gui.rendering.system.opengl.buffer.uniform.FloatOpenGLUniformBuffer
@ -32,6 +31,7 @@ import kotlin.math.sin
class LightMap(private val connection: PlayConnection) {
private val profile = connection.profiles.rendering.light
private val nightVisionStatusEffect = connection.registries.statusEffectRegistry[DefaultStatusEffects.NIGHT_VISION]
private val conduitPowerStatusEffect = connection.registries.statusEffectRegistry[DefaultStatusEffects.CONDUIT_POWER]
private val uniformBuffer = FloatOpenGLUniformBuffer(1, memAllocFloat(UNIFORM_BUFFER_SIZE))
@ -105,7 +105,7 @@ class LightMap(private val connection: PlayConnection) {
}
}
color = lerp(Minosoft.config.config.game.light.gamma, color, color.toVec3 modify { 1.0f - (1.0f - it).pow(4) })
color = lerp(profile.gamma, color, color.toVec3 modify { 1.0f - (1.0f - it).pow(4) })
color = lerp(0.04f, color, Vec3(0.75f))
color = color.clamp(0.0f, 1.0f)

View File

@ -16,6 +16,7 @@ package de.bixilon.minosoft.gui.rendering.world
import de.bixilon.minosoft.config.key.KeyAction
import de.bixilon.minosoft.config.key.KeyBinding
import de.bixilon.minosoft.config.key.KeyCodes
import de.bixilon.minosoft.config.profile.change.listener.SimpleChangeListener.Companion.listen
import de.bixilon.minosoft.data.assets.AssetsUtil
import de.bixilon.minosoft.data.assets.Resources
import de.bixilon.minosoft.data.direction.Directions
@ -82,6 +83,7 @@ class WorldRenderer(
private val connection: PlayConnection,
override val renderWindow: RenderWindow,
) : Renderer, OpaqueDrawable, TranslucentDrawable, TransparentDrawable {
private val profile = connection.profiles.block
override val renderSystem: RenderSystem = renderWindow.renderSystem
private val frustum = renderWindow.inputHandler.camera.frustum
private val shader = renderSystem.createShader("minosoft:world".toResourceLocation())
@ -243,15 +245,20 @@ class WorldRenderer(
}
})
renderWindow.inputHandler.registerKeyCallback("minosoft:clear_chunk_cache".toResourceLocation(), KeyBinding(
mutableMapOf(
KeyAction.MODIFIER to mutableSetOf(KeyCodes.KEY_F3),
KeyAction.PRESS to mutableSetOf(KeyCodes.KEY_A),
),
)) {
unloadWorld()
prepareWorld()
}
renderWindow.inputHandler.registerKeyCallback("minosoft:clear_chunk_cache".toResourceLocation(),
KeyBinding(
mutableMapOf(
KeyAction.MODIFIER to mutableSetOf(KeyCodes.KEY_F3),
KeyAction.PRESS to mutableSetOf(KeyCodes.KEY_A),
),
)) { clearChunkCache() }
profile.rendering::antiMoirePattern.listen(this, false, profile) { clearChunkCache() }
}
private fun clearChunkCache() {
unloadWorld()
prepareWorld()
}
private fun prepareWorld() {

View File

@ -28,6 +28,7 @@ import java.util.*
class SolidCullSectionPreparer(
val renderWindow: RenderWindow,
) : SolidSectionPreparer {
private val profile = renderWindow.connection.profiles.block.rendering
private val bedrock = renderWindow.connection.registries.blockRegistry[MinecraftBlocks.BEDROCK]?.defaultState
private val someFullBlock = renderWindow.connection.registries.blockRegistry[MinecraftBlocks.COMMAND_BLOCK]?.defaultState
private val tintColorCalculator = renderWindow.tintManager
@ -36,6 +37,7 @@ class SolidCullSectionPreparer(
override fun prepareSolid(chunkPosition: Vec2i, sectionHeight: Int, chunk: Chunk, section: ChunkSection, neighbours: Array<ChunkSection?>, neighbourChunks: Array<Chunk>, mesh: WorldMesh) {
val random = Random(0L)
val randomBlockModels = profile.antiMoirePattern
val isLowestSection = sectionHeight == chunk.lowestSection
val isHighestSection = sectionHeight == chunk.highestSection
val blocks = section.blocks
@ -124,7 +126,11 @@ class SolidCullSectionPreparer(
}
position = Vec3i(offsetX + x, offsetY + y, offsetZ + z)
random.setSeed(VecUtil.generatePositionHash(position.x, position.y, position.z))
if (randomBlockModels) {
random.setSeed(VecUtil.generatePositionHash(position.x, position.y, position.z))
} else {
random.setSeed(0L)
}
tints = tintColorCalculator.getAverageTint(chunk, neighbourChunks, blockState, x, y, z)
rendered = model.singleRender(position, mesh, random, blockState, neighbourBlocks, light, ambientLight, tints)

View File

@ -19,5 +19,4 @@ object Jackson {
init {
MAPPER.propertyNamingStrategy = PropertyNamingStrategies.SNAKE_CASE
}
}