Hello,
I’m trying to change the shadow color of the 2D lights that can be used with URP. I know this feature is experimental and hence it might not support this, but is there a way to do this manually?
Thanks in advance.
Hello,
I’m trying to change the shadow color of the 2D lights that can be used with URP. I know this feature is experimental and hence it might not support this, but is there a way to do this manually?
Thanks in advance.
[EDIT]
I managed to achieve a working solution by creating a custom sprite-lit-default shader and by creating a modified version of CombinedShapeLightShared.hlsl, both downloadable below.
It works by setting a shadow color attribute in the shader, that is then used in “CombinedShapeLightShared” calculations. I decided to use a global attribute _ShadowColor for the shader as I though it should be common to all scene shadows.
Finally, to edit this color, I created a simple component “ShadowColorChanger.cs” that allow to change the color in inspector if dropped in scene, or by code without even needing to instantiate it with it’s static method “SetShadowColor(Color c)”
Result:
Usage:
======================
[OLD POST]
I’m getting some interesting results when messing with the value of “finalOutput” in CombinedShapeLightShared.hlsl.
Still a hard-coded color but that’s the kind of results I was targeting.
It needs further investigation but I think that’s the way to go
//starting line 80 of CombinedShapeLightShared.hlsl
#if !USE_SHAPE_LIGHT_TYPE_0 && !USE_SHAPE_LIGHT_TYPE_1 && !USE_SHAPE_LIGHT_TYPE_2 && ! USE_SHAPE_LIGHT_TYPE_3
finalOutput = color;
#else
half4 finalModulate = shapeLight0Modulate + shapeLight1Modulate + shapeLight2Modulate + shapeLight3Modulate;
half4 finalAdditve = shapeLight0Additive + shapeLight1Additive + shapeLight2Additive + shapeLight3Additive;
half4 test = half4(0.5h, 0.01h, 0.01h, 0.01h); //brute test shadow color
finalOutput = lerp(color, test, 1-finalModulate);
//finalOutput = _HDREmulationScale * (color * finalModulate + finalAdditve);
#endif