Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Question Realtime lighting in URP results in flickering shadows not present in BiRP

Discussion in 'General Graphics' started by Reverend-Speed, May 16, 2022.

  1. Reverend-Speed


    Mar 28, 2011
    I'm a fairly experienced Unity gameplay programmer in the middle of building a game which will feature some procedural generation using 3D tiles assembled at runtime (think Tiny Keep etc). I probably won't be able to use any kind of GI as Unity cannot calculate GI on static objects during Runtime (feel free to correct me on this!).

    I've been doing some tests with a test environment inspired by the PS2 game Silent Hill 4: The Room (walking before running), using alternate versions of the project using BiRP and URP. Both projects use the Linear colourspace and deferred pathway.

    This link contains a URP webgl player of the environment, a 360 reference video of the original location and a link to the entire BiRP test project (allowing you to test and inspect the scene in the editor).

    While the lighting in the URP version definitely looks nicer, there's an issue whereby some shadows seem to flick on and off in relation to the camera's position to the shadows while in editor (see attached video in .zip). In the WebGL version (see link above), walls are just randomly covered with blackness.

    Speaking to another Unity developer, they suggested that the issue arose from floating point precision issues, and suggested that I scale the entire project up (by about 4 times). With the project scaled up and the lighting ranges multiplied by 10, I had something that seemed to resemble the original lighting and environment, but didn't feature the flicking shadows - which seems to back up this developers assertion that it's a precision issue.

    Going back to my BiRP version of my realtime lighting project... the lighting quality isn't quite as nice (shadows aren't as nicely blended), but the flickering isn't present. (BiRP on left, URP on right)

    Continuing to create my project at four times the normal scale seems like it's going to cause troubles for physics and a lot of awkward gameplay calculations, especially for large environments (multiple rooms ultimately extending a footprint over 256x256, with maybe 8 floors).

    Is BiRP the best route forward for a procedural environment with linear deferred realtime lighting? Or should I scale everything up by 4? Or is there another solution available? Any assistance or advice appreciated, happy to provide any projects or further information.

    Attached Files: