Search Unity

Resolved Shader not working properly when building

Discussion in 'Shaders' started by DevDunk, Apr 4, 2021.

  1. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    I am using a shader in post-processing for outlines. In the editor it looks great, but when I build the game (to Windows 86-64) it does not work properly. It seems like there is some sort of outlining, but not even close to the way it works in the editor.
    All materials in the scene are using unlit materials if that makes any difference.

    Editor:

    Build:

    The dot in the middle and text are UI elements. The blue object is not apart of the shader.

    Already tried:
    Making an object with a material using the shader
    Putting shaders in the resource folder
    Having shaders under 'always included shaders'
    Having shaders in preloaded shaders
    Changing API to directx11, OpenGLCore, Vulkan

    Using 2019.4.21f1 LTS with the built-in deferred renderer

    Shader: https://pastebin.com/yvjhVJ5k
    Shader from: https://roystan.net/articles/outline-shader.html

    Edit: Looking into the shader guide it seems like it is the normal outline part which isn't working properly.

    Post Processing settings:

    Any ideas what the cause of this might be?
     
    Last edited: Apr 4, 2021
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    Fixed it!
    I had to disable "Optimize Mesh Data" in the Player settings
     
    ROBYER1 likes this.
  3. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    I am also noticing this bug in 2021.2.16f1 on android, a shader works in editor but doesn't show in the build because I am not using it on any models I am using it on the UI canvas it must not search there. I'll file a bug for this and share the case no. back.
     
  4. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    5,060
    Add it to the always includes assets or shaders