AmplifyCreations / AmplifyShaderEditor-Feedback

4 stars 0 forks source link

Bug HDRP - Parallax Occlusion Mapping Node #164

Open Dawie3565 opened 1 year ago

Dawie3565 commented 1 year ago

how to reproduce Parallax Occlusion Mapping Node - Use Curvature option in HDRP

this is first found in HDRP 10x 2020.3.45 api 10.10.1

error undeclared identifier 'unity_LightShadowBias'

refence ase ParallaxOcclusionMappingNode.cs image

Note also see ase action it 163 related to Parallax Occlusion Mapping

recommendation complete rebuild ParallaxOcclusionMappingNode per action item 163

oddoscar commented 5 months ago

This also happens when hooking up a Parallax Occlusion Mapping Node's output to Opacity (See attached image).

Quick hack (that may or may not actually work), that gets rid of the error in Unity 2022.3.18 + Amplify 1.9.2.2:

// ParallaxOcclusionMappingNode.cs (around line 500 in Amplify 1.9.2.2)
    if ( m_useCurvature )
    {
        IOUtils.AddFunctionLine( ref m_functionBody, "#ifdef UNITY_PASS_SHADOWCASTER" );
        IOUtils.AddFunctionLine( ref m_functionBody, "if ( _ShadowBias.x == 0.0 )" );  // <<-- CHANGED!
        IOUtils.AddFunctionLine( ref m_functionBody, "{" );
        IOUtils.AddFunctionLine( ref m_functionBody, "#endif" );
        IOUtils.AddFunctionLine( ref m_functionBody, " \tif ( result.z > 1 )" );
        IOUtils.AddFunctionLine( ref m_functionBody, " \t \tclip( -1 );" );
        IOUtils.AddFunctionLine( ref m_functionBody, "#ifdef UNITY_PASS_SHADOWCASTER" );
        IOUtils.AddFunctionLine( ref m_functionBody, "}" );
        IOUtils.AddFunctionLine( ref m_functionBody, "#endif" );
    }

    if ( m_clipEnds )
    {
        IOUtils.AddFunctionLine( ref m_functionBody, "result.xy = uvs.xy + finalTexOffset;" );
        IOUtils.AddFunctionLine( ref m_functionBody, "#ifdef UNITY_PASS_SHADOWCASTER" );
        IOUtils.AddFunctionLine( ref m_functionBody, "if ( _ShadowBias.x == 0.0 )" );  // <<-- CHANGED!
        IOUtils.AddFunctionLine( ref m_functionBody, "{" );
        IOUtils.AddFunctionLine( ref m_functionBody, "#endif" );
        IOUtils.AddFunctionLine( ref m_functionBody, " \tif ( result.x < 0 )" );

Two lines of code were changed (marked). I'm assuming _ShadowBias.x is the same as unity_LightShadowBias.z, but I don't know.

(I believe _ShadowBias is declared in com.unity.render-pipelines.universal@14.0.10\ShaderLibrary\Shadows.hlsl as float4 _ShadowBias; // x: depth bias, y: normal bias ?)


image

Dawie3565 commented 5 months ago

@diogovtx for info only i believe the original unity_LightShadowBias comes from BIRP UnityShaderVariables.cginc