UnityFurURP
UnityFurURP copied to clipboard
No shadows
Is there a way to get shadows showing on this please? specifically I am using the shell method.
Edited: Incorrect fix, see "Sunnhild" 's reply for correct fix:
I found a solution for directional light shadow:
in shell's Lit.hlsl
From Line 120 to Line 123 (the author's file)
```( this is line 119 )
float4 color = UniversalFragmentPBR(inputData, surfaceData);
ApplyRimLight(color.rgb, input.positionWS, viewDirWS, normalWS);
color.rgb += _AmbientColor;
```( this is line 124 )
Change it to:
```( this is line 119 )
Light mainLight = GetMainLight(TransformWorldToShadowCoord(input.positionWS));
float shadow = mainLight.distanceAttenuation * mainLight.shadowAttenuation;
float4 color = UniversalFragmentPBR(inputData, surfaceData);
color.rgb *= shadow;
ApplyRimLight(color.rgb, input.positionWS, viewDirWS, normalWS);
color.rgb += _AmbientColor;
```( this is line 127 )
Don't know if it is correct, but it works. ( I cannot write shader code ) Please feel free to correct me!
After adding the code, you will have this result:
Terrible self-shadow ( can be fixed )
You can adjust the Shadow Extra Bias to avoid some self-shadow
No terrible self-shadow ( for this model, Shadow Extra Bias = -0.5)
The point light shadow works as expected ( no change needed)
By the way, this is the best shell fur shader I've ever seen.
amazing thank you - looks great
Thank you for your comment!
If possible, could you let me know which shader and which version of Unity (and URP) you are using? This is because the shadow is handled in UniversalFragmentPBR()
and you don't need to multiply it to color by yourself. I've got the result with shadows like the one in the README without changing the code.
![](https://raw.githubusercontent.com/wiki/hecomi/UnityFurURP/Screenshot.gif)
oh so I am on 2021.1.26f1 URP and I never had any shadows appear on the fur (using shell)
Thank you! Something may have changed since 2021.x. I'll update the project at hand and look into it when I have time.
Thank you! Something may have changed since 2021.x. I'll update the project at hand and look into it when I have time.
I found a similar issue on Unity Forum and they provide a solution. Link to the Thread (Unity Forum)
Thank you! Something may have changed since 2021.x. I'll update the project at hand and look into it when I have time.
I found a similar issue on Unity Forum and they provide a solution. Link to the Thread (Unity Forum)
This is the solution from your link, it works great!
replace #if defined(_MAIN_LIGHT_SHADOWS) && !defined(_RECEIVE_SHADOWS_OFF)
by #if defined(_MAIN_LIGHT_SHADOWS) || defined(_MAIN_LIGHT_SHADOWS_CASCADE) || defined(_MAIN_LIGHT_SHADOWS_SCREEN)
in all Lit hlsl files and it works 👍