mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2025-12-20 09:16:01 +08:00
[unity] Fixed URP Sprite shader not receiving secondary light shadows. Closes #2098.
This commit is contained in:
parent
4c527e3055
commit
61a09fd650
@ -43,6 +43,22 @@ struct VertexOutputLWRP
|
|||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
// Vertex and Fragment functions //
|
// Vertex and Fragment functions //
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
|
#if defined(_ADDITIONAL_LIGHT_SHADOWS) && !defined(_RECEIVE_SHADOWS_OFF)
|
||||||
|
half4 CalculateShadowMaskBackwardsCompatible(InputData inputData)
|
||||||
|
{
|
||||||
|
// To ensure backward compatibility we have to avoid using shadowMask input, as it is not present in older shaders
|
||||||
|
#if defined(SHADOWS_SHADOWMASK) && defined(LIGHTMAP_ON)
|
||||||
|
half4 shadowMask = inputData.shadowMask;
|
||||||
|
#elif !defined (LIGHTMAP_ON)
|
||||||
|
half4 shadowMask = unity_ProbesOcclusion;
|
||||||
|
#else
|
||||||
|
half4 shadowMask = half4(1, 1, 1, 1);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return shadowMask;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
half3 LightweightLightVertexSimplified(float3 positionWS, half3 normalWS) {
|
half3 LightweightLightVertexSimplified(float3 positionWS, half3 normalWS) {
|
||||||
#ifdef _MAIN_LIGHT_VERTEX
|
#ifdef _MAIN_LIGHT_VERTEX
|
||||||
Light mainLight = GetMainLight();
|
Light mainLight = GetMainLight();
|
||||||
@ -101,7 +117,12 @@ half4 LightweightFragmentPBRSimplified(InputData inputData, half4 texAlbedoAlpha
|
|||||||
int pixelLightCount = GetAdditionalLightsCount();
|
int pixelLightCount = GetAdditionalLightsCount();
|
||||||
for (int i = 0; i < pixelLightCount; ++i)
|
for (int i = 0; i < pixelLightCount; ++i)
|
||||||
{
|
{
|
||||||
|
#if defined(_ADDITIONAL_LIGHT_SHADOWS) && !defined(_RECEIVE_SHADOWS_OFF)
|
||||||
|
half4 shadowMask = CalculateShadowMaskBackwardsCompatible(inputData);
|
||||||
|
Light light = GetAdditionalLight(i, inputData.positionWS, shadowMask);
|
||||||
|
#else
|
||||||
Light light = GetAdditionalLight(i, inputData.positionWS);
|
Light light = GetAdditionalLight(i, inputData.positionWS);
|
||||||
|
#endif
|
||||||
finalColor += LightingPhysicallyBased(brdfData, light, inputData.normalWS, inputData.viewDirectionWS);
|
finalColor += LightingPhysicallyBased(brdfData, light, inputData.normalWS, inputData.viewDirectionWS);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
@ -142,7 +163,12 @@ half4 LightweightFragmentBlinnPhongSimplified(InputData inputData, half4 texDiff
|
|||||||
int pixelLightCount = GetAdditionalLightsCount();
|
int pixelLightCount = GetAdditionalLightsCount();
|
||||||
for (int i = 0; i < pixelLightCount; ++i)
|
for (int i = 0; i < pixelLightCount; ++i)
|
||||||
{
|
{
|
||||||
|
#if defined(_ADDITIONAL_LIGHT_SHADOWS) && !defined(_RECEIVE_SHADOWS_OFF)
|
||||||
|
half4 shadowMask = CalculateShadowMaskBackwardsCompatible(inputData);
|
||||||
|
Light light = GetAdditionalLight(i, inputData.positionWS, shadowMask);
|
||||||
|
#else
|
||||||
Light light = GetAdditionalLight(i, inputData.positionWS);
|
Light light = GetAdditionalLight(i, inputData.positionWS);
|
||||||
|
#endif
|
||||||
half3 attenuation = (light.distanceAttenuation * light.shadowAttenuation);
|
half3 attenuation = (light.distanceAttenuation * light.shadowAttenuation);
|
||||||
half3 attenuatedLightColor = light.color * attenuation;
|
half3 attenuatedLightColor = light.color * attenuation;
|
||||||
#ifndef _DIFFUSE_RAMP
|
#ifndef _DIFFUSE_RAMP
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "com.esotericsoftware.spine.urp-shaders",
|
"name": "com.esotericsoftware.spine.urp-shaders",
|
||||||
"displayName": "Spine Universal RP Shaders",
|
"displayName": "Spine Universal RP Shaders",
|
||||||
"description": "This plugin provides universal render pipeline (URP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.1.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
|
"description": "This plugin provides universal render pipeline (URP) shaders for the spine-unity runtime.\n\nPrerequisites:\nIt requires a working installation of the spine-unity runtime, version 4.1.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
|
||||||
"version": "4.1.2",
|
"version": "4.1.3",
|
||||||
"unity": "2019.3",
|
"unity": "2019.3",
|
||||||
"author": {
|
"author": {
|
||||||
"name": "Esoteric Software",
|
"name": "Esoteric Software",
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user