#Shadow Distance issue

1 messages · Page 1 of 1 (latest)

amber yarrow
#

Hey guys, I need some help. I've been trying to fix it myself but to no avail. I am using URP with Forward+ rendering with UniversalRenderPipelineAsset customPipeline, and when the game first launches with customPipeline.shadowDistance set to 0 - the lights start flickering.

Increasing it to above 0 and then lowering it back to 0 fixes the issue, but it must be performed manually, since for some reason the coroutines refuse to work :/

The question is - how can I disable shadows in a better way so the lights won't flicker?

compact plinth
#

There's a separate toggle for disabling shadows
If you only want shadows gone then you won't additionally need to change the urp asset from scripts, but if you do you have to be aware when you're modifying an instance of an urp asset, and if it the instance is actually in use, as you can't modify the original assets

#

At least not very persistently

amber yarrow
#

I am sorry, but I'm struggling to read this

compact plinth
#

So what is the point of settings shadow distance to 0 with coroutines

compact plinth
#

It'd still render the shadow passes but with a distance that doesn't make sense

amber yarrow
#

if the distance set to 0

#

no pixels are being drawn

compact plinth
# amber yarrow there wouldn't be any passes, why would they be rendered

The toggle determines if the shadowcaster pass is rendered or not
When the rendering of the pass is started the system doesn't know whether it should've been skipped to begin with due to there being nothing to render
After that objects' shaders will do the extra step of applying shadow attenuation, as they won't know that it will always return the same value

amber yarrow
#

okay, and I can disable cast shadows from within the script? or do I have to make a whole pipeline for that?

compact plinth
#

Or so I believe based on my experience, I don't know with certainty if there's a check in the system to disable shadows with a 0 shadow distance, or if URP swaps to shadowless shader variants outside the shadow distance
But I haven't seen those occurring and I don't think you'd be having your issue if that was the case

amber yarrow
#

well it feels like it does, since when i first boot the scene - the shadows are all broken with shadow distance set to 0

compact plinth
#

"Broken"?

amber yarrow
#

and then it fixes itself after setting it to higher value and then back

amber yarrow
#

but such thing doesn't happen with shadow distance above 0 and when player manually sets them to 0 while in the scene

compact plinth
#

That sounds like it's trying to render shadows but getting garbage values for the shadow attenuation
Which makes sense because distance functions break with null values

amber yarrow
#

thats why i thought that i could just delay the applicaiton of the shadow distance setting by a bit so that it can render shadows properly and then apply the distance values

#

but coroutines are not great for that

compact plinth
#

doc and urp source file specifically for 6.3. so if you're using a different version you may need to swap those pages' versions too

amber yarrow
#

alright ill take a look