Search Unity

Unique shadows broken in 5.6

Discussion in 'General Graphics' started by Zomby138, Apr 22, 2017.

  1. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    The blacksmith character shadows are once again broken in the new version of Unity.

    https://www.assetstore.unity3d.com/en/#!/content/39921

    It now gives the following error:

    Shader error in 'aShader': invalid subscript '_ShadowCoord' 'UnityComputeForwardShadows': no matching 3 parameter function at line 230 (on d3d11)

    Compiling Vertex program with DIRECTIONAL SHADOWS_SCREEN UNIQUE_SHADOW
    Platform defines: UNITY_ENABLE_REFLECTION_BUFFERS UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP


    When this asset pack was broken in 5.5, a fix was created as seen in this thread:
    https://forum.unity3d.com/threads/unique-shadows-are-broken-in-5-5.431550/

    I hope fixes like this will continue to be released.

    @torbjorn @LeonhardP any word?
     
  2. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    @Swagmiral I saw that you were talking about this on the store page.

    I'm sure there are more people who use this asset, but right now it sort of feels like it's just me.

    Has anyone heard anything?
     
  3. monkeymonkey

    monkeymonkey

    Joined:
    Mar 17, 2015
    Posts:
    5
    zer0w0 and ksam2 like this.
  4. monkeymonkey

    monkeymonkey

    Joined:
    Mar 17, 2015
    Posts:
    5
    yes,just unity5.6.2f1
     
  5. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    I look forward to trying this tonight!
     
  6. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    Do you have an example of how to use this with a custom surface shader? The only custom shader you have is a fragment shader.

    In the old version I just had to add:

    #pragma multi_compile _ UNIQUE_SHADOW UNIQUE_SHADOW_LIGHT_COOKIE
    #include "UniqueShadow_ShadowSample.cginc"

    And it worked.

    Now I can't seem to get it working :\
     
  7. Luckymouse

    Luckymouse

    Joined:
    Jan 31, 2010
    Posts:
    484
    To fix the error: Shader error in 'aShader': invalid subscript '_ShadowCoord' 'UnityComputeForwardShadows' for current latest version 5.5. at the asset store.

    Since version 5.6 unity changed the macro name with prefix UNITY, so it won't match the 5.5 macro name. That is the reason the error occurs.

    Here is the solution:
    1) Open the UniqueShadow_ShadowSample.cginc file.
    2) Replace the following code at very bottom of the file:
    Code (CSharp):
    1. #if defined(UNITY_PASS_FORWARDBASE) || defined(UNITY_PASS_FORWARDADD) || defined(UNIQUE_SHADOW_FORCE_REPLACE_BUILTIN)
    2. #if UNITY_VERSION >= 560
    3.     #undef UNITY_SHADOW_COORDS
    4.     #undef UNITY_TRANSFER_SHADOW
    5.     #undef UNITY_SHADOW_ATTENUATION
    6.     #define UNITY_SHADOW_COORDS(i)                    UNIQUE_SHADOW_INTERP(i)
    7.     #define UNITY_TRANSFER_SHADOW(i,coord)            o.uniqueShadowPos = mul(u_UniqueShadowMatrix, float4(worldPos.xyz, 1.f));
    8.     #define UNITY_SHADOW_ATTENUATION(i, worldPos)    UNIQUE_SHADOW_SAMPLE(i);
    9. #else
    10.     #undef SHADOW_COORDS
    11.     #undef TRANSFER_SHADOW
    12.     #undef SHADOW_ATTENUATION
    13.     #define SHADOW_COORDS(i)                    UNIQUE_SHADOW_INTERP(i)
    14.     #define TRANSFER_SHADOW                        o.uniqueShadowPos = mul(u_UniqueShadowMatrix, float4(worldPos.xyz, 1.f));
    15.     #define SHADOW_ATTENUATION(i)                UNIQUE_SHADOW_SAMPLE(i);
    16. #endif
    17. #endif
    3) Reimport the Volund_StandardCharacterSpecularSurface shader or any your custom shader that has the Unique shadow feature with it.


    The original macro should work on other surface shader again:
    Code (csharp):
    1.         // Volund additional variants
    2.         #pragma multi_compile _ UNIQUE_SHADOW UNIQUE_SHADOW_LIGHT_COOKIE
    3.        
    4.         // Include unique shadow functions
    5.         #include "../UniqueShadow/UniqueShadow_ShadowSample.cginc"
    Note: make sure you got the right path for UniqueShadow_ShadowSample.cginc.

    I tested, It works with version 2017.2 as well.
     
    Last edited: Nov 27, 2017
    ksam2, nirvanajie and Zomby138 like this.
  8. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
  9. invadererik

    invadererik

    Joined:
    Oct 31, 2010
    Posts:
    148
    @Luckymouse & @Zomby138 any idea why I get :

    Assertion failed: GfxFramebufferGLES: An active RenderTargetSetup has dangling pointers.

    ( I'm on a mac, 2017.2.0f3) does this only work on windows ?
     
    Last edited: Dec 14, 2017
  10. Zomby138

    Zomby138

    Joined:
    Nov 3, 2009
    Posts:
    659
    I'm still using 5.6, sorry :\
     
  11. kkkjerry

    kkkjerry

    Joined:
    Dec 24, 2017
    Posts:
    1
    It only work on surface shader, how can i make it work on custom vertex-fragment shader ?
     
  12. Tega-dumuje

    Tega-dumuje

    Joined:
    Mar 23, 2016
    Posts:
    3
    hi guys is it possible to make unique shadows work in unity 2018 or 2019 pls any suggestion wil be apreciated
     
  13. IanItor

    IanItor

    Joined:
    Dec 21, 2017
    Posts:
    12
    It works in 2018.4. Import package from assetstore. Then replace files https://github.com/unity3d-kr/UniqueShadow
    Don't change lines manually, it's already working. Even in custom shaders, just need to include those:

    #pragma multi_compile _ UNIQUE_SHADOW UNIQUE_SHADOW_LIGHT_COOKIE
    #include "../UniqueShadow/UniqueShadow_ShadowSample.cginc"