stride3d / stride

Stride (formerly Xenko), a free and open-source cross-platform C# game engine.
https://stride3d.net
MIT License
6.63k stars 957 forks source link

Point Lights with shadows degrades performance greatly #2501

Closed BlackCurtainStudio closed 3 weeks ago

BlackCurtainStudio commented 3 weeks ago

Release Type: Official Release

Version: 4.2.0.2232 and 4.1.0.1948

Platform(s): Windows

Describe the bug Point Lights, even a single one, with Shadows enabled degrades performance greatly to the point where the game freezes up completely for several seconds when the camera is aimed towards the light source with shadows.

To Reproduce Steps to reproduce the behavior:

  1. Create new project
  2. Add one or more models with higher complexity to the scene
  3. Add at least 1 Point Light
  4. Enable Shadows for the Point Light(s)

Expected behavior No noticeable lag should occur.

tebjan commented 3 weeks ago

This is to be expected, point lights need to render the whole scene 6 times (cube map, for omnidirectional shadow projection) to produce the shadow map. Whenever you can, replace them with a spotlight or disable the shadows.

BlackCurtainStudio commented 3 weeks ago

This is to be expected, point lights need to render the whole scene 6 times (cube map, for omnidirectional shadow projection) to produce the shadow map. Whenever you can, replace them with a spotlight or disable the shadows.

So you mean I can't have a single Point Light with shadows without expecting freezing up the game by lag? Spot Light shadows are also a problem but not as bad.

Eideren commented 3 weeks ago

I can't repro, can you share a scene where you are seeing this performance issueImage

BlackCurtainStudio commented 3 weeks ago

I was able to reproduce it in a clean project but with much less performance degradation and now, somehow, the performance decrease seems to have lifted in my main project after some tinkering. I still don't know the cause, but for now I guess we can assume there's nothing wrong with the Point Lights themselves.