mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-19 12:25:12 -04:00
recalculate sun scatter matrix when sky matrix changes
Prevents sun scatter moving with camera
This commit is contained in:
parent
3b9f7172f8
commit
251c257bed
@ -38,9 +38,10 @@ class SunScatterRenderer(
|
||||
private val mesh = SunScatterMesh(sky.renderWindow)
|
||||
private var matrix = Mat4()
|
||||
private var timeUpdate = true
|
||||
private var skyMatrix = Mat4()
|
||||
|
||||
private fun calculateMatrix() {
|
||||
val matrix = Mat4(sky.matrix)
|
||||
private fun calculateMatrix(skyMatrix: Mat4) {
|
||||
val matrix = Mat4(skyMatrix)
|
||||
|
||||
matrix.rotateAssign((sun.calculateAngle() + 90.0f).rad, Vec3(0, 0, 1))
|
||||
|
||||
@ -88,13 +89,17 @@ class SunScatterRenderer(
|
||||
shader.use()
|
||||
if (timeUpdate || weatherLevel > 0.0f) {
|
||||
if (timeUpdate) {
|
||||
calculateMatrix()
|
||||
shader.scatterMatrix = matrix
|
||||
shader.sunPosition = calculateSunPosition()
|
||||
timeUpdate = false
|
||||
}
|
||||
shader.intensity = (1.0f - weatherLevel) * calculateIntensity(sky.time.progress)
|
||||
}
|
||||
val skyMatrix = sky.matrix
|
||||
if (this.skyMatrix !== skyMatrix) {
|
||||
calculateMatrix(skyMatrix)
|
||||
shader.scatterMatrix = matrix
|
||||
this.skyMatrix = skyMatrix
|
||||
}
|
||||
|
||||
sky.renderSystem.enable(RenderingCapabilities.BLENDING)
|
||||
sky.renderSystem.setBlendFunction(
|
||||
|
Loading…
x
Reference in New Issue
Block a user