diff --git a/src/main/java/de/bixilon/minosoft/config/config/game/GameConfig.kt b/src/main/java/de/bixilon/minosoft/config/config/game/GameConfig.kt index 33d6602c0..0a7fbd23c 100644 --- a/src/main/java/de/bixilon/minosoft/config/config/game/GameConfig.kt +++ b/src/main/java/de/bixilon/minosoft/config/config/game/GameConfig.kt @@ -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(), ) diff --git a/src/main/java/de/bixilon/minosoft/config/profile/profiles/block/BlockProfile.kt b/src/main/java/de/bixilon/minosoft/config/profile/profiles/block/BlockProfile.kt index bf37e9d2b..906a90829 100644 --- a/src/main/java/de/bixilon/minosoft/config/profile/profiles/block/BlockProfile.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/profiles/block/BlockProfile.kt @@ -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) diff --git a/src/main/java/de/bixilon/minosoft/config/config/game/OtherGameConfig.kt b/src/main/java/de/bixilon/minosoft/config/profile/profiles/block/rendering/RenderingC.kt similarity index 66% rename from src/main/java/de/bixilon/minosoft/config/config/game/OtherGameConfig.kt rename to src/main/java/de/bixilon/minosoft/config/profile/profiles/block/rendering/RenderingC.kt index 42f8766ec..06ec0880e 100644 --- a/src/main/java/de/bixilon/minosoft/config/config/game/OtherGameConfig.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/profiles/block/rendering/RenderingC.kt @@ -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) +} diff --git a/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/RenderingProfile.kt b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/RenderingProfile.kt index b90b0c37f..9ace8ff8a 100644 --- a/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/RenderingProfile.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/RenderingProfile.kt @@ -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 { diff --git a/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/advanced/AdvancedC.kt b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/advanced/AdvancedC.kt index 3ff2d6e82..275dac7ed 100644 --- a/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/advanced/AdvancedC.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/advanced/AdvancedC.kt @@ -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 . + * + * 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 diff --git a/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/chunkborder/ChunkBorderC.kt b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/chunkborder/ChunkBorderC.kt index 45ba22b9f..afa4b2eb5 100644 --- a/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/chunkborder/ChunkBorderC.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/chunkborder/ChunkBorderC.kt @@ -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) } diff --git a/src/main/java/de/bixilon/minosoft/config/config/game/LightConfig.kt b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/experimental/ExperimentalC.kt similarity index 64% rename from src/main/java/de/bixilon/minosoft/config/config/game/LightConfig.kt rename to src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/experimental/ExperimentalC.kt index 49ec55871..14ddd109d 100644 --- a/src/main/java/de/bixilon/minosoft/config/config/game/LightConfig.kt +++ b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/experimental/ExperimentalC.kt @@ -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) +} diff --git a/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/light/LightC.kt b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/light/LightC.kt new file mode 100644 index 000000000..d76f7bcc8 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/config/profile/profiles/rendering/light/LightC.kt @@ -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 . + * + * 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" } } +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/RenderWindow.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/RenderWindow.kt index 1450ab558..f5f360fcc 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/RenderWindow.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/RenderWindow.kt @@ -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) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/stats/AbstractRenderStats.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/stats/AbstractRenderStats.kt index 488398725..549378efa 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/stats/AbstractRenderStats.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/stats/AbstractRenderStats.kt @@ -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() - } - } } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/util/VecUtil.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/util/VecUtil.kt index 10b0e2f14..9f475f399 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/util/VecUtil.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/util/VecUtil.kt @@ -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 } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/LightMap.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/LightMap.kt index e3ee4af32..8cd0e40ad 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/LightMap.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/LightMap.kt @@ -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) diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/WorldRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/WorldRenderer.kt index c6c761e42..5c56f57fc 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/WorldRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/WorldRenderer.kt @@ -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() { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt index 0f314711a..ecb944263 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/world/preparer/cull/SolidCullSectionPreparer.kt @@ -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, neighbourChunks: Array, 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) diff --git a/src/main/java/de/bixilon/minosoft/util/json/jackson/Jackson.kt b/src/main/java/de/bixilon/minosoft/util/json/jackson/Jackson.kt index abcd5a39f..afbbcb76a 100644 --- a/src/main/java/de/bixilon/minosoft/util/json/jackson/Jackson.kt +++ b/src/main/java/de/bixilon/minosoft/util/json/jackson/Jackson.kt @@ -19,5 +19,4 @@ object Jackson { init { MAPPER.propertyNamingStrategy = PropertyNamingStrategies.SNAKE_CASE } - }