Compile error in shader in Unity 2020.2.3 but not in Unity 2019.2.17

I’ve written a few shaders which were working perfectly with Unity 2019.2.17.
When I upgrade to Unity 2020.2.3 they throw some errors and a lot of warnings.

The errors and warnings made no real sense, and in the end I’ve fixed one warning which fixed all the other warnings and errors.
It was this warning:

It was located on that line of code (please look at the right end of the line, the problem lies there…):

// ************************************************************************************************************************************************ \\

Yes, I know that it’s only a comment (I use that in a pattern to separate functions) and that it should work perfectly fine, yet it generates a warning.

I had hundreds of these warnings, and they generated other warnings and errors (I guess that at some point Unity simply stopped reading the code).

The fix was to replace my pattern with:

// ************************************************************************************************************************************************

We added a new preprocessor for shaders in 2020.2. It is more strict than what was used before.
This pattern is not “just a comment”. Those trailing backslashes tell the preprocessor that the current line continues on the next line. The next line becomes part of the comment.

Thank you for the explanation.

You may want to change the error message, as it doesn’t explain that at all:

This warning is about something different, and shouldn’t explain this :slight_smile:
It just says that there shouldn’t be any spaces between the backslash and the new line, and it just happened that your code had it.

No, my code had no space character between the last '' and the new line.
It probably doesn’t like the CR-LF and consider that CR is a space character.

Now that I know that ‘\’ is used to append the next line I won’t have any problem with it again, but other people may face the same warning and struggle to find out the root of the problem.

Perhaps, I’ll check.

Well, this is just correct preprocessor behaviour :slight_smile:

Correct preprocessor behavior is great, but like Gladyon says, now I’m having this problem and I have no clue what to do with it. :slight_smile:

@Hexane what exactly is the error you see?

@aleksandrk

I get this warning in the Console constantly that keeps polluting the logs:

Shader warning in ‘[BrickBreak_vfx] [Burst] OutputUpdate’: Extra space between '' and newline. at VFXCommon.hlsl(204)

When I click the generated file it points to, the inspector says this:

[Brick Break_vfx] [Burst] Output Update (Compute Shader)
CSMain Directo3D11
Preprocess only [false]
Errors (6)
Extra space between '' and newline. … 26 VFXCommon.hlsl:202
Extra space between '' and newline. at kernel CS Main … 26 VFXCommon.hlsl:202
Extra space between '' and newline. … 26 VFXCommon.hlsl:203
Extra space between '' and newline. at kernel CS Main … 26 VFXCommon.hlsl:203
Extra space between '' and newline. … 26 VFXCommon.hlsl:204
Extra space between '' and newline. at kernel CS Main … 26 VFXCommon.hlsl:204

When I click “Show compiled code” and go to line 26 it says:

25: if_nz r0.y
26: …ishl r0.y, r1.x, l(8)
27: …ld_raw_indexable(raw_buffer)(mixed,mixed,mixed,mixed) r0.yzw, r0.y, t0.xxyz

(Added periods to show indent)

There’s no '' anywhere. This is a project that I’ve upgraded from a previous version to version 2021/2022. I’ve also recompiled all of my VFX Graph scripts but it keeps happening. I’m now using 2022.2.18.

1 Like

Please check VFXCommon.hlsl line 26

Ah, duh, it didn’t occur to me that VFXCommon.hlsl would be its own file. I found it under “Library/PackageCache/com.unity.render-pipelines.universal@14.0.7/Runtime/VFXGraph/Shaders/VFXCommon.hlsl”

#if defined(_GBUFFER_NORMALS_OCT)
#define VFXComputePixelOutputToNormalBuffer(i,normalWS,uvData,outNormalBuffer) \
{ \
    float2 octNormalWS = PackNormalOctQuadEncode(normalWS); \          // values between [-1, +1], must use fp32 on some platforms
    float2 remappedOctNormalWS = saturate(octNormalWS * 0.5 + 0.5); \  // values between [ 0,  1]
    half3 packedNormalWS = PackFloat2To888(remappedOctNormalWS); \     // values between [ 0,  1]
    outNormalBuffer = float4(packedNormalWS, 0.0); \
}
#else
#define VFXComputePixelOutputToNormalBuffer(i,normalWS,uvData,outNormalBuffer) \
{ \
    outNormalBuffer = float4(normalWS, 0.0); \
}
#endif

I edited the file but Unity keeps regenerating the file as-is. I also reinstalled the com.unity.render-pipelines.universal@14.0.7 package but it keeps happening (and broke all my Shader Graph materials in the process ). I wonder if it’s something else on my end?

1 Like

No. I would suggest reporting this as a bug since it’s Unity code.

Will look into it, thank you so much!

1 Like

I can also confirm this is happening. It’s just a warning, but it is annoying.

It started happening to me after I’ve updated the URP package from:

  • “com.unity.render-pipelines.universal”: “12.1.10”,
  • “com.unity.render-pipelines.universal”: “14.0.7”,
1 Like

Same here, same update of the Visual Effect Graph (and URP) package to 14.0.7.

Same issue.

Outside of the already-identified problem in the source with the " " in the last lines of VFX Common in com.unity.render-pipelines.universal@14.0.7, when changing the Output Quad settings you can find that the Additive and Opaque mixing options don’t trigger the warnings while Alpha and Alpha Premultiplied do.

I guess you could change to Additive and modify the colors a bit in certain use cases, if the warnings are the greater evil.

Same issue here…with update to Unity LTS 2022.3.0 (and hence Shader Graph 14.0.7)…

same issue on 2022.2.20f1 and visual effect graph 14.0.7

Did anyone file a bug report?

Looks like someone filed a bug for it some time ago.

1 Like