move debug texture to render constants

This commit is contained in:
Bixilon 2021-04-09 14:09:47 +02:00
parent afd4a89406
commit 59fe64020a
No known key found for this signature in database
GPG Key ID: 5CAD791931B09AC4
6 changed files with 17 additions and 8 deletions

View File

@ -13,6 +13,7 @@
package de.bixilon.minosoft.gui.rendering package de.bixilon.minosoft.gui.rendering
import de.bixilon.minosoft.data.mappings.ResourceLocation
import de.bixilon.minosoft.data.text.RGBColor import de.bixilon.minosoft.data.text.RGBColor
object RenderConstants { object RenderConstants {
@ -57,4 +58,8 @@ object RenderConstants {
const val RENDER_HUD = true const val RENDER_HUD = true
const val FORCE_DEBUG_TEXTURE = false const val FORCE_DEBUG_TEXTURE = false
val DEBUG_TEXTURE_RESOURCE_LOCATION = ResourceLocation("minosoft:textures/debug.png")
const val DEBUG_TEXTURE_ID = 0 // always add the debug texture to the texture array first to ensure the id is 0
} }

View File

@ -238,7 +238,7 @@ class RenderWindow(
glEnable(GL_CULL_FACE) glEnable(GL_CULL_FACE)
textures.allTextures.add(Texture(TextureArray.DEBUG_TEXTURE)) textures.allTextures.add(Texture(RenderConstants.DEBUG_TEXTURE_RESOURCE_LOCATION))
font.load(connection.assetsManager) font.load(connection.assetsManager)

View File

@ -36,7 +36,7 @@ class SectionArrayMesh : Mesh(initialCacheSize = 100000) {
val lightColor = RGBColor((color.red * lightFactor).toInt(), (color.green * lightFactor).toInt(), (color.blue * lightFactor).toInt()) val lightColor = RGBColor((color.red * lightFactor).toInt(), (color.green * lightFactor).toInt(), (color.blue * lightFactor).toInt())
val textureLayer = if (RenderConstants.FORCE_DEBUG_TEXTURE) { val textureLayer = if (RenderConstants.FORCE_DEBUG_TEXTURE) {
0 RenderConstants.DEBUG_TEXTURE_ID
} else { } else {
(texture.arrayId shl 24) or texture.arrayLayer (texture.arrayId shl 24) or texture.arrayLayer
} }

View File

@ -33,7 +33,13 @@ import de.bixilon.minosoft.gui.rendering.util.VecUtil.rotate
import glm_.vec3.Vec3 import glm_.vec3.Vec3
import glm_.vec3.Vec3i import glm_.vec3.Vec3i
class ElementRenderer(parent: BlockModelElement, val rotation: Vec3, uvLock: Boolean, rescale: Boolean, private val directionMapping: HashBiMap<Directions, Directions>) { class ElementRenderer(
parent: BlockModelElement,
val rotation: Vec3,
uvLock: Boolean,
rescale: Boolean,
private val directionMapping: HashBiMap<Directions, Directions>,
) {
val faceBorderSize: Array<FaceSize?> = arrayOfNulls(Directions.DIRECTIONS.size) val faceBorderSize: Array<FaceSize?> = arrayOfNulls(Directions.DIRECTIONS.size)
private val faces: MutableMap<Directions, BlockModelFace> = mutableMapOf() private val faces: MutableMap<Directions, BlockModelFace> = mutableMapOf()
private var transformedPositions: Array<Vec3> = parent.transformedPositions.clone() private var transformedPositions: Array<Vec3> = parent.transformedPositions.clone()
@ -68,7 +74,7 @@ class ElementRenderer(parent: BlockModelElement, val rotation: Vec3, uvLock: Boo
val face = faces[realDirection] ?: return // Not our face val face = faces[realDirection] ?: return // Not our face
val positionTemplate = BlockModelElement.FACE_POSITION_MAP_TEMPLATE[realDirection.ordinal] val positionTemplate = BlockModelElement.FACE_POSITION_MAP_TEMPLATE[realDirection.ordinal]
val texture = textureMapping[face.textureName] ?: TODO("Unknown texture used ${face.textureName}") val texture = textureMapping[face.textureName] ?: TODO("Unknown texture used ${face.textureName}") // ToDo: can be replaced with RenderConstants.DEBUG_TEXTURE_ID?
val lightLevel = lightAccessor.getLightLevel(blockPosition + face.cullFace?.let { directionMapping[it] }) // ToDo: rotate cullface val lightLevel = lightAccessor.getLightLevel(blockPosition + face.cullFace?.let { directionMapping[it] }) // ToDo: rotate cullface

View File

@ -18,8 +18,8 @@ import com.google.gson.JsonObject
import de.bixilon.minosoft.data.assets.AssetsManager import de.bixilon.minosoft.data.assets.AssetsManager
import de.bixilon.minosoft.data.mappings.ResourceLocation import de.bixilon.minosoft.data.mappings.ResourceLocation
import de.bixilon.minosoft.data.text.RGBColor import de.bixilon.minosoft.data.text.RGBColor
import de.bixilon.minosoft.gui.rendering.RenderConstants
import de.bixilon.minosoft.gui.rendering.textures.Texture import de.bixilon.minosoft.gui.rendering.textures.Texture
import de.bixilon.minosoft.gui.rendering.textures.TextureArray
import java.io.InputStream import java.io.InputStream
object FontLoader { object FontLoader {
@ -97,7 +97,7 @@ object FontLoader {
if (i % 256 == 0) { if (i % 256 == 0) {
currentAtlasTexture = if (MISSING_UNICODE_PAGES.contains(i / UNICODE_CHARS_PER_PAGE)) { currentAtlasTexture = if (MISSING_UNICODE_PAGES.contains(i / UNICODE_CHARS_PER_PAGE)) {
// ToDo: Why is this texture missing in minecraft? // ToDo: Why is this texture missing in minecraft?
Texture(TextureArray.DEBUG_TEXTURE) Texture(RenderConstants.DEBUG_TEXTURE_RESOURCE_LOCATION)
} else { } else {
// new page (texture) // new page (texture)
Texture(Texture.getResourceTextureIdentifier(template.namespace, template.path.format("%02x".format(i / 256)))) Texture(Texture.getResourceTextureIdentifier(template.namespace, template.path.format("%02x".format(i / 256))))

View File

@ -145,8 +145,6 @@ class TextureArray(val allTextures: MutableList<Texture>) {
val TEXTURE_RESOLUTION_ID_MAP = arrayOf(16, 32, 64, 128, 256, 512, 1024) // A 12x12 texture will be saved in texture id 0 (in 0 are only 16x16 textures). Animated textures get split val TEXTURE_RESOLUTION_ID_MAP = arrayOf(16, 32, 64, 128, 256, 512, 1024) // A 12x12 texture will be saved in texture id 0 (in 0 are only 16x16 textures). Animated textures get split
const val TEXTURE_MAX_RESOLUTION = 1024 const val TEXTURE_MAX_RESOLUTION = 1024
val DEBUG_TEXTURE = ResourceLocation("minosoft:textures/debug.png")
private const val INTS_PER_ANIMATED_TEXTURE = 4 private const val INTS_PER_ANIMATED_TEXTURE = 4
} }