Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

2020.2 f1 Shader Compile issue: "Too Few Arguments to a macro call"

Discussion in 'Shaders' started by PhoenixAdvanced, Dec 17, 2020.

  1. PhoenixAdvanced

    PhoenixAdvanced

    Joined:
    Sep 30, 2016
    Posts:
    316
    Hello, I have recently ported my project from Unity 2020.1 to 2020.2 f1, and I am getting the above error in a third party asset. This does not occur in 2020.1.

    The full text of the error is:

    Code (CSharp):
    1. Shader error in 'WeatherMaker/WeatherMakerPrecipitationShader': 'UNITY_SAMPLE_TEX2D_SAMPLER_LOD': Too few arguments to a macro call. at Assets/WeatherMaker/Prefab/Shaders/WeatherMakerCloudShaderInclude.cginc(142)
    This asset, WeatherMaker, is a paid third party asset, but I am hoping that posting just the single line causing the error will be ok:

    Code (CSharp):
    1.     fbm += ((UNITY_SAMPLE_TEX2D_SAMPLER_LOD(noiseTex, _CloudNoise1, float4(RotateUV(noisePos.xz, _CloudNoiseRotation[cloudIndex + 4], _CloudNoiseRotation[cloudIndex]), 0.0, 0.0)).a) * _CloudNoiseMultiplier[cloudIndex].x);
    This issue seems to be identical to this one:

    https://issuetracker.unity3d.com/is...ements-in-macro-arguments-in-unity-2020-dot-2

    Which is marked as fixed in 2020.2, but I am still seeing it.

    Is there are way of fixing, or working around, this issue?

    I am not a "shader guy", but it seems that there is a way to rewrite the above line to avoid the issue, is that possible?

    Thanks for any advice.
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,956
    Ok, I double-checked - the macro expansion happens correctly on this line.
    This line produces 3 arguments for the macro, but I suppose the macro definition requires 4 or more.
    This is an issue with the asset and I would suggest contacting the asset developers for help with this.
     
  3. PhoenixAdvanced

    PhoenixAdvanced

    Joined:
    Sep 30, 2016
    Posts:
    316
    Thanks, I'll do that!
     
    aleksandrk likes this.
  4. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,462
    This is a unity shader macro that was working in 2020.1.10 and suddenly broke in 2020.1.16. Please investigate on your end unity.

    2019.4 latest also works fine.
     
    Last edited: Dec 17, 2020
  5. jjxtra

    jjxtra

    Joined:
    Aug 30, 2013
    Posts:
    1,462
    @PhoenixAdvanced I've refreshed the current weather maker version to hack around this for the newer Unity versions, please try downloading again and let me know if it works.
     
  6. PhoenixAdvanced

    PhoenixAdvanced

    Joined:
    Sep 30, 2016
    Posts:
    316
    Hi,

    I just deleted and reimported weather maker in my project, to make sure I was using a clean, up to date, version (I got the December 17th update), and I still get the same error, in the same file:

    Code (CSharp):
    1. Shader error in 'WeatherMaker/WeatherMakerPrecipitationShader': 'UNITY_SAMPLE_TEX2D_SAMPLER_LOD': Too few arguments to a macro call. at Assets/WeatherMaker/Prefab/Shaders/WeatherMakerCloudShaderInclude.cginc(140)
    2.  
    3. Compiling Vertex program with WEATHER_MAKER_SHADOWS_ONE_CASCADE
    4. Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_HARDWARE_TIER3 UNITY_LIGHTMAP_RGBM_ENCODING
    5. Disabled keywords: WEATHER_MAKER_SHADOWS_SPLIT_SPHERES UNITY_URP INSTANCING_ON ORTHOGRAPHIC_MODE UNITY_NO_DXT5nm UNITY_ENABLE_NATIVE_SHADOW_LOOKUPS UNITY_METAL_SHADOWS_USE_POINT_FILTERING UNITY_NO_SCREENSPACE_SHADOWS UNITY_PBS_USE_BRDF2 UNITY_PBS_USE_BRDF3 UNITY_NO_FULL_STANDARD_SHADER UNITY_HARDWARE_TIER1 UNITY_HARDWARE_TIER2 UNITY_COLORSPACE_GAMMA UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_HALF_PRECISION_FRAGMENT_SHADER_REGISTERS UNITY_LIGHTMAP_DLDR_ENCODING UNITY_LIGHTMAP_FULL_HDR UNITY_VIRTUAL_TEXTURING UNITY_PRETRANSFORM_TO_DISPLAY_ORIENTATION UNITY_ASTC_NORMALMAP_ENCODING SHADER_API_GLES30
    6.  
    7.  
    The Line number is now 140, instead of 142, but the error seems to be the same.
     
  7. Juho_Oravainen

    Juho_Oravainen

    Unity Technologies

    Joined:
    Jun 5, 2014
    Posts:
    42
    Hey!

    I took a dive in this one and turns out it is a mistake in the Weather Maker shader side.
    WeatherMakerCoreShaderInclude.cginc contains this:

    #ifndef UNITY_SAMPLE_TEX2D_SAMPLER_LOD
    #define UNITY_SAMPLE_TEX2D_SAMPLER_LOD(tex, samp, uv) tex.SampleLevel(sampler##samp, uv, 0.0)
    #endif

    Now, UNITY_SAMPLE_TEX2D_SAMPLER_LOD definition did not actually exist in Unity until very recently. So up until now the above user version of this macro has been in use. However, the newly introduced internal definition looks like this:
    #define UNITY_SAMPLE_TEX2D_SAMPLER_LOD(tex, samplertex, coord, lod) tex.SampleLevel (sampler##samplertex, coord, lod)

    This does not match with the Weather Maker version. So now the system grabs the internal one due to #ifndef check there, but the actual usage in the shaders does not have matching arguments and this leads to shader errors.

    Basically the Weather Maker shaders either need to fix their usage of that macro to match with the internal definition, or use their own definition always (avoid the #ifndef check and not use Unity internal macro name)
     
    TimothePAUL likes this.
  8. PhoenixAdvanced

    PhoenixAdvanced

    Joined:
    Sep 30, 2016
    Posts:
    316
    Ah, that makes sense!

    Thanks a lot for looking into that.

    It reminds me of my old C++ days, I would run into similar issues a lot, I guess that's why I don't like shader programming all that much!