Search Unity

Resolved Shader in 2020.2 completely black, but no errors given

Discussion in 'Shaders' started by carcasanchez, Dec 18, 2020.

  1. carcasanchez

    carcasanchez

    Joined:
    Jul 15, 2018
    Posts:
    177
    As the title says, I have updated my project from 2019 to 2020.2. All good and smooth, but a specific shader now is just plain black. It was a surface shader with a simple billboard function.
    The strange part is that no errors are given in the console about the shader not compiling or something similar.
    The only thing that pops up is a warning, but seems rather intrascendental:
    upload_2020-12-18_17-4-46.png
    Has anyone experienced something like this?
     
  2. carcasanchez

    carcasanchez

    Joined:
    Jul 15, 2018
    Posts:
    177
    Update: I have detected some strange behaviours when changing shader code.
    Specifically, with a .cginc that holds utility functions.
    If I comment that include, and hardcode the Output color to, say, yellow, everything goes as expected, quad turns yellow.
    But the moment I add that include (again, it's a file that in previous Unity versions worked without issues), the quad turns black. Just by including it, without calling any functionality.
    And the strange part is that no errors are given on console, and the shader seems to compile properly.
    My theory is that something in that include file is not working good after updating, but the silence on the console is driving me crazy.
    Has anyone any idea of what is happening?
    EDIT: yes, I have reimported the files, and rebooting the engine
     
  3. carcasanchez

    carcasanchez

    Joined:
    Jul 15, 2018
    Posts:
    177
    SOLVED!
    Turns out the culprit was an auto-generated snippet from previous Unity versions. The line said:
    Code (CSharp):
    1. // Upgrade NOTE: excluded shader from DX11, OpenGL ES 2.0 because it uses unsized arrays
    2. #pragma exclude_renderers d3d11 gles
    Removing it made the shader compile again.