mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-16 19:05:02 -04:00
particle renderer: remove translucent shader
Its the same shader
This commit is contained in:
parent
77ba81b4b7
commit
df31204dfe
@ -124,7 +124,7 @@ class ParticleRendererTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// TODO: queue, maxAmount, auto ticking
|
// TODO: auto ticking (task registering)
|
||||||
|
|
||||||
private class TestParticle(connection: PlayConnection) : Particle(connection, Vec3d.EMPTY, Vec3d.EMPTY, DATA) {
|
private class TestParticle(connection: PlayConnection) : Particle(connection, Vec3d.EMPTY, Vec3d.EMPTY, DATA) {
|
||||||
var vertices = 0
|
var vertices = 0
|
||||||
|
@ -43,7 +43,6 @@ class ParticleRenderer(
|
|||||||
override val renderSystem: RenderSystem = context.system
|
override val renderSystem: RenderSystem = context.system
|
||||||
private val profile = connection.profiles.particle
|
private val profile = connection.profiles.particle
|
||||||
private val shader = renderSystem.createShader(minosoft("particle")) { ParticleShader(it) }
|
private val shader = renderSystem.createShader(minosoft("particle")) { ParticleShader(it) }
|
||||||
private val translucentShader = renderSystem.createShader(minosoft("particle")) { ParticleShader(it) }
|
|
||||||
|
|
||||||
// There is no opaque mesh because it is simply not needed (every particle has transparency)
|
// There is no opaque mesh because it is simply not needed (every particle has transparency)
|
||||||
var mesh = ParticleMesh(context, BufferedArrayFloatList(profile.maxAmount * ParticleMesh.ParticleMeshStruct.FLOATS_PER_VERTEX))
|
var mesh = ParticleMesh(context, BufferedArrayFloatList(profile.maxAmount * ParticleMesh.ParticleMeshStruct.FLOATS_PER_VERTEX))
|
||||||
@ -81,7 +80,7 @@ class ParticleRenderer(
|
|||||||
|
|
||||||
override fun registerLayers() {
|
override fun registerLayers() {
|
||||||
layers.register(OpaqueLayer, shader, this::drawTransparent)
|
layers.register(OpaqueLayer, shader, this::drawTransparent)
|
||||||
layers.register(TranslucentLayer, translucentShader, this::drawTranslucent)
|
layers.register(TranslucentLayer, shader, this::drawTranslucent)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun loadTextures() {
|
private fun loadTextures() {
|
||||||
@ -107,7 +106,6 @@ class ParticleRenderer(
|
|||||||
|
|
||||||
override fun postInit(latch: AbstractLatch) {
|
override fun postInit(latch: AbstractLatch) {
|
||||||
shader.load()
|
shader.load()
|
||||||
translucentShader.load()
|
|
||||||
ticker.init()
|
ticker.init()
|
||||||
|
|
||||||
connection.world.particle = this
|
connection.world.particle = this
|
||||||
@ -125,21 +123,18 @@ class ParticleRenderer(
|
|||||||
queue += particle
|
queue += particle
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateShaders() {
|
private fun updateShader() {
|
||||||
val matrix = context.camera.matrixHandler.viewProjectionMatrix
|
val matrix = context.camera.matrixHandler.viewProjectionMatrix
|
||||||
val cameraRight = Vec3(matrix[0][0], matrix[1][0], matrix[2][0])
|
val cameraRight = Vec3(matrix[0][0], matrix[1][0], matrix[2][0])
|
||||||
val cameraUp = Vec3(matrix[0][1], matrix[1][1], matrix[2][1])
|
val cameraUp = Vec3(matrix[0][1], matrix[1][1], matrix[2][1])
|
||||||
|
|
||||||
shader.cameraRight = cameraRight
|
shader.cameraRight = cameraRight
|
||||||
shader.cameraUp = cameraUp
|
shader.cameraUp = cameraUp
|
||||||
|
|
||||||
translucentShader.cameraRight = cameraRight
|
|
||||||
translucentShader.cameraUp = cameraUp
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun prePrepareDraw() {
|
override fun prePrepareDraw() {
|
||||||
if (matrixUpdate) {
|
if (matrixUpdate) {
|
||||||
updateShaders()
|
updateShader()
|
||||||
matrixUpdate = false
|
matrixUpdate = false
|
||||||
}
|
}
|
||||||
mesh.unload()
|
mesh.unload()
|
||||||
|
@ -14,15 +14,12 @@
|
|||||||
package de.bixilon.minosoft.gui.rendering.particle
|
package de.bixilon.minosoft.gui.rendering.particle
|
||||||
|
|
||||||
import de.bixilon.kutil.concurrent.schedule.RepeatedTask
|
import de.bixilon.kutil.concurrent.schedule.RepeatedTask
|
||||||
import de.bixilon.kutil.concurrent.schedule.TaskScheduler
|
|
||||||
import de.bixilon.kutil.exception.ExceptionUtil.ignoreAll
|
import de.bixilon.kutil.exception.ExceptionUtil.ignoreAll
|
||||||
import de.bixilon.kutil.observer.DataObserver.Companion.observe
|
|
||||||
import de.bixilon.kutil.time.TimeUtil.millis
|
import de.bixilon.kutil.time.TimeUtil.millis
|
||||||
import de.bixilon.minosoft.data.world.positions.ChunkPosition
|
import de.bixilon.minosoft.data.world.positions.ChunkPosition
|
||||||
import de.bixilon.minosoft.gui.rendering.particle.types.Particle
|
import de.bixilon.minosoft.gui.rendering.particle.types.Particle
|
||||||
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionStates
|
import de.bixilon.minosoft.protocol.network.connection.play.PlayConnectionStates
|
||||||
import de.bixilon.minosoft.protocol.packets.s2c.play.block.chunk.ChunkUtil.isInViewDistance
|
import de.bixilon.minosoft.protocol.packets.s2c.play.block.chunk.ChunkUtil.isInViewDistance
|
||||||
import de.bixilon.minosoft.protocol.protocol.ProtocolDefinition
|
|
||||||
|
|
||||||
class ParticleTicker(val renderer: ParticleRenderer) {
|
class ParticleTicker(val renderer: ParticleRenderer) {
|
||||||
private val particles = renderer.particles
|
private val particles = renderer.particles
|
||||||
@ -85,27 +82,8 @@ class ParticleTicker(val renderer: ParticleRenderer) {
|
|||||||
particles.lock.unlock()
|
particles.lock.unlock()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun unregister() {
|
|
||||||
val task = this.task ?: return
|
|
||||||
TaskScheduler -= task
|
|
||||||
this.task = null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun register() {
|
|
||||||
if (this.task != null) unregister()
|
|
||||||
val task = RepeatedTask(ProtocolDefinition.TICK_TIME, maxDelay = ProtocolDefinition.TICK_TIME / 2) { tick(false) }
|
|
||||||
this.task = task
|
|
||||||
TaskScheduler += task
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
fun init() {
|
fun init() {
|
||||||
context.connection::state.observe(this) {
|
context.connection.ticker += { tick(false) }
|
||||||
unregister()
|
|
||||||
if (it == PlayConnectionStates.PLAYING) {
|
|
||||||
register()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user