JetBrains / JetBrains/resharper-unity

No completion in shader graph custom functions

Open
#2,463 0 comments 5 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
142
PR merge metrics
No merged PRs in 30d

Description

When writing functions in a separate `hlsl` file and then using them as custom functions in shader graph Rider doesn't see the global properties defined in the graph. Also Rider complains about unresolved symbols for typical unity shader macros like `SAMPLE_TEXTURE2D`.

One way to work around this is to pass all the shader graph properties as parameters to the function but it's annoying and still doesn't solve the problem with the macros.

Steps to reproduce:
- Create a shader graph and add a property - for example `SomeTexture` with type `Texture2D`
- Create a `hlsl` file and write a function in it:
```
void TestFunction_float(out float3 color)
{
color = SAMPLE_TEXTURE2D(_SomeTexture, sampler_SomeTexture, float2(0, 0)).rgb;
}
```
- In the shader graph add a custom function node and set it up to use the file and function created in the previous step
- Connect the custom function node output to the shader base color
- The shader will compile fine but Rider will complain about unresolved symbols for `SAMPLE_TEXTURE2D`, `_SomeTexture` and `sampler_SomeTexture`

I'm using Unity 6000.0.23f1 and Rider 2024.1.2

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue in Unity 6000.0.23f1 and Rider 2024.1.2 using the separate hlsl file, shader graph property, and custom function node described above. Start by tracing Rider's handling of shader graph custom functions and diagnostics; done means global properties and macros such as SAMPLE_TEXTURE2D no longer produce unresolved-symbol warnings.

Written by the indexing model from the issue text.

Assessment

Tech stack
unity
Domain
computer-graphics, devtools
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.