mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-11 00:23:42 -04:00
rendering: reduce amount of floats per vertex, improve preparing performance
This commit is contained in:
parent
71ebcab943
commit
7d501bfc6b
@ -60,8 +60,6 @@ object RenderConstants {
|
|||||||
val DEBUG_TEXTURE_RESOURCE_LOCATION = ResourceLocation("minosoft:textures/debug.png")
|
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
|
const val DEBUG_TEXTURE_ID = 0 // always add the debug texture to the texture array first to ensure the id is 0
|
||||||
|
|
||||||
const val FORCE_DEBUG_TEXTURE = false
|
|
||||||
|
|
||||||
|
|
||||||
val PIXEL_UV_PIXEL_ADD = Vec2(0, 0.1f)
|
val PIXEL_UV_PIXEL_ADD = Vec2(0, 0.1f)
|
||||||
|
|
||||||
|
@ -18,8 +18,6 @@ import de.bixilon.minosoft.data.assets.Resources
|
|||||||
import de.bixilon.minosoft.data.direction.Directions
|
import de.bixilon.minosoft.data.direction.Directions
|
||||||
import de.bixilon.minosoft.data.direction.FakeDirection
|
import de.bixilon.minosoft.data.direction.FakeDirection
|
||||||
import de.bixilon.minosoft.data.registries.ResourceLocation
|
import de.bixilon.minosoft.data.registries.ResourceLocation
|
||||||
import de.bixilon.minosoft.data.registries.blocks.properties.BlockProperties
|
|
||||||
import de.bixilon.minosoft.data.registries.blocks.properties.MultipartDirectionParser
|
|
||||||
import de.bixilon.minosoft.data.world.ChunkSection
|
import de.bixilon.minosoft.data.world.ChunkSection
|
||||||
import de.bixilon.minosoft.data.world.World
|
import de.bixilon.minosoft.data.world.World
|
||||||
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
import de.bixilon.minosoft.gui.rendering.RenderWindow
|
||||||
@ -74,10 +72,9 @@ class WorldRenderer(
|
|||||||
|
|
||||||
|
|
||||||
val random = Random(0L)
|
val random = Random(0L)
|
||||||
val blockState1 = connection.registries.blockRegistry["grass_block"]?.defaultState
|
val blockState1 = connection.registries.blockRegistry["redstone_block"]?.defaultState
|
||||||
val blockState2 = connection.registries.blockRegistry["oak_fence"]!!.defaultState.withProperties(BlockProperties.MULTIPART_SOUTH to MultipartDirectionParser.SIDE, BlockProperties.MULTIPART_NORTH to MultipartDirectionParser.SIDE, BlockProperties.MULTIPART_EAST to MultipartDirectionParser.SIDE, BlockProperties.MULTIPART_WEST to MultipartDirectionParser.SIDE)
|
val blockState2 = connection.registries.blockRegistry["diamond_block"]!!.defaultState//.withProperties(BlockProperties.MULTIPART_SOUTH to MultipartDirectionParser.SIDE, BlockProperties.MULTIPART_NORTH to MultipartDirectionParser.SIDE, BlockProperties.MULTIPART_EAST to MultipartDirectionParser.SIDE, BlockProperties.MULTIPART_WEST to MultipartDirectionParser.SIDE)
|
||||||
val section = ChunkSection(Array(4096) {
|
val section = ChunkSection(Array(4096) {
|
||||||
if (it < 4096) return@Array blockState2 else return@Array null
|
|
||||||
when (random.nextInt(3)) {
|
when (random.nextInt(3)) {
|
||||||
1 -> blockState1
|
1 -> blockState1
|
||||||
2 -> blockState2
|
2 -> blockState2
|
||||||
@ -88,8 +85,8 @@ class WorldRenderer(
|
|||||||
|
|
||||||
mesh = sectionPreparer.prepare(section)
|
mesh = sectionPreparer.prepare(section)
|
||||||
|
|
||||||
// for (i in 0 until 1000)
|
for (i in 0 until 1000)
|
||||||
mesh = sectionPreparer.prepare(section)
|
mesh = sectionPreparer.prepare(section)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Log.log(LogMessageType.OTHER, LogLevels.WARN){"Culling now..."}
|
Log.log(LogMessageType.OTHER, LogLevels.WARN){"Culling now..."}
|
||||||
|
@ -23,38 +23,27 @@ import de.bixilon.minosoft.gui.rendering.util.mesh.MeshStruct
|
|||||||
import glm_.vec2.Vec2
|
import glm_.vec2.Vec2
|
||||||
import glm_.vec3.Vec3
|
import glm_.vec3.Vec3
|
||||||
|
|
||||||
class ChunkSectionMesh(renderWindow: RenderWindow) : Mesh(renderWindow, SectionArrayMeshStruct, PrimitiveTypes.QUAD, initialCacheSize = 100000) {
|
class ChunkSectionMesh(renderWindow: RenderWindow) : Mesh(renderWindow, SectionArrayMeshStruct, PrimitiveTypes.QUAD, initialCacheSize = 200000) {
|
||||||
|
|
||||||
fun addVertex(position: FloatArray, uv: Vec2, texture: AbstractTexture, tintColor: RGBColor?, light: Int) {
|
fun addVertex(position: FloatArray, uv: Vec2, texture: AbstractTexture, tintColor: RGBColor?, light: Int) {
|
||||||
//val texture = renderWindow.WHITE_TEXTURE.texture
|
|
||||||
val textureLayer = if (RenderConstants.FORCE_DEBUG_TEXTURE) {
|
|
||||||
RenderConstants.DEBUG_TEXTURE_ID
|
|
||||||
} else {
|
|
||||||
texture.renderData?.layer ?: RenderConstants.DEBUG_TEXTURE_ID
|
|
||||||
}
|
|
||||||
val transformedUV = texture.renderData?.transformUV(uv) ?: uv
|
val transformedUV = texture.renderData?.transformUV(uv) ?: uv
|
||||||
data.addAll(
|
data.addAll(floatArrayOf(
|
||||||
floatArrayOf(
|
position[0],
|
||||||
position[0],
|
position[1],
|
||||||
position[1],
|
position[2],
|
||||||
position[2],
|
transformedUV.x,
|
||||||
transformedUV.x,
|
transformedUV.y,
|
||||||
transformedUV.y,
|
Float.fromBits(texture.renderData?.shaderTextureId ?: RenderConstants.DEBUG_TEXTURE_ID),
|
||||||
Float.fromBits(textureLayer),
|
Float.fromBits((tintColor?.rgb ?: 0xFFFFFF) or (light shl 24)), // white
|
||||||
Float.fromBits(texture.renderData?.animationData ?: -1),
|
))
|
||||||
Float.fromBits(tintColor?.rgb ?: 0xFFFFFF), // white
|
|
||||||
Float.fromBits(light),
|
|
||||||
))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
data class SectionArrayMeshStruct(
|
data class SectionArrayMeshStruct(
|
||||||
val position: Vec3,
|
val position: Vec3,
|
||||||
val uv: Vec2,
|
val uv: Vec2,
|
||||||
val textureLayer: Int,
|
val indexLayerAnimation: Int,
|
||||||
val animationId: Int,
|
val tintLight: Int,
|
||||||
val tintColor: RGBColor,
|
|
||||||
val light: Int,
|
|
||||||
) {
|
) {
|
||||||
companion object : MeshStruct(SectionArrayMeshStruct::class)
|
companion object : MeshStruct(SectionArrayMeshStruct::class)
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ class GUIMesh(
|
|||||||
data class GUIMeshStruct(
|
data class GUIMeshStruct(
|
||||||
val position: Vec3,
|
val position: Vec3,
|
||||||
val uv: Vec2,
|
val uv: Vec2,
|
||||||
val textureLayer: Int,
|
val indexLayerAnimation: Int,
|
||||||
val tintColor: RGBColor,
|
val tintColor: RGBColor,
|
||||||
) {
|
) {
|
||||||
companion object : MeshStruct(GUIMeshStruct::class)
|
companion object : MeshStruct(GUIMeshStruct::class)
|
||||||
@ -69,7 +69,7 @@ class GUIMesh(
|
|||||||
BASE_Z + Z_MULTIPLIER * z,
|
BASE_Z + Z_MULTIPLIER * z,
|
||||||
uv.x,
|
uv.x,
|
||||||
uv.y,
|
uv.y,
|
||||||
Float.fromBits(texture.renderData?.layer ?: RenderConstants.DEBUG_TEXTURE_ID),
|
Float.fromBits(texture.renderData?.shaderTextureId ?: RenderConstants.DEBUG_TEXTURE_ID),
|
||||||
Float.fromBits(color.rgba),
|
Float.fromBits(color.rgba),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,6 @@ import glm_.vec3.Vec3d
|
|||||||
class ParticleMesh(renderWindow: RenderWindow, initialCacheSize: Int) : Mesh(renderWindow, ParticleMeshStruct, PrimitiveTypes.POINT, initialCacheSize) {
|
class ParticleMesh(renderWindow: RenderWindow, initialCacheSize: Int) : Mesh(renderWindow, ParticleMeshStruct, PrimitiveTypes.POINT, initialCacheSize) {
|
||||||
|
|
||||||
fun addVertex(position: Vec3d, scale: Float, texture: AbstractTexture, tintColor: RGBColor, uvMin: Vec2 = Vec2(0.0f, 0.0f), uvMax: Vec2 = Vec2(1.0f, 1.0f)) {
|
fun addVertex(position: Vec3d, scale: Float, texture: AbstractTexture, tintColor: RGBColor, uvMin: Vec2 = Vec2(0.0f, 0.0f), uvMax: Vec2 = Vec2(1.0f, 1.0f)) {
|
||||||
val textureLayer = if (RenderConstants.FORCE_DEBUG_TEXTURE) {
|
|
||||||
RenderConstants.DEBUG_TEXTURE_ID
|
|
||||||
} else {
|
|
||||||
texture.renderData?.layer ?: RenderConstants.DEBUG_TEXTURE_ID
|
|
||||||
}
|
|
||||||
|
|
||||||
val minTransformedUV = texture.renderData?.transformUV(uvMin) ?: uvMin
|
val minTransformedUV = texture.renderData?.transformUV(uvMin) ?: uvMin
|
||||||
val maxTransformedUV = texture.renderData?.transformUV(uvMax) ?: uvMax
|
val maxTransformedUV = texture.renderData?.transformUV(uvMax) ?: uvMax
|
||||||
data.addAll(
|
data.addAll(
|
||||||
@ -44,8 +38,7 @@ class ParticleMesh(renderWindow: RenderWindow, initialCacheSize: Int) : Mesh(ren
|
|||||||
minTransformedUV.y,
|
minTransformedUV.y,
|
||||||
maxTransformedUV.x,
|
maxTransformedUV.x,
|
||||||
maxTransformedUV.y,
|
maxTransformedUV.y,
|
||||||
Float.fromBits(textureLayer),
|
Float.fromBits(texture.renderData?.shaderTextureId ?: RenderConstants.DEBUG_TEXTURE_ID),
|
||||||
Float.fromBits(texture.renderData?.animationData ?: -1),
|
|
||||||
scale,
|
scale,
|
||||||
Float.fromBits(tintColor.rgba),
|
Float.fromBits(tintColor.rgba),
|
||||||
))
|
))
|
||||||
@ -56,8 +49,7 @@ class ParticleMesh(renderWindow: RenderWindow, initialCacheSize: Int) : Mesh(ren
|
|||||||
val position: Vec3,
|
val position: Vec3,
|
||||||
val minUVCoordinates: Vec2,
|
val minUVCoordinates: Vec2,
|
||||||
val maxUVCoordinates: Vec2,
|
val maxUVCoordinates: Vec2,
|
||||||
val textureLayer: Int,
|
val indexLayerAnimation: Int,
|
||||||
val animationId: Int,
|
|
||||||
val scale: Float,
|
val scale: Float,
|
||||||
val tintColor: RGBColor,
|
val tintColor: RGBColor,
|
||||||
) {
|
) {
|
||||||
|
@ -16,7 +16,7 @@ package de.bixilon.minosoft.gui.rendering.system.base.texture.texture
|
|||||||
import glm_.vec2.Vec2
|
import glm_.vec2.Vec2
|
||||||
|
|
||||||
interface TextureRenderData {
|
interface TextureRenderData {
|
||||||
val layer: Int
|
val shaderTextureId: Int
|
||||||
val animationData: Int
|
val animationData: Int
|
||||||
|
|
||||||
fun transformUV(end: Vec2): Vec2
|
fun transformUV(end: Vec2): Vec2
|
||||||
|
@ -68,8 +68,8 @@ class OpenGLSpriteAnimator : SpriteAnimator {
|
|||||||
|
|
||||||
val arrayOffset = textureAnimation.texture.renderData!!.animationData * INTS_PER_ANIMATED_TEXTURE
|
val arrayOffset = textureAnimation.texture.renderData!!.animationData * INTS_PER_ANIMATED_TEXTURE
|
||||||
|
|
||||||
uniformBuffer.data[arrayOffset] = currentFrame.texture.renderData!!.layer
|
uniformBuffer.data[arrayOffset] = currentFrame.texture.renderData!!.shaderTextureId
|
||||||
uniformBuffer.data[arrayOffset + 1] = nextFrame.texture.renderData!!.layer
|
uniformBuffer.data[arrayOffset + 1] = nextFrame.texture.renderData!!.shaderTextureId
|
||||||
uniformBuffer.data[arrayOffset + 2] = interpolation.toInt()
|
uniformBuffer.data[arrayOffset + 2] = interpolation.toInt()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ class OpenGLTextureData(
|
|||||||
val uvEnd: Vec2?,
|
val uvEnd: Vec2?,
|
||||||
override val animationData: Int = -1,
|
override val animationData: Int = -1,
|
||||||
) : TextureRenderData {
|
) : TextureRenderData {
|
||||||
override val layer: Int = (array shl 24) or (index)
|
override val shaderTextureId: Int = (array shl 28) or (index shl 12) or (animationData + 1)
|
||||||
|
|
||||||
override fun transformUV(end: Vec2): Vec2 {
|
override fun transformUV(end: Vec2): Vec2 {
|
||||||
if (uvEnd == null) {
|
if (uvEnd == null) {
|
||||||
|
@ -23,12 +23,6 @@ import glm_.vec3.Vec3
|
|||||||
open class SimpleTextureMesh(renderWindow: RenderWindow) : Mesh(renderWindow, SimpleTextureMeshStruct, initialCacheSize = 2 * 3 * SimpleTextureMeshStruct.FLOATS_PER_VERTEX) {
|
open class SimpleTextureMesh(renderWindow: RenderWindow) : Mesh(renderWindow, SimpleTextureMeshStruct, initialCacheSize = 2 * 3 * SimpleTextureMeshStruct.FLOATS_PER_VERTEX) {
|
||||||
|
|
||||||
fun addVertex(position: Vec3, texture: AbstractTexture, uv: 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 {
|
|
||||||
texture.renderData?.layer ?: RenderConstants.DEBUG_TEXTURE_ID
|
|
||||||
}
|
|
||||||
|
|
||||||
data.addAll(
|
data.addAll(
|
||||||
floatArrayOf(
|
floatArrayOf(
|
||||||
position.x,
|
position.x,
|
||||||
@ -36,8 +30,7 @@ open class SimpleTextureMesh(renderWindow: RenderWindow) : Mesh(renderWindow, Si
|
|||||||
position.z,
|
position.z,
|
||||||
uv.x,
|
uv.x,
|
||||||
uv.y,
|
uv.y,
|
||||||
Float.fromBits(textureLayer),
|
Float.fromBits(texture.renderData?.shaderTextureId ?: RenderConstants.DEBUG_TEXTURE_ID),
|
||||||
Float.fromBits(tintColor.rgba),
|
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,8 +38,7 @@ open class SimpleTextureMesh(renderWindow: RenderWindow) : Mesh(renderWindow, Si
|
|||||||
data class SimpleTextureMeshStruct(
|
data class SimpleTextureMeshStruct(
|
||||||
val position: Vec3,
|
val position: Vec3,
|
||||||
val uv: Vec2,
|
val uv: Vec2,
|
||||||
val textureLayer: Int,
|
val indexLayerAnimation: Int,
|
||||||
val animationId: Int,
|
|
||||||
) {
|
) {
|
||||||
companion object : MeshStruct(SimpleTextureMeshStruct::class)
|
companion object : MeshStruct(SimpleTextureMeshStruct::class)
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
layout (location = 0) in vec3 vinPosition;
|
layout (location = 0) in vec3 vinPosition;
|
||||||
layout (location = 1) in vec2 vinUV;
|
layout (location = 1) in vec2 vinUV;
|
||||||
layout (location = 2) in uint vinTextureLayer;
|
layout (location = 2) in uint vinIndexLayerAnimation;
|
||||||
layout (location = 3) in uint vinTintColor;
|
layout (location = 3) in uint vinTintColor;
|
||||||
|
|
||||||
flat out uint finTextureIndex;
|
flat out uint finTextureIndex;
|
||||||
@ -26,7 +26,10 @@ out vec4 finTintColor;
|
|||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
gl_Position = vec4(vinPosition.xyz, 1.0f);
|
gl_Position = vec4(vinPosition.xyz, 1.0f);
|
||||||
finTextureCoordinates = vec3(vinUV, vinTextureLayer & 0xFFFFFFu);
|
|
||||||
finTextureIndex = vinTextureLayer >> 24u;
|
// ToDo: Texture animations
|
||||||
|
|
||||||
|
finTextureIndex = vinIndexLayerAnimation >> 28u;
|
||||||
|
finTextureCoordinates = vec3(vinUV, ((vinIndexLayerAnimation >> 12) & 0xFFFFu));
|
||||||
finTintColor = getRGBAColor(vinTintColor);
|
finTintColor = getRGBAColor(vinTintColor);
|
||||||
}
|
}
|
||||||
|
@ -16,11 +16,10 @@
|
|||||||
layout (location = 0) in vec3 vinPosition;
|
layout (location = 0) in vec3 vinPosition;
|
||||||
layout (location = 1) in vec2 vinMinUVCoordinates;
|
layout (location = 1) in vec2 vinMinUVCoordinates;
|
||||||
layout (location = 2) in vec2 vinMaxUVCoordinates;
|
layout (location = 2) in vec2 vinMaxUVCoordinates;
|
||||||
layout (location = 3) in uint vinTextureLayer;
|
layout (location = 3) in uint vinIndexLayerAnimation;
|
||||||
layout (location = 4) in int vinAnimationIndex;
|
|
||||||
|
|
||||||
layout (location = 5) in float vinScale;
|
layout (location = 4) in float vinScale;
|
||||||
layout (location = 6) in uint vinTintColor;
|
layout (location = 5) in uint vinTintColor;
|
||||||
|
|
||||||
|
|
||||||
#include "minosoft:animation"
|
#include "minosoft:animation"
|
||||||
@ -50,24 +49,29 @@ void main() {
|
|||||||
ginVertex.scale = vinScale;
|
ginVertex.scale = vinScale;
|
||||||
ginVertex.tintColor = getRGBAColor(vinTintColor);
|
ginVertex.tintColor = getRGBAColor(vinTintColor);
|
||||||
|
|
||||||
if (vinAnimationIndex == -1) {
|
|
||||||
ginVertex.textureIndex1 = vinTextureLayer >> 24u;
|
uint animationIndex = vinIndexLayerAnimation & 0xFFFu;
|
||||||
ginVertex.textureLayer1 = vinTextureLayer & 0xFFFFFFu;
|
|
||||||
|
if (animationIndex == 0u) {
|
||||||
|
ginVertex.textureIndex1 = vinIndexLayerAnimation >> 28u;
|
||||||
|
ginVertex.textureLayer1 = ((vinIndexLayerAnimation >> 12) & 0xFFFFu);
|
||||||
|
|
||||||
ginVertex.interpolation = 0.0f;
|
ginVertex.interpolation = 0.0f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uvec4 data = uAnimationData[vinAnimationIndex];
|
uvec4 data = uAnimationData[animationIndex -1u];
|
||||||
uint texture1 = data.x;
|
uint texture1 = data.x;
|
||||||
uint texture2 = data.y;
|
uint texture2 = data.y;
|
||||||
uint interpolation = data.z;
|
uint interpolation = data.z;
|
||||||
|
|
||||||
ginVertex.textureIndex1 = texture1 >> 24u;
|
|
||||||
ginVertex.textureLayer1 = texture1 & 0xFFFFFFu;
|
|
||||||
|
|
||||||
ginVertex.textureIndex2 = texture2 >> 24u;
|
|
||||||
ginVertex.textureLayer2 = texture2 & 0xFFFFFFu;
|
ginVertex.textureIndex1 = texture1 >> 28u;
|
||||||
|
ginVertex.textureLayer1 = (texture1 >> 12) & 0xFFFFu;
|
||||||
|
|
||||||
|
ginVertex.textureIndex2 = texture2 >> 28u;
|
||||||
|
ginVertex.textureLayer2 = (texture2 >> 12) & 0xFFFFu;
|
||||||
|
|
||||||
ginVertex.interpolation = interpolation / 100.0f;
|
ginVertex.interpolation = interpolation / 100.0f;
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
layout (location = 0) in vec3 vinPosition;
|
layout (location = 0) in vec3 vinPosition;
|
||||||
layout (location = 1) in vec2 vinUV;
|
layout (location = 1) in vec2 vinUV;
|
||||||
layout (location = 2) in uint vinTextureLayer;
|
layout (location = 2) in uint vinIndexLayerAnimation;
|
||||||
layout (location = 3) in uint vinTintColor;
|
layout (location = 3) in uint vinTintColor;
|
||||||
|
|
||||||
out vec4 finTintColor;
|
out vec4 finTintColor;
|
||||||
@ -29,7 +29,8 @@ uniform mat4 uSkyViewProjectionMatrix;
|
|||||||
void main() {
|
void main() {
|
||||||
gl_Position = (uSkyViewProjectionMatrix * vec4(vinPosition, 1.0f)).xyww - vec4(0.0f, 0.0f, 0.000001f, 0.0f);// prevent face fighting
|
gl_Position = (uSkyViewProjectionMatrix * vec4(vinPosition, 1.0f)).xyww - vec4(0.0f, 0.0f, 0.000001f, 0.0f);// prevent face fighting
|
||||||
|
|
||||||
finTextureCoordinates = vec3(vinUV, vinTextureLayer & 0xFFFFFFu);
|
finTextureIndex = vinIndexLayerAnimation >> 28u;
|
||||||
finTextureIndex = vinTextureLayer >> 24u;
|
finTextureCoordinates = vec3(vinUV, ((vinIndexLayerAnimation >> 12) & 0xFFFFu));
|
||||||
|
|
||||||
finTintColor = getRGBAColor(vinTintColor);
|
finTintColor = getRGBAColor(vinTintColor);
|
||||||
}
|
}
|
||||||
|
@ -15,11 +15,8 @@
|
|||||||
|
|
||||||
layout (location = 0) in vec3 vinPosition;
|
layout (location = 0) in vec3 vinPosition;
|
||||||
layout (location = 1) in vec2 vinUV;
|
layout (location = 1) in vec2 vinUV;
|
||||||
layout (location = 2) in uint vinTextureLayer;
|
layout (location = 2) in uint vinIndexLayerAnimation;// texture index (0xF0000000), texture layer (0x0FFFF000), animation index (0x00000FFF)
|
||||||
|
layout (location = 3) in uint vinTintColorAndLight;// Light (0xFF000000); 3 bytes color (0x00FFFFFF)
|
||||||
layout (location = 3) in int vinAnimationIndex;
|
|
||||||
layout (location = 4) in uint vinTintColor;
|
|
||||||
layout (location = 5) in uint vinLight;
|
|
||||||
|
|
||||||
flat out uint finTextureIndex1;
|
flat out uint finTextureIndex1;
|
||||||
out vec3 finTextureCoordinates1;
|
out vec3 finTextureCoordinates1;
|
||||||
@ -39,28 +36,27 @@ uniform mat4 uViewProjectionMatrix;
|
|||||||
|
|
||||||
void work() {
|
void work() {
|
||||||
gl_Position = uViewProjectionMatrix * vec4(vinPosition, 1.0f);
|
gl_Position = uViewProjectionMatrix * vec4(vinPosition, 1.0f);
|
||||||
finTintColor = getRGBColor(vinTintColor) * getLight(vinLight);
|
finTintColor = getRGBColor(vinTintColorAndLight & 0xFFFFFFu) * getLight(vinTintColorAndLight >> 24u);
|
||||||
|
|
||||||
|
|
||||||
if (vinAnimationIndex == -1) {
|
uint animationIndex = vinIndexLayerAnimation & 0xFFFu;
|
||||||
finTextureIndex1 = vinTextureLayer >> 24u;
|
if (animationIndex == 0u) {
|
||||||
|
finTextureIndex1 = vinIndexLayerAnimation >> 28u;
|
||||||
finTextureCoordinates1 = vec3(vinUV, (vinTextureLayer & 0xFFFFFFu));
|
finTextureCoordinates1 = vec3(vinUV, ((vinIndexLayerAnimation >> 12) & 0xFFFFu));
|
||||||
|
|
||||||
finInterpolation = 0.0f;
|
finInterpolation = 0.0f;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
uvec4 data = uAnimationData[vinAnimationIndex];
|
uvec4 data = uAnimationData[animationIndex - 1u];
|
||||||
uint firstTexture = data.x;
|
uint texture1 = data.x;
|
||||||
uint secondTexture = data.y;
|
uint texture2 = data.y;
|
||||||
uint interpolation = data.z;
|
uint interpolation = data.z;
|
||||||
|
|
||||||
finTextureIndex1 = firstTexture >> 24u;
|
finTextureIndex1 = texture1 >> 28u;
|
||||||
finTextureCoordinates1 = vec3(vinUV, firstTexture & 0xFFFFFFu);
|
finTextureCoordinates1 = vec3(vinUV, ((texture1 >> 12) & 0xFFFFu));
|
||||||
|
|
||||||
finTextureIndex2 = secondTexture >> 24u;
|
finTextureIndex2 = texture2 >> 28u;
|
||||||
finTextureCoordinates2 = vec3(vinUV, secondTexture & 0xFFFFFFu);
|
finTextureCoordinates2 = vec3(vinUV, ((texture2 >> 12) & 0xFFFFu));
|
||||||
|
|
||||||
finInterpolation = interpolation / 100.0f;
|
finInterpolation = interpolation / 100.0f;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user