Division-by-zero in ComputeSafeOrthonormals on heavy zoom out

Ben Gamari

New Member
Feb 26, 2026
2
3

Game Version

2026.2.38.3713

Operating System

Linux

What Happened​

In map view I inadvertently zoomed out heavily instead of in (the entire solar system was easily in view). This resulted in the following crash:
Code:
18:16:18 ERROR Unhandled exception System.DivideByZeroException: Attempted to divide by zero.
   at KSA.Rendering.Lighting.ShadowUtils.ComputeSafeOrthonormals(float3 inDir, float3& outRight, float3& outUp)
   at KSA.Rendering.Lighting.CascadedShadowSystem.ComputeCascadeViewProj(float4x4& outView, float4x4& outProj, Single& outInvDepthRange, float3& outCascadeSizeWs, Camera inCamera, float3 inLightDir, Int32 shadowMapSize, Single inNear, Single inFar, Boolean stabilize, Single depthPadding, Single overlapTexels)
   at KSA.Rendering.Lighting.CascadedShadowSystem.UpdateUniforms(Camera& inCamera, float3 inSunPos, Int32 inFrameIndex)
   at KSA.Program.UpdateRenderingResources(Int32 frameIndex)
   at KSA.Program.OnFrame(Double currentPlayerTime, Double dtPlayer)
   at KSA.App.Run()
   at KSA.Program.Main(String[] inArgs).
Unhandled exception. System.DivideByZeroException: Attempted to divide by zero.
   at KSA.Rendering.Lighting.ShadowUtils.ComputeSafeOrthonormals(float3 inDir, float3& outRight, float3& outUp)
   at KSA.Rendering.Lighting.CascadedShadowSystem.ComputeCascadeViewProj(float4x4& outView, float4x4& outProj, Single& outInvDepthRange, float3& outCascadeSizeWs, Camera inCamera, float3 inLightDir, Int32 shadowMapSize, Single inNear, Single inFar, Boolean stabilize, Single depthPadding, Single overlapTexels)
   at KSA.Rendering.Lighting.CascadedShadowSystem.UpdateUniforms(Camera& inCamera, float3 inSunPos, Int32 inFrameIndex)
   at KSA.Program.UpdateRenderingResources(Int32 frameIndex)
   at KSA.Program.OnFrame(Double currentPlayerTime, Double dtPlayer)
   at KSA.App.Run()
   at KSA.Program.Main(String[] inArgs)

What Was Expected​

It not crash. :)

Reproduction Steps​

I have struggled to reproduce the crash. My vehicle was in space approaching the SoI of Saturn. Hopefully just auditing the function in question will reveal to culprit division operation.

Reproduction Rate​

once

Additional Info​

  • Video/Screenshots: [Link or attach files]
  • Save File: [Attached/Link to save file if relevant]
  • Other Notes: [Any other relevant details]
 
  • Like
Reactions: Akavis
Upvote 1
Also on 2026.2.38.3713 but on Windows 11 I get a similar issue.

Zooming out far enough in map view does crash the game. I don't get any errors in the log though, the game just closes and that's it.
 
A little more tinkering and I managed to induce the error message!

00:21:08.604 INFO set map camera to azimuth 2.88, elevation 0.47, distancePower 100000000000000.00
00:21:08.604 INFO set camera mode to 'Map'
00:21:14.026 INFO set map camera to azimuth 2.88, elevation 0.47, distancePower 100000000000000000.00
00:21:14.026 INFO set camera mode to 'Map'
00:21:17.452 INFO set map camera to azimuth 2.88, elevation 0.47, distancePower 1000000000000000000.00
00:21:17.452 INFO set camera mode to 'Map'
00:21:20.161 INFO set map camera to azimuth 2.88, elevation 0.47, distancePower 10000000000000000000.00
00:21:20.161 INFO set camera mode to 'Map'
00:21:22.578 INFO set map camera to azimuth 2.88, elevation 0.47, distancePower 100000000000000000000.00
00:21:22.578 INFO set camera mode to 'Map'
00:21:22.592 ERROR Unhandled exception System.DivideByZeroException: Attempted to divide by zero.
at KSA.Rendering.Lighting.ShadowUtils.ComputeSafeOrthonormals(float3 inDir, float3& outRight, float3& outUp)
at KSA.Rendering.Lighting.CascadedShadowSystem.ComputeCascadeViewProj(float4x4& outView, float4x4& outProj, Single& outInvDepthRange, float3& outCascadeSizeWs, Camera inCamera, float3 inLightDir, Int32 shadowMapSize, Single inNear, Single inFar, Boolean stabilize, Single depthPadding, Single overlapTexels)
at KSA.Rendering.Lighting.CascadedShadowSystem.UpdateUniforms(Camera& inCamera, float3 inSunPos, Int32 inFrameIndex)
at KSA.Program.UpdateRenderingResources(Int32 frameIndex)
at KSA.Program.OnFrame(Double currentPlayerTime, Double dtPlayer)
at KSA.App.Run()
at KSA.Program.Main(String[] inArgs).
00:21:23.592 INFO Last chance dump: timed out.

I used the camera command to have a bit more control and see if it was a digits issue. We seem to top out around 20.

The crash will also occur if camera is used past its breaking point without actually being in the map view, like being in the normal orbit view.