mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-14 09:56:37 -04:00
rendering: combine view and projection matrix
This commit is contained in:
parent
498ffd9503
commit
f72c0abae5
@ -139,7 +139,7 @@ class Camera(private val connection: Connection, private var fov: Float) {
|
||||
cameraPosition = cameraPosition + CAMERA_UP_VEC3 * cameraSpeed
|
||||
}
|
||||
if (lastPosition != cameraPosition) {
|
||||
recalculateViewMatrix()
|
||||
recalculateViewProjectionMatrix()
|
||||
sendPositionToServer()
|
||||
}
|
||||
|
||||
@ -150,7 +150,7 @@ class Camera(private val connection: Connection, private var fov: Float) {
|
||||
0f
|
||||
}
|
||||
if (lastZoom != zoom) {
|
||||
recalculateProjectionMatrix()
|
||||
recalculateViewProjectionMatrix()
|
||||
}
|
||||
|
||||
}
|
||||
@ -162,12 +162,12 @@ class Camera(private val connection: Connection, private var fov: Float) {
|
||||
fun screenChangeResizeCallback(screenWidth: Int, screenHeight: Int) {
|
||||
this.screenWidth = screenWidth
|
||||
this.screenHeight = screenHeight
|
||||
recalculateProjectionMatrix()
|
||||
recalculateViewProjectionMatrix()
|
||||
}
|
||||
|
||||
private fun recalculateProjectionMatrix() {
|
||||
private fun recalculateViewProjectionMatrix() {
|
||||
for (shader in shaders) {
|
||||
shader.use().setMat4("projectionMatrix", calculateProjectionMatrix(screenWidth, screenHeight))
|
||||
shader.use().setMat4("viewProjectionMatrix", calculateProjectionMatrix(screenWidth, screenHeight) * calculateViewMatrix())
|
||||
}
|
||||
}
|
||||
|
||||
@ -175,12 +175,6 @@ class Camera(private val connection: Connection, private var fov: Float) {
|
||||
return glm.perspective(glm.radians(fov / (zoom + 1.0f)), screenWidth.toFloat() / screenHeight.toFloat(), 0.2f, 1000f)
|
||||
}
|
||||
|
||||
private fun recalculateViewMatrix() {
|
||||
for (shader in shaders) {
|
||||
shader.use().setMat4("viewMatrix", calculateViewMatrix())
|
||||
}
|
||||
}
|
||||
|
||||
private fun calculateViewMatrix(): Mat4 {
|
||||
return glm.lookAt(cameraPosition, cameraPosition + cameraFront, CAMERA_UP_VEC3)
|
||||
}
|
||||
@ -198,7 +192,7 @@ class Camera(private val connection: Connection, private var fov: Float) {
|
||||
|
||||
cameraRight = cameraFront.cross(CAMERA_UP_VEC3).normalize()
|
||||
cameraUp = cameraRight.cross(cameraFront).normalize()
|
||||
recalculateViewMatrix()
|
||||
recalculateViewProjectionMatrix()
|
||||
sendPositionToServer()
|
||||
}
|
||||
|
||||
|
@ -24,13 +24,12 @@ layout (location = 4) in uint tintColor;
|
||||
out vec3 passTextureCoordinates;
|
||||
out vec4 passTintColor;
|
||||
|
||||
uniform mat4 viewMatrix;
|
||||
uniform mat4 projectionMatrix;
|
||||
uniform mat4 viewProjectionMatrix;
|
||||
uniform int animationTick;
|
||||
|
||||
|
||||
void main() {
|
||||
gl_Position = projectionMatrix * viewMatrix * vec4(inPosition, 1.0f);
|
||||
gl_Position = viewProjectionMatrix * vec4(inPosition, 1.0f);
|
||||
passTintColor = vec4(((tintColor >> 24u) & 0xFFu) / 255.0f, ((tintColor >> 16u) & 0xFFu) / 255.0f, ((tintColor >> 8u) & 0xFFu) / 255.0f, (tintColor & 0xFFu) / 255.0f);
|
||||
|
||||
if (animatedTextureData.y == 1.0f) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user