Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug URP: Materials/shaders displaying incorrectly on build.

Discussion in 'General Graphics' started by yonicstudios, Aug 7, 2022.

  1. yonicstudios

    yonicstudios

    Joined:
    Jul 15, 2018
    Posts:
    7
    Up until now, making a development build of a game didn't give me any issues, but when I merged (with Plastic SCM) into the main branch a feature to have portals into the game, I started having rendering problems with some materials. The shaders do compile fine, but with a few warnings that may be causing the issue. The lightmaps are fine, but are also not being used correctly.


    However, this only happens in a handful of scenes. Other scenes display them just fine (perhaps because there is a lack of baked lighting?):

    The rendering of the portals aren't much different from this video implementation, but it uses Shader Graph for the portal shader instead of plain HLSL, and they aren't used in the scenes of these screenshots anyway. There doesn't seem to be any changes on the URP settings, either. (Edit: The Project Settings did change the settings asset for scriptable renderer pipeline, but even after reverting it to the previous one it remains broken)

    As for the warnings, there are a few built-in shaders that give out the following warnings:


    But I believe these are not the cause of the problem. Switching to deferred rendering seems to fix this, but for now I'd like to stick with forward rendering. It seems like the position of vertices in world space is being added or multiplied on the materials, but other materials seem to display fine, just the lightmaps being used completely wrong.

    Is there any way to narrow down the issue?
     
  2. yonicstudios

    yonicstudios

    Joined:
    Jul 15, 2018
    Posts:
    7
    I found the way to fix it.
    Apparently, disabling a rendering feature in the settings asset for URP does not cause the shaders to be recompiled without the disabled features (although I only tested it for SSAO). You need to remove it from the list of features.
    It makes me wonder why is there an option to disable it in the first place if it'll break on build.
     
    Keitaro_Ura likes this.