Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice
  2. Enter the 2020.2 Beta Sweepstakes for a chance to win an Oculus Quest 2.
    Dismiss Notice

Bug Shader macro with multi-line arguments fails to compile

Discussion in '2020.2 Beta' started by Jasper-Flick, Sep 21, 2020.

  1. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    876
    Shader code like this used to work:

    Code (CSharp):
    1.     return SAMPLE_TEXTURE2D_SHADOW(
    2.         _DirectionalShadowAtlas, SHADOW_SAMPLER, positionSTS
    3.     );
    But in Unity 2020.2.0b2.3094 it fails:

    Code (CSharp):
    1. Shader error in 'Custom RP/Unlit': 'SAMPLE_TEXTURE2D_SHADOW': Too few arguments to a macro call. at Assets/Custom RP/ShaderLibrary/Shadows.hlsl(148)
    A single-line statement does compile:

    Code (CSharp):
    1.     return SAMPLE_TEXTURE2D_SHADOW(_DirectionalShadowAtlas, SHADOW_SAMPLER, positionSTS);
    So the shader parser suddenly can no longer cope with newlines in macro argument lists.

    I don't know when this bug was introduced, but just noticed it when trying something in the 2020.2 beta.

    Submitted a bug report for it, with case ID 1279246.
     
    Last edited: Sep 21, 2020
    Peter77 and MadeFromPolygons like this.
  2. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    876
  3. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    1,662
    Hi!
    Caching preprocessor is used by default starting with 2020.2.0a13 - this is where this got broken. A fix is on its way :)
     
unityunity