The blacksmith character shadows are once again broken in the new version of Unity.
Discover the best assets for game making. Choose from our massive catalog of 2D, 3D models, SDKs, templates, and tools to speed up your game development process.
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:
Hi, Unique Character Shadows https://www.assetstore.unity3d.com/en/#!/content/39921 example project asset is broken in 5.5. The sampling shader gets called and all but the attenuation value it returns seems to be 0 almost everywhere. 5.5 introduced...
Reading time: 1 mins 🕑
Likes: 6 ❤
I hope fixes like this will continue to be released.
@torbjorn @LeonhardP any word?
@LightMagicStudio 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?
Hello sir, I wrote the package just now. you can find it here: GitHub - 807183087/unity3d: unity3d
maybe helpful
2 Likes
I look forward to trying this tonight!
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 :\
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:
Open the UniqueShadow_ShadowSample.cginc file.
Replace the following code at very bottom of the file:
#if defined(UNITY_PASS_FORWARDBASE) || defined(UNITY_PASS_FORWARDADD) || defined(UNIQUE_SHADOW_FORCE_REPLACE_BUILTIN)
#if UNITY_VERSION >= 560
#undef UNITY_SHADOW_COORDS
#undef UNITY_TRANSFER_SHADOW
#undef UNITY_SHADOW_ATTENUATION
#define UNITY_SHADOW_COORDS(i) UNIQUE_SHADOW_INTERP(i)
#define UNITY_TRANSFER_SHADOW(i,coord) o.uniqueShadowPos = mul(u_UniqueShadowMatrix, float4(worldPos.xyz, 1.f));
#define UNITY_SHADOW_ATTENUATION(i, worldPos) UNIQUE_SHADOW_SAMPLE(i);
#else
#undef SHADOW_COORDS
#undef TRANSFER_SHADOW
#undef SHADOW_ATTENUATION
#define SHADOW_COORDS(i) UNIQUE_SHADOW_INTERP(i)
#define TRANSFER_SHADOW o.uniqueShadowPos = mul(u_UniqueShadowMatrix, float4(worldPos.xyz, 1.f));
#define SHADOW_ATTENUATION(i) UNIQUE_SHADOW_SAMPLE(i);
#endif
#endif
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:
// Volund additional variants
#pragma multi_compile _ UNIQUE_SHADOW UNIQUE_SHADOW_LIGHT_COOKIE
// Include unique shadow functions
#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.
3 Likes
@Luckymouse You beautiful man! Thank you so much!
@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 ?
I’m still using 5.6, sorry :\
Luckymouse:
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:
Open the UniqueShadow_ShadowSample.cginc file.
Replace the following code at very bottom of the file:
#if defined(UNITY_PASS_FORWARDBASE) || defined(UNITY_PASS_FORWARDADD) || defined(UNIQUE_SHADOW_FORCE_REPLACE_BUILTIN)
#if UNITY_VERSION >= 560
#undef UNITY_SHADOW_COORDS
#undef UNITY_TRANSFER_SHADOW
#undef UNITY_SHADOW_ATTENUATION
#define UNITY_SHADOW_COORDS(i) UNIQUE_SHADOW_INTERP(i)
#define UNITY_TRANSFER_SHADOW(i,coord) o.uniqueShadowPos = mul(u_UniqueShadowMatrix, float4(worldPos.xyz, 1.f));
#define UNITY_SHADOW_ATTENUATION(i, worldPos) UNIQUE_SHADOW_SAMPLE(i);
#else
#undef SHADOW_COORDS
#undef TRANSFER_SHADOW
#undef SHADOW_ATTENUATION
#define SHADOW_COORDS(i) UNIQUE_SHADOW_INTERP(i)
#define TRANSFER_SHADOW o.uniqueShadowPos = mul(u_UniqueShadowMatrix, float4(worldPos.xyz, 1.f));
#define SHADOW_ATTENUATION(i) UNIQUE_SHADOW_SAMPLE(i);
#endif
#endif
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:
// Volund additional variants
#pragma multi_compile _ UNIQUE_SHADOW UNIQUE_SHADOW_LIGHT_COOKIE
// Include unique shadow functions
#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.
It only work on surface shader, how can i make it work on custom vertex-fragment shader ?
hi guys is it possible to make unique shadows work in unity 2018 or 2019 pls any suggestion wil be apreciated
IanItor
February 13, 2020, 7:15pm
13
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”