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

Very unusual shader issue only in build

Discussion in 'Shaders' started by PhoenixAdvanced, Apr 1, 2021.

  1. PhoenixAdvanced

    PhoenixAdvanced

    Joined:
    Sep 30, 2016
    Posts:
    316
    Hi,

    I am having a bizarre issue with a particular shader in my project.

    I am using the DX 11 Grass Shader from Stix games, and I have posted in the relevant thread here:

    https://forum.unity.com/threads/released-directx-11-grass-shader.348258/page-29

    But I am now thinking that the issue is more to do with Unity than with the shader.

    Basically, the issue is that usually, in the build, and very rarely in the editor, there is a lighting/shadow glitch on *Half* of the shader. This is what it looks like in the build:

    https://imgur.com/vI3fMl5

    and here is the exact same scene, with the exact same conditions, in the editor:

    https://imgur.com/UqcKrrp

    You can see that in the first image, there is a noticeable shaded seam along half of the shader.

    The things that confuse me the most about this are that it almost always only occurs in the build, and it only seems to occur when I load my game.

    IE, when the player travels to a location, the grass looks fine, but when I save the game and load it, this occur is present.

    I am completely stumped as to how to fix this.

    I have tried:
    Reimporting the grass shader asset
    Updating the grass shader asset to the latest version
    Recreating my materials from scratch
    Removing all assets from my scene except for a camera, a directional light, and a plane with the grass shader on it (this is what that looks like: https://imgur.com/8Pv07jG)
    Setting my camera to both deferred and forward mode
    Trying both forward and deferred modes for the Dx 11 shader.

    Has anyone seen this issue before,or anything like it? Or is there anything else that I could try to narrow down the issue? Maybe something that I could disable/enable in player settings?

    Thanks!
     
  2. PhoenixAdvanced

    PhoenixAdvanced

    Joined:
    Sep 30, 2016
    Posts:
    316
    I believe I have solved this.

    The issue took some time to track down, but it seems to be related to another shader that I am using in my project for rendering snow on top of the terrain and grass during random snowstorms.

    It seems that I can fix this issue by applying the snow effect and them immediately removing it when the game loads.

    I'm not sure why this works, I assume that the issue is caused by the snow shader not being properly loaded before a snowstorm occurs in the game, and applying and removing the shader causes it to be fully loaded?