From 620a49d34847efd5a97747d610e581c0cf74efa2 Mon Sep 17 00:00:00 2001 From: Bixilon Date: Wed, 4 Aug 2021 13:14:06 +0200 Subject: [PATCH] wip HUDRenderer --- .../minosoft/gui/rendering/RenderWindow.kt | 17 ++-- .../block/mesh/ChunkSectionArrayMesh.kt | 2 +- .../minosoft/gui/rendering/font/CharData.kt | 9 +++ .../gui/rendering/gui/hud/HUDRenderer.kt | 81 +++++++++++++++++++ .../{ => gui}/hud/atlas/TextureLike.kt | 2 +- .../{ => gui}/hud/atlas/TextureLikeTexture.kt | 2 +- .../rendering/gui/mesh/FontVertexConsumer.kt | 26 ++++++ .../gui/rendering/gui/mesh/GUIMesh.kt | 73 +++++++++++++++++ .../minosoft/gui/rendering/sky/SkyRenderer.kt | 7 +- .../minosoft/gui/rendering/util/mesh/Mesh.kt | 39 ++++----- .../rendering/util/mesh/SimpleTextureMesh.kt | 8 +- .../minosoft/rendering/shader/hud/hud.fsh | 2 + .../minosoft/rendering/shader/hud/hud.vsh | 8 +- .../rendering/shader/includes/texture.glsl | 18 ++--- .../rendering/shader/sky/sun/sky_sun.vsh | 4 +- .../minosoft/rendering/shader/world/world.vsh | 8 +- 16 files changed, 247 insertions(+), 59 deletions(-) create mode 100644 src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/HUDRenderer.kt rename src/main/java/de/bixilon/minosoft/gui/rendering/{ => gui}/hud/atlas/TextureLike.kt (94%) rename src/main/java/de/bixilon/minosoft/gui/rendering/{ => gui}/hud/atlas/TextureLikeTexture.kt (97%) create mode 100644 src/main/java/de/bixilon/minosoft/gui/rendering/gui/mesh/FontVertexConsumer.kt create mode 100644 src/main/java/de/bixilon/minosoft/gui/rendering/gui/mesh/GUIMesh.kt 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 e912e751f..c8c8f9b4a 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/RenderWindow.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/RenderWindow.kt @@ -13,21 +13,15 @@ package de.bixilon.minosoft.gui.rendering -import de.bixilon.minosoft.Minosoft import de.bixilon.minosoft.config.config.game.controls.KeyBindingsNames import de.bixilon.minosoft.data.registries.ResourceLocation -import de.bixilon.minosoft.gui.rendering.block.WorldRenderer -import de.bixilon.minosoft.gui.rendering.block.chunk.ChunkBorderRenderer -import de.bixilon.minosoft.gui.rendering.block.outline.BlockOutlineRenderer -import de.bixilon.minosoft.gui.rendering.entity.EntityHitBoxRenderer import de.bixilon.minosoft.gui.rendering.font.Font import de.bixilon.minosoft.gui.rendering.font.FontLoader -import de.bixilon.minosoft.gui.rendering.hud.atlas.TextureLike -import de.bixilon.minosoft.gui.rendering.hud.atlas.TextureLikeTexture +import de.bixilon.minosoft.gui.rendering.gui.hud.HUDRenderer +import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.TextureLike +import de.bixilon.minosoft.gui.rendering.gui.hud.atlas.TextureLikeTexture import de.bixilon.minosoft.gui.rendering.input.key.RenderWindowInputHandler 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.system.base.IntegratedBufferTypes import de.bixilon.minosoft.gui.rendering.system.base.PolygonModes import de.bixilon.minosoft.gui.rendering.system.base.RenderSystem @@ -104,7 +98,7 @@ class RenderWindow( }) // order dependent (from back to front) - registerRenderer(SkyRenderer) +/* registerRenderer(SkyRenderer) registerRenderer(WorldRenderer) registerRenderer(BlockOutlineRenderer) if (Minosoft.config.config.game.graphics.particles.enabled) { @@ -115,7 +109,8 @@ class RenderWindow( } if (Minosoft.config.config.game.world.chunkBorders.enabled) { registerRenderer(ChunkBorderRenderer) - } + }*/ + registerRenderer(HUDRenderer) } fun init(latch: CountUpAndDownLatch) { diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/block/mesh/ChunkSectionArrayMesh.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/block/mesh/ChunkSectionArrayMesh.kt index e56b8d080..c5af3cc5c 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/block/mesh/ChunkSectionArrayMesh.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/block/mesh/ChunkSectionArrayMesh.kt @@ -51,7 +51,7 @@ class ChunkSectionArrayMesh(renderWindow: RenderWindow) : Mesh(renderWindow, Sec data class SectionArrayMeshStruct( val position: Vec3, - val uvCoordinates: Vec2, + val uv: Vec2, val textureLayer: Int, val animationId: Int, val tintColor: RGBColor, diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/font/CharData.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/font/CharData.kt index 5f94d85ec..cf163aeba 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/font/CharData.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/font/CharData.kt @@ -13,8 +13,12 @@ package de.bixilon.minosoft.gui.rendering.font +import de.bixilon.minosoft.data.text.ChatColors +import de.bixilon.minosoft.data.text.TextStyle +import de.bixilon.minosoft.gui.rendering.gui.mesh.FontVertexConsumer import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture import glm_.vec2.Vec2 +import glm_.vec2.Vec2i class CharData( val char: Char, @@ -23,8 +27,13 @@ class CharData( var uvStart: Vec2, var uvEnd: Vec2, ) { + fun postInit() { uvStart = uvStart * texture.textureArrayUV uvEnd = uvEnd * texture.textureArrayUV } + + fun render(position: Vec2i, style: TextStyle, vertexConsumer: FontVertexConsumer) { + vertexConsumer.addQuad(position, position + Vec2i(width, Font.CHAR_HEIGHT), texture, uvStart, uvEnd, style.color ?: ChatColors.WHITE) + } } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/HUDRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/HUDRenderer.kt new file mode 100644 index 000000000..6906f30ea --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/HUDRenderer.kt @@ -0,0 +1,81 @@ +/* + * 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.gui.rendering.gui.hud + +import de.bixilon.minosoft.Minosoft +import de.bixilon.minosoft.data.registries.ResourceLocation +import de.bixilon.minosoft.data.text.ChatColors +import de.bixilon.minosoft.data.text.PreChatFormattingCodes +import de.bixilon.minosoft.data.text.TextComponent +import de.bixilon.minosoft.gui.rendering.RenderWindow +import de.bixilon.minosoft.gui.rendering.Renderer +import de.bixilon.minosoft.gui.rendering.RendererBuilder +import de.bixilon.minosoft.gui.rendering.gui.mesh.GUIMesh +import de.bixilon.minosoft.gui.rendering.modding.events.ResizeWindowEvent +import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker +import de.bixilon.minosoft.protocol.network.connection.play.PlayConnection +import de.bixilon.minosoft.util.KUtil.toResourceLocation +import glm_.glm +import glm_.mat4x4.Mat4 +import glm_.vec2.Vec2i + +class HUDRenderer( + val connection: PlayConnection, + val renderWindow: RenderWindow, +) : Renderer { + private val shader = renderWindow.renderSystem.createShader("minosoft:hud".toResourceLocation()) + private lateinit var mesh: GUIMesh + var scaledSize: Vec2i = renderWindow.window.size + private var matrix: Mat4 = Mat4() + + override fun init() { + connection.registerEvent(CallbackEventInvoker.of { + scaledSize = it.size / Minosoft.config.config.game.hud.scale + matrix = glm.ortho(0.0f, scaledSize.x.toFloat(), scaledSize.y.toFloat(), 0.0f) + }) + } + + override fun postInit() { + shader.load() + renderWindow.textureManager.staticTextures.use(shader) + } + + override fun draw() { + renderWindow.renderSystem.reset() + if (this::mesh.isInitialized) { + mesh.unload() + } + + mesh = GUIMesh(renderWindow, matrix) + val style = TextComponent("", ChatColors.BLUE, ChatColors.RED, formatting = mutableSetOf(PreChatFormattingCodes.BOLD, PreChatFormattingCodes.SHADOWED, PreChatFormattingCodes.UNDERLINED)) + renderWindow.font['M']?.render(Vec2i(100, 100), style, mesh) + renderWindow.font['o']?.render(Vec2i(108, 100), style, mesh) + renderWindow.font['r']?.render(Vec2i(116, 100), style, mesh) + + mesh.load() + + + + shader.use() + mesh.draw() + } + + companion object : RendererBuilder { + override val RESOURCE_LOCATION = ResourceLocation("minosoft:hud_renderer") + + override fun build(connection: PlayConnection, renderWindow: RenderWindow): HUDRenderer { + return HUDRenderer(connection, renderWindow) + } + } +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/hud/atlas/TextureLike.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/atlas/TextureLike.kt similarity index 94% rename from src/main/java/de/bixilon/minosoft/gui/rendering/hud/atlas/TextureLike.kt rename to src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/atlas/TextureLike.kt index af3f0f67f..0825aa2e3 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/hud/atlas/TextureLike.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/atlas/TextureLike.kt @@ -11,7 +11,7 @@ * This software is not affiliated with Mojang AB, the original developer of Minecraft. */ -package de.bixilon.minosoft.gui.rendering.hud.atlas +package de.bixilon.minosoft.gui.rendering.gui.hud.atlas import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture import glm_.vec2.Vec2 diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/hud/atlas/TextureLikeTexture.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/atlas/TextureLikeTexture.kt similarity index 97% rename from src/main/java/de/bixilon/minosoft/gui/rendering/hud/atlas/TextureLikeTexture.kt rename to src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/atlas/TextureLikeTexture.kt index 55f298c5d..f45c55032 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/hud/atlas/TextureLikeTexture.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/hud/atlas/TextureLikeTexture.kt @@ -24,7 +24,7 @@ * This software is not affiliated with Mojang AB, the original developer of Minecraft. */ -package de.bixilon.minosoft.gui.rendering.hud.atlas +package de.bixilon.minosoft.gui.rendering.gui.hud.atlas import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture import glm_.vec2.Vec2 diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/mesh/FontVertexConsumer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/mesh/FontVertexConsumer.kt new file mode 100644 index 000000000..a70a4127f --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/mesh/FontVertexConsumer.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.gui.rendering.gui.mesh + +import de.bixilon.minosoft.data.text.RGBColor +import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture +import glm_.vec2.Vec2 +import glm_.vec2.Vec2i + +interface FontVertexConsumer { + + fun addVertex(position: Vec2i, texture: AbstractTexture, uv: Vec2, tint: RGBColor) + + fun addQuad(start: Vec2i, end: Vec2i, texture: AbstractTexture, uvStart: Vec2, uvEnd: Vec2, tint: RGBColor) +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/gui/mesh/GUIMesh.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/mesh/GUIMesh.kt new file mode 100644 index 000000000..7220d1a59 --- /dev/null +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/gui/mesh/GUIMesh.kt @@ -0,0 +1,73 @@ +/* + * 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.gui.rendering.gui.mesh + +import de.bixilon.minosoft.data.text.RGBColor +import de.bixilon.minosoft.gui.rendering.RenderConstants +import de.bixilon.minosoft.gui.rendering.RenderWindow +import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture +import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh +import de.bixilon.minosoft.gui.rendering.util.mesh.MeshStruct +import glm_.mat4x4.Mat4 +import glm_.vec2.Vec2 +import glm_.vec2.Vec2i +import glm_.vec3.Vec3 +import glm_.vec4.Vec4 + +class GUIMesh( + renderWindow: RenderWindow, + val matrix: Mat4, +) : Mesh(renderWindow, HUDMeshStruct), FontVertexConsumer { + + override fun addVertex(position: Vec2i, texture: AbstractTexture, uv: Vec2, tint: RGBColor) { + val outPosition = matrix * Vec4(position, 1.0f, 1.0f) + data.addAll(floatArrayOf( + outPosition.x, + outPosition.y, + 0.95f, + uv.x, + uv.y, + Float.fromBits(texture.renderData?.layer ?: RenderConstants.DEBUG_TEXTURE_ID), + Float.fromBits(tint.rgba), + )) + } + + override fun addQuad(start: Vec2i, end: Vec2i, texture: AbstractTexture, uvStart: Vec2, uvEnd: Vec2, tint: RGBColor) { + val positions = arrayOf( + start, + Vec2i(end.x, start.y), + end, + Vec2i(start.x, end.y), + ) + val texturePositions = arrayOf( + Vec2(uvEnd.x, uvStart.y), + uvStart, + Vec2(uvStart.x, uvEnd.y), + uvEnd, + ) + + for ((vertexIndex, textureIndex) in QUAD_DRAW_ODER) { + addVertex(positions[vertexIndex], texture, texturePositions[textureIndex], tint) + } + } + + data class HUDMeshStruct( + val position: Vec3, + val uv: Vec2, + val textureLayer: Int, + val tintColor: RGBColor, + ) { + companion object : MeshStruct(HUDMeshStruct::class) + } +} diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/sky/SkyRenderer.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/sky/SkyRenderer.kt index a3259cf5b..d9bee8377 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/sky/SkyRenderer.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/sky/SkyRenderer.kt @@ -25,6 +25,7 @@ import de.bixilon.minosoft.gui.rendering.modding.events.CameraMatrixChangeEvent import de.bixilon.minosoft.gui.rendering.system.base.BlendingFunctions import de.bixilon.minosoft.gui.rendering.system.base.DepthFunctions import de.bixilon.minosoft.gui.rendering.system.base.texture.texture.AbstractTexture +import de.bixilon.minosoft.gui.rendering.util.mesh.Mesh import de.bixilon.minosoft.gui.rendering.util.mesh.SimpleTextureMesh import de.bixilon.minosoft.modding.event.events.TimeChangeEvent import de.bixilon.minosoft.modding.event.invoker.CallbackEventInvoker @@ -94,14 +95,14 @@ class SkyRenderer( skySunMesh = SimpleTextureMesh(renderWindow) - skySunMesh.addQuad( + Mesh.addQuad( start = Vec3(-0.15f, 1.0f, -0.15f), end = Vec3(+0.15f, 1.0f, +0.15f), - vertexConsumer = { position, textureCoordinate -> + vertexConsumer = { position, uv -> skySunMesh.addVertex( position = position, texture = sunTexture, - textureCoordinates = textureCoordinate, + uv = uv, tintColor = ChatColors.WHITE.with(alpha = 1.0f - connection.world.rainGradient), // ToDo: Depends on time ) } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/util/mesh/Mesh.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/util/mesh/Mesh.kt index 7a890f334..be80d20e7 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/util/mesh/Mesh.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/util/mesh/Mesh.kt @@ -61,25 +61,6 @@ abstract class Mesh( } } - fun addQuad(start: Vec3, end: Vec3, textureStart: Vec2 = Vec2(0.0f, 0.0f), textureEnd: Vec2 = Vec2(1.0f, 1.0f), vertexConsumer: (position: Vec3, textureCoordinate: Vec2) -> Unit) { - val positions = arrayOf( - start, - Vec3(start.x, start.y, end.z), - end, - Vec3(end.x, end.y, start.z), - ) - val texturePositions = arrayOf( - Vec2(textureEnd.x, textureStart.y), - textureStart, - Vec2(textureStart.x, textureEnd.y), - textureEnd, - ) - - for ((vertexIndex, textureIndex) in QUAD_DRAW_ODER) { - vertexConsumer.invoke(positions[vertexIndex], texturePositions[textureIndex]) - } - } - enum class MeshStates { PREPARING, LOADED, @@ -95,5 +76,25 @@ abstract class Mesh( 1 to 0, 0 to 1, ) + + + fun addQuad(start: Vec3, end: Vec3, uvStart: Vec2 = Vec2(0.0f, 0.0f), uvEnd: Vec2 = Vec2(1.0f, 1.0f), vertexConsumer: (position: Vec3, uv: Vec2) -> Unit) { + val positions = arrayOf( + start, + Vec3(start.x, start.y, end.z), + end, + Vec3(end.x, end.y, start.z), + ) + val texturePositions = arrayOf( + Vec2(uvEnd.x, uvStart.y), + uvStart, + Vec2(uvStart.x, uvEnd.y), + uvEnd, + ) + + for ((vertexIndex, textureIndex) in QUAD_DRAW_ODER) { + vertexConsumer.invoke(positions[vertexIndex], texturePositions[textureIndex]) + } + } } } diff --git a/src/main/java/de/bixilon/minosoft/gui/rendering/util/mesh/SimpleTextureMesh.kt b/src/main/java/de/bixilon/minosoft/gui/rendering/util/mesh/SimpleTextureMesh.kt index 7b0bfdbfe..f11374ca6 100644 --- a/src/main/java/de/bixilon/minosoft/gui/rendering/util/mesh/SimpleTextureMesh.kt +++ b/src/main/java/de/bixilon/minosoft/gui/rendering/util/mesh/SimpleTextureMesh.kt @@ -22,7 +22,7 @@ import glm_.vec3.Vec3 open class SimpleTextureMesh(renderWindow: RenderWindow) : Mesh(renderWindow, SimpleTextureMeshStruct, initialCacheSize = 2 * 3 * SimpleTextureMeshStruct.FLOATS_PER_VERTEX) { - fun addVertex(position: Vec3, texture: AbstractTexture, textureCoordinates: Vec2, tintColor: RGBColor) { + fun addVertex(position: Vec3, texture: AbstractTexture, uv: Vec2, tintColor: RGBColor) { val textureLayer = if (RenderConstants.FORCE_DEBUG_TEXTURE) { RenderConstants.DEBUG_TEXTURE_ID } else { @@ -34,8 +34,8 @@ open class SimpleTextureMesh(renderWindow: RenderWindow) : Mesh(renderWindow, Si position.x, position.y, position.z, - textureCoordinates.x, - textureCoordinates.y, + uv.x, + uv.y, Float.fromBits(textureLayer), Float.fromBits(tintColor.rgba), )) @@ -44,7 +44,7 @@ open class SimpleTextureMesh(renderWindow: RenderWindow) : Mesh(renderWindow, Si data class SimpleTextureMeshStruct( val position: Vec3, - val uvCoordinates: Vec2, + val uv: Vec2, val textureLayer: Int, val animationId: Int, ) { diff --git a/src/main/resources/assets/minosoft/rendering/shader/hud/hud.fsh b/src/main/resources/assets/minosoft/rendering/shader/hud/hud.fsh index a364a74fa..5a6a141e3 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/hud/hud.fsh +++ b/src/main/resources/assets/minosoft/rendering/shader/hud/hud.fsh @@ -24,6 +24,8 @@ in vec4 finTintColor; void main() { vec4 texelColor = getTexture(finTextureIndex, finTextureCoordinates); + //texelColor = vec4(1.0f, 0.0f, 1.0f, 1.0f); + if (finTintColor.a == 1.0f && texelColor.a == 0) { discard; } diff --git a/src/main/resources/assets/minosoft/rendering/shader/hud/hud.vsh b/src/main/resources/assets/minosoft/rendering/shader/hud/hud.vsh index 689d902f6..4030d3603 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/hud/hud.vsh +++ b/src/main/resources/assets/minosoft/rendering/shader/hud/hud.vsh @@ -14,8 +14,8 @@ #version 330 core layout (location = 0) in vec3 vinPosition; -layout (location = 1) in vec2 vinUVCoordinates; -layout (location = 2) in uint vinRextureLayer; +layout (location = 1) in vec2 vinUV; +layout (location = 2) in uint vinTextureLayer; layout (location = 3) in uint vinTintColor; flat out uint finTextureIndex; @@ -26,7 +26,7 @@ out vec4 finTintColor; void main() { gl_Position = vec4(vinPosition.xyz, 1.0f); - finTextureCoordinates = vec3(vinUVCoordinates, vinRextureLayer & 0xFFFFFFu); - finTextureIndex = vinRextureLayer >> 24u; + finTextureCoordinates = vec3(vinUV, vinTextureLayer & 0xFFFFFFu); + finTextureIndex = vinTextureLayer >> 24u; finTintColor = getRGBAColor(vinTintColor); } diff --git a/src/main/resources/assets/minosoft/rendering/shader/includes/texture.glsl b/src/main/resources/assets/minosoft/rendering/shader/includes/texture.glsl index ca3de516d..0e948a4b6 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/includes/texture.glsl +++ b/src/main/resources/assets/minosoft/rendering/shader/includes/texture.glsl @@ -14,18 +14,18 @@ uniform sampler2DArray uTextures[7]; -vec4 getTexture(uint textureId, vec3 textureCoordinates) { // ToDo: This method is just stupid and workarounds a opengl crash with mesa drivers +vec4 getTexture(uint textureId, vec3 uv) { // ToDo: This method is just stupid and workarounds a opengl crash with mesa drivers #ifdef __NVIDIA - return texture(uTextures[textureId], textureCoordinates); + return texture(uTextures[textureId], uv); #else switch (textureId) { - case 1u: return texture(uTextures[1], textureCoordinates); - case 2u: return texture(uTextures[2], textureCoordinates); - case 3u: return texture(uTextures[3], textureCoordinates); - case 4u: return texture(uTextures[4], textureCoordinates); - case 5u: return texture(uTextures[5], textureCoordinates); - case 6u: return texture(uTextures[6], textureCoordinates); + case 1u: return texture(uTextures[1], uv); + case 2u: return texture(uTextures[2], uv); + case 3u: return texture(uTextures[3], uv); + case 4u: return texture(uTextures[4], uv); + case 5u: return texture(uTextures[5], uv); + case 6u: return texture(uTextures[6], uv); } - return texture(uTextures[0], textureCoordinates); + return texture(uTextures[0], uv); #endif } diff --git a/src/main/resources/assets/minosoft/rendering/shader/sky/sun/sky_sun.vsh b/src/main/resources/assets/minosoft/rendering/shader/sky/sun/sky_sun.vsh index 5847ed543..9202f9bd2 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/sky/sun/sky_sun.vsh +++ b/src/main/resources/assets/minosoft/rendering/shader/sky/sun/sky_sun.vsh @@ -14,7 +14,7 @@ #version 330 core layout (location = 0) in vec3 vinPosition; -layout (location = 1) in vec2 vinUVCoordinates; +layout (location = 1) in vec2 vinUV; layout (location = 2) in uint vinTextureLayer; layout (location = 3) in uint vinTintColor; @@ -29,7 +29,7 @@ uniform mat4 uSkyViewProjectionMatrix; void main() { gl_Position = (uSkyViewProjectionMatrix * vec4(vinPosition, 1.0f)).xyww - vec4(0.0f, 0.0f, 0.000001f, 0.0f);// prevent face fighting - finTextureCoordinates = vec3(vinUVCoordinates, vinTextureLayer & 0xFFFFFFu); + finTextureCoordinates = vec3(vinUV, vinTextureLayer & 0xFFFFFFu); finTextureIndex = vinTextureLayer >> 24u; finTintColor = getRGBAColor(vinTintColor); } diff --git a/src/main/resources/assets/minosoft/rendering/shader/world/world.vsh b/src/main/resources/assets/minosoft/rendering/shader/world/world.vsh index 99bae7e8f..a9bb6bc3c 100644 --- a/src/main/resources/assets/minosoft/rendering/shader/world/world.vsh +++ b/src/main/resources/assets/minosoft/rendering/shader/world/world.vsh @@ -14,7 +14,7 @@ #version 330 core layout (location = 0) in vec3 vinPosition; -layout (location = 1) in vec2 vinUVCoordinates; +layout (location = 1) in vec2 vinUV; layout (location = 2) in uint vinTextureLayer; layout (location = 3) in int vinAnimationIndex; @@ -45,7 +45,7 @@ void work() { if (vinAnimationIndex == -1) { finTextureIndex1 = vinTextureLayer >> 24u; - finTextureCoordinates1 = vec3(vinUVCoordinates, (vinTextureLayer & 0xFFFFFFu)); + finTextureCoordinates1 = vec3(vinUV, (vinTextureLayer & 0xFFFFFFu)); finInterpolation = 0.0f; return; @@ -57,10 +57,10 @@ void work() { uint interpolation = data.z; finTextureIndex1 = firstTexture >> 24u; - finTextureCoordinates1 = vec3(vinUVCoordinates, firstTexture & 0xFFFFFFu); + finTextureCoordinates1 = vec3(vinUV, firstTexture & 0xFFFFFFu); finTextureIndex2 = secondTexture >> 24u; - finTextureCoordinates2 = vec3(vinUVCoordinates, secondTexture & 0xFFFFFFu); + finTextureCoordinates2 = vec3(vinUV, secondTexture & 0xFFFFFFu); finInterpolation = interpolation / 100.0f; }