#how to prevent light leaking

1 messages · Page 1 of 1 (latest)

opal radish
#

the light source is below the floor and the meshes dont have gap but its leaking

boreal cloud
opal radish
boreal cloud
opal radish
boreal cloud
#

How many lights are we talking and what is the resolution of each (the resolutions corresponding to each level can be changed from the URP asset too iirc)?

opal radish
#

around 30 lol. ive set em all to low but i can see the fps drop already. i didnt get the warning tho. whats the smallest res i can go without ruining the visual

boreal cloud
opal radish
#

yea smallest is 128 but still it ain viable its lagging

opal radish
boreal cloud
# opal radish yea smallest is 128 but still it ain viable its lagging

I would say that the performance hit of shadows rarely come from the resolution alone. Each light with a shadow basically acts as a camera which must render to the shadowmap to update it. As far as I know, URP doesn't do any shadowmap caching, so every shadow caster is updated every frame. The amount of shadow casting lights should usually be kept at minimum

opal radish
#

i managed to reduce the leakin by settin the depth and normal bias to 0

boreal cloud
#

Be careful with that, there is a reason for those options to exist. Without any bias, you probably will see some "shadow acne" appear

opal radish
#

normal bias actually didnt do anything but i put depth bias to 0.1

boreal cloud
# opal radish even with shadows theres still leakin and i closed the gaps

If the floor ends right at the wall, there is a change some light might sneak through especially with the bias which messes with the shadow casting objects when they are rendered to the shadowmap. If the floor extended little bit inside the wall, that could fix the leakage. Overlap usually adds some error margin to the shadowmapping process. Another bit hacky solution would be to use a separate shadow casting object like a thin box inside the floor to block the light if you don't want to go modify the house model itself. To avoid that object being visible (and there's no point rendering that anyways) from some angle, you could set it to render only shadows from the mesh renderer

#

Shadowmapping is a process full of edge cases. Often literally happening at the edges of the objects. Especially flat shaded objects are very prone to issues where light can sneak through places they shouldn't.

opal radish
boreal cloud
# opal radish is there a way to overcome the performance problem?

Other than minimizing the amount of lights that cast shadows there probably aren't many good ways. Making the light radius smaller should have some impact though the size is probably decided by visual preferences, not performance considerations. If the whole building was a one 3D model, splitting it up to a smaller pieces might also help. If it was one piece, basically every light inside the building would hit it and therefore the same building would need to be rendered once for each light sources shadows (maybe even 6 times for point lights, I don't know if that is how they work in URP). The splitting of objects especially is something that is really hard to tell from distance whether it is good or bad for performance to begin with. More objects is generally more draw calls though the SRP batcher in URP makes those very fast

#

First step thought would be to verify it is the shadows that makes your game slow. That should be easy to test by enabling and disabling all shadows and seeing how that affects performance. If it happens to be something else, you are probably doing more harm than good trying to optimize the shadow performance

opal radish
boreal cloud
#

I don't think that affects shadow rendering much

opal radish
#

yea the shadows literally drop fps in half

#

its ok cause i have the wall torches that are the majority and the hanging lights which have the shadows

tidal sapphire
#

For realtime shadowcasting you should prefer spot light instead of point lights, as point lights have to render 6 shadowmaps as opposed to 1

#

Light layers can be used to separate lights between adjactent rooms in stead of shadowscasting

#

Baked shadows would be an ideal solution for performance, if your lighting can be static

opal radish
opal radish
#

update: i managed to do it, it looks good but spot light seem to have a problem with shadows tied to angle, intensity and range. if those three arent set properly it gives crazy weird shadows

tidal sapphire
#

Point lights avoid this by rendering the 90 fov perspective 6 times, once along each axis

tidal sapphire
# opal radish Thanks for the explanation 🙏

It's often worth it to get a bit clever when designing lighting
Like for example I've sometimes used a shadowing spot light that points down, and a shadowless that points up a short distance below to fake the way a hanging lamp's light should bounce back up from the room
Lights can also have cookies which shape the light and can be used to fake some shadows
A point light with a 3D cookie can make it look like a spot light that has an angle over 180 degrees, which is useful with this double light trick
Though these help more with optimization and looks, not specifically with the issue of lights getting from one room to the next
For that I'd still consider light layers and baked lightmap workflow as the most surefire solutions

opal radish
tidal sapphire
opal radish