Search Issue Tracker

Won't Fix

Votes

0

Found in [Package]

9.0.0-preview.72

Issue ID

1370153

Regression

Yes

Errors while compiling Shader Graph when two added Node groups have input -1

Package: Shader Graph

-

Reproduction steps:
1. Open the attached project "1370153.zip"
2. Open Scene "Assets/Scenes/SampleScene"
3. Open Shader Subgraph "Assets/Shaders/Subgraphs/simple_two_sided_transmission_light_bug"
4. In the Node Group "1" change the Float value to -1
5. Press Save Asset

Expected result: no compile errors
Actual result: compile errors are thrown

Reproducible with: 9.0.0-preview.72 (2020.2.0b5), 10.7.0 (2020.3.21f1), 12.1.0 (2021.2.0b16), 13.1.0 (2022.1.0a13)
Not reproducible with: 11.0.0 (2021.1.27f1)
Could not test with: 7.7.1 (2019.4.31f1), 8.3.1 (2020.1.17f1) (console errors)

Console errors:
Shader error in 'Shader Graphs/foliage shader': Program 'frag', error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Negate modifier not allowed for operand #5 of opcode #57 (counts are 1-based). at line 58 (on d3d11)
Shader error in 'Shader Graphs/foliage shader': Program 'frag', error X8000: D3D11 Internal Compiler Error: Invalid Bytecode: Negate modifier not allowed for operand #5 of opcode #71 (counts are 1-based). at line 58 (on d3d11)

Note:
- seems to be reproducible only when both Floats in Node Groups 1 and 2 are -1

  1. Resolution Note:

    Unfortunately, this error is coming from a bug in the FXC shader compiler, which we don't have any way to fix.

    Luckily, the bug is easy to work around. Any of these methods work:

    1) use -0.9999 instead of -1 (for lighting calculations the difference shouldn't be detectable)
    2) replace one of the branch nodes with a negate node, to negate the other branch result (i.e. branchB = -branchA)
    3) instead of doing: branch(predicate, x, -1.0 * x) do: branch(predicate, 1.0, -1.0) * x
    4) enable the DXC shader compiler, which does not have this bug (only if you know DXC works on all of your platforms).

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.