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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

URP Lit Shader error

Discussion in 'Universal Render Pipeline' started by ryanm798, Jul 23, 2021.

  1. ryanm798

    ryanm798

    Joined:
    Sep 14, 2019
    Posts:
    2
    Upon importing the Universal RP package into my project (Unity 2020.3.12f1, and URP 10.5.1), when I navigate to the URP Lit shader in my project directory (Packages > Universal RP > Shaders > Lit) and select it, I see that it has 2 errors, both about not being able to open include file 'LitInput.hlsl', which I can see is there in the same URP shaders folder. I tried removing and reinstalling the package and the error persists. I pasted the exact error text from the first error below:

    Couldn't open include file 'Packages/com.unity.render-pipelines.universal/Shaders/LitInput.hlsl'.
    Compiling Fragment program with _ADDITIONAL_LIGHTS _NORMALMAP _METALLICSPECGLOSSMAP _SPECULAR_SETUP
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_FULL_HDR
    Disabled keywords: _MAIN_LIGHT_SHADOWS _MAIN_LIGHT_SHADOWS_CASCADE _ADDITIONAL_LIGHTS_VERTEX _ADDITIONAL_LIGHT_SHADOWS _SHADOWS_SOFT _SCREEN_SPACE_OCCLUSION LIGHTMAP_SHADOW_MIXING SHADOWS_SHADOWMASK DIRLIGHTMAP_COMBINED LIGHTMAP_ON DOTS_INSTANCING_ON FOG_LINEAR FOG_EXP FOG_EXP2 INSTANCING_ON _ALPHATEST_ON _ALPHAPREMULTIPLY_ON _EMISSION _SMOOTHNESS_TEXTURE_ALBEDO_CHANNEL_A _OCCLUSIONMAP _PARALLAXMAP _DETAIL_MULX2 _DETAIL_SCALED _SPECULARHIGHLIGHTS_OFF _ENVIRONMENTREFLECTIONS_OFF _RECEIVE_SHADOWS_OFF UNITY_NO_DXT5nm UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_NO_FULL_STANDARD_SHADER UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_HARDWARE_TIER3 UNITY_COLORSPACE_GAMMA UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_RGBM_ENCODING UNITY_VIRTUAL_TEXTURING UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_ASTC_NORMALMAP_ENCODING SHADER_API_GLES30
     
  2. BlackSabin

    BlackSabin

    Joined:
    Feb 27, 2021
    Posts:
    73
    I get the same exact error here. Did the same steps for the most part, as well; I've only recently started messing with shaders and keep seeing this error pop up. It seems to stop the rendering of any of my custom coded shaders too, any workarounds or fixes?
     
  3. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    Are you getting any other errors in the console than this?
     
  4. BlackSabin

    BlackSabin

    Joined:
    Feb 27, 2021
    Posts:
    73
    Just double checked, no other errors show up in console.
     
  5. peterbay

    peterbay

    Unity Technologies

    Joined:
    Nov 2, 2017
    Posts:
    100
    Hmm, weird, let's see if we can figure out the issue :) How did you import it into your project?
     
  6. BlackSabin

    BlackSabin

    Joined:
    Feb 27, 2021
    Posts:
    73
    The Unity package manager. Window > Package Manager > Unity Registry > Universal RP > Install.
     
  7. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,472
    Having the same problem here, only it is on my custom shaders and it also can't open:

    Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl and SurfaceInput.hlsl
     
  8. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,472
    Update, I managed to get these errors to go away by changing the "Override preprocessor" setting to any other setting but "Use Project Settings" and hitting "Apply". I can then change it back to "Use Project Settings" and the issue remains resolved. Problem is, I have to do this with every single custom shader in my project.

    Any idea what is causing this and how to prevent it?
     
    GBudee and yusuf_isik like this.
  9. yusuf_isik

    yusuf_isik

    Joined:
    Feb 14, 2014
    Posts:
    21
    Unity 2020.3.14 has the same issue. Thanks @Brady , you've saved my day.
     
    Whiskas009 and Brady like this.
  10. SWISH93

    SWISH93

    Joined:
    Mar 28, 2022
    Posts:
    24
    @Brady I'm having a similar issue. Where can I find these settings you mentioned in order to fix it?
     
  11. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,472
    You should see this in the inspector when you select the shader in question: upload_2022-4-11_17-30-13.png

    Try changing that setting to "Force Platform Preprocessor" or "Force Caching Preprocessor" , apply, then you can change it back and apply again and the problem should remain fixed.
     
  12. John1515

    John1515

    Joined:
    Nov 29, 2012
    Posts:
    248
    For me the problem was that the project was on dropbox and started syncing while building. By pausing dropbox, it now works for me.

    EDIT: Ah too soon. Somehow it worked a few times, and now I get the same error again. After editing a shader graph it seems. Unity 2022.1 beta
     
    Last edited: Apr 13, 2022
  13. tompainter

    tompainter

    Joined:
    Oct 10, 2017
    Posts:
    7
    I get similar errors
    upload_2022-4-19_20-32-12.png

    @Brady if I go here, then if I select that shader, the override dropdown is greyed out
    any ideas?

    upload_2022-4-19_20-37-58.png
     

    Attached Files:

  14. tompainter

    tompainter

    Joined:
    Oct 10, 2017
    Posts:
    7
  15. tompainter

    tompainter

    Joined:
    Oct 10, 2017
    Posts:
    7
    PS, I've followed the 'update your old project' instructions, the project is a year old
     
  16. Brady

    Brady

    Joined:
    Sep 25, 2008
    Posts:
    2,472
    I'm not sure why the inspector would be disabled for the shader like that. Could it be a version control thing perhaps?
     
  17. tompainter

    tompainter

    Joined:
    Oct 10, 2017
    Posts:
    7
    hmm, I've setup my .gitignore like this
    I'm guessing that maybe inside the library folder things are locked and that's where I need to make a change?
    I thought it was maybe bad practice to start hacking all the packages and stuff?
    upload_2022-4-20_23-21-37.png
    upload_2022-4-20_23-22-25.png
     
  18. tompainter

    tompainter

    Joined:
    Oct 10, 2017
    Posts:
    7
    OK so I've been working on my non-URP branch all day, I checked out yesterdays URP branch, and now its working without those errors, even though according to source control nothing changed, weird not really sure what changed maybe a reset of unity?
     
  19. joshuamcsorley

    joshuamcsorley

    Joined:
    Nov 3, 2017
    Posts:
    1
    Interesting, so I had a very similar issue to @tompainter after messing with Baking for a while. I simply restarted Unity and everything just worked as it was 30 minutes ago. I'm not sure what caused the issue but I'm just happy it's fixed and I can keep learning :)
     
  20. MX-Pain

    MX-Pain

    Joined:
    Sep 27, 2020
    Posts:
    49
    Where you able to fix it ?
    I have the same issues on my end for no reason ...
    upload_2022-6-21_8-51-28.png
     
  21. swittk

    swittk

    Joined:
    Mar 15, 2018
    Posts:
    1
    @MX-Pain I had the same exact errors after converting from a non-URP project to URP.
    Managed to solve it by deleting the `Library` folder in the root of the project (with Unity closed). When you re-open Unity it'll re-import its dependencies and that fixed it for me.
     
  22. MX-Pain

    MX-Pain

    Joined:
    Sep 27, 2020
    Posts:
    49
    Thanks a lot. I finnaly get rid of those error messages.
     
  23. KrabbyQ

    KrabbyQ

    Joined:
    Dec 19, 2016
    Posts:
    3
    This works for me too. Thanks!
     
  24. HautEsports

    HautEsports

    Joined:
    Feb 3, 2022
    Posts:
    1
    Thank you guys. I delete the project then build a new project with the same operaiton. The problem disappeearedd:)
     
    ignarmezh likes this.
  25. victorliu233

    victorliu233

    Joined:
    Aug 28, 2022
    Posts:
    5
    Thanks, this really works.
     
  26. M54667656

    M54667656

    Joined:
    Sep 11, 2020
    Posts:
    1

    baby,you are right.thanks~
     
  27. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    467
    I had luck just deleting a couple of things inside the Library folder instead, so I didn't have to reimport all assets:
    Delete Library/ShaderCache/ and Library/ShaderCache.db with Unity Editor closed
     
    the_blow and markoal like this.