KhronosGroup / KhronosGroup/UnityGLTF

Fix Suggenstion for HDRP

Open
#721 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
C#
Stars
2.2k
Forks
536
PR merge metrics
No merged PRs in 30d

Description

Version 2.10.0-rc displays pink materials with HDRP and Unity 2022.3.12. Below is a suggested fix, and I hope you will find helpful.

In line 3 of PBRHelpers.cginc:
https://github.com/KhronosGroup/UnityGLTF/blob/20b7493dbd6039fe2fd88e7c5a564ab3bd72734d/Runtime/Shaders/ShaderGraph/PBRHelpers.cginc#L3

SHADERGRAPH_PREVIEW must be replaced by another ShaderKeyword used in HDRP, such as SHADERPASS_FORWARD, because it has been removed in the current version of HDRP. Note that SHADERPASS_FORWARD is just an example.
Reference: https://issuetracker.unity3d.com/issues/shadergraph-number-if-shadergraph-preview-in-a-custom-function-node-throws-error

The two functions, SampleSceneColor_float and SampleSceneColor_half, from lines 52 to 72 in PBRHelpers.cginc:
https://github.com/KhronosGroup/UnityGLTF/blob/20b7493dbd6039fe2fd88e7c5a564ab3bd72734d/Runtime/Shaders/ShaderGraph/PBRHelpers.cginc#L52-L72
should be nested out of the conditional #if defined(USE_CAMERA_OPAQUE), as this conditional is not executed when HDRP is enabled.

Additionally, for improved convenience, within the Graph Inspector of PBRGraph.shadergraph, HDRP's Surface Type should be Opaque instead of Transparent and Alpha Clipping should be enabled as it is frequently used in many materials.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with Runtime/Shaders/ShaderGraph/PBRHelpers.cginc, especially the preview conditional and the SampleSceneColor functions described in the issue. Then inspect PBRGraph.shadergraph in Unity 2022.3.12 with HDRP and verify the relevant shader keywords and Graph Inspector settings. Done means HDRP materials no longer render pink, the shader compiles, and the graph uses the requested surface and clipping defaults.

Written by the indexing model from the issue text.

Assessment

Tech stack
csharp, unity
Domain
game-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.