mgsx-dev / gdx-gltf

GLTF 2.0 3D format support and PBR shader implementation for LibGDX
Apache License 2.0
214 stars 50 forks source link

SkyBox exception #129

Closed MonstrousSoftware closed 4 months ago

MonstrousSoftware commented 4 months ago

I see that there was a recent update to the skybox. I now get sporadic exceptions when moving around a lot, maybe after a few minutes of moving and rotating the view. I've not been able to reproduce this in debug mode, so I don't know the offending matrix value. Using LWJGL3 backend. This is with version 2.2.0 and 2.2.1.


Exception in thread "main" java.lang.RuntimeException: non-invertible matrix
    at com.badlogic.gdx.math.Matrix4.inv(Matrix4.java:405)
    at net.mgsx.gltf.scene3d.scene.SceneSkybox.update(SceneSkybox.java:244)
    at net.mgsx.gltf.scene3d.scene.SceneManager.update(SceneManager.java:186)
    at com.monstrous.moonbase.GameView.render(GameView.java:156)
    at com.monstrous.moonbase.GameScreen.render(GameScreen.java:66)
    at com.badlogic.gdx.Game.render(Game.java:48)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Window.update(Lwjgl3Window.java:387)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.loop(Lwjgl3Application.java:193)
    at com.badlogic.gdx.backends.lwjgl3.Lwjgl3Application.<init>(Lwjgl3Application.java:167)
    at com.monstrous.moonbase.lwjgl3.Lwjgl3Launcher.createApplication(Lwjgl3Launcher.java:15)
    at com.monstrous.moonbase.lwjgl3.Lwjgl3Launcher.main(Lwjgl3Launcher.java:11)```
MonstrousSoftware commented 4 months ago

Never mind. It's probably because my camera projection matrix is degenerate. I suspect because I'm setting camera.up to Vector3.Y regardless of the camera direction in order to keep the camera upright. If the player is looking upwards, the matrix could become singular (direction and up being equal) and hence non-invertable.