Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Suggenstion for HDRP #721

Open
sseiichi opened this issue Mar 23, 2024 · 0 comments
Open

Fix Suggenstion for HDRP #721

sseiichi opened this issue Mar 23, 2024 · 0 comments

Comments

@sseiichi
Copy link

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:

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:

void SampleSceneColor_float(float2 uv, float lod, out float3 color)
{
#define REQUIRE_OPAQUE_TEXTURE // seems we need to define this ourselves? HDSceneColorNode does that as well
#if defined(USE_CAMERA_OPAQUE)
color = SAMPLE_TEXTURE2D_X_LOD(_CameraOpaqueTexture, sampler_CameraOpaqueTexture, UnityStereoTransformScreenSpaceTex(uv), lod).rgb;
// color = Sample4Tap(uv, lod); // TODO higher quality refraction
#else
// For HDRP, from HDSceneColorNode
#if defined(REQUIRE_OPAQUE_TEXTURE) && defined(_SURFACE_TYPE_TRANSPARENT) && defined(SHADERPASS) && (SHADERPASS != SHADERPASS_LIGHT_TRANSPORT) && (SHADERPASS != SHADERPASS_PATH_TRACING) && (SHADERPASS != SHADERPASS_RAYTRACING_VISIBILITY) && (SHADERPASS != SHADERPASS_RAYTRACING_FORWARD)
color = SampleCameraColor(uv, lod) * 1.0; // GetInverseCurrentExposureMultiplier()
#else
color = float3(0.0, 0.0, 0.0);
#endif
#endif
}
void SampleSceneColor_half(float2 uv, float lod, out float3 color)
{
SampleSceneColor_float(uv, lod, color);
}

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.

@sseiichi sseiichi changed the title Fix Proposal for HDRP Fix Suggenstion for HDRP Apr 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant