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.
  2. Join us on Dec 8, 2022, between 7 am & 7 pm EST, in the DOTS Dev Blitz Day 2022 - Q&A forum, Discord, and Unity3D Subreddit to learn more about DOTS directly from the Unity Developers.
    Dismiss Notice
  3. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question _MainLightShadowmapTexture uninitalized in additive scene until a shadow is cast

Discussion in 'Shaders' started by chrismarch, Feb 19, 2021.

  1. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    449
    I've got a custom shader that basically URP BakedLit with realtime shadows, and I've noticed that
    MainLightRealtimeShadow (Library/PackageCache/com.unity.render-pipelines.universal@7.5.1/ShaderLibrary/Shadows.hlsl), which samples the shadow map in the title, returns values from previous renders, or maybe just garbage, in an additive scene with no shadow casters. When the first shadow caster is rendered, then the MainLightRealtimeShadow values are fine. So, I can just add a Shadows Only quad to make this seeming optimization headache go away, but it feels like a hack...
    I see the bug in Unity Editor 2019.4.16f1 and builds.