[unity] Added support for light cookies at Universal Render Pipeline/Spine/Sprite shader. Closes #2285.

This commit is contained in:
Harald Csaszar 2023-05-03 20:27:58 +02:00
parent ae2f1a1dc6
commit fc05ecf931
4 changed files with 14 additions and 2 deletions

View File

@ -99,6 +99,7 @@
* Lit Spine URP shaders (`Universal Render Pipeline/Spine/Sprite` and `Universal Render Pipeline/Spine/Skeleton Lit`) now support `Forward+` rendering path as introduced by Unity 2022.2 and URP version 14.
* `SkeletonGraphic` now supports automatic scaling based on its `RectTransform` bounds. Automatic scaling can be enabled by setting the added `Layout Scale Mode` Inspector property to either `Width Controls Height`, `Height Controls Width`, `FitInParent` or `EnvelopeParent`. It is set to `None` by default to keep previous behaviour and avoid breaking existing projects. To modify the reference layout bounds, hit the additional `Edit Layout Bounds` toggle button to switch into edit mode, adjust the bounds or hit `Match RectTransform with Mesh`, and hit the button again when done adjusting. The skeleton will now be scaled accordingly to fit the reference layout bounds to the object's `RectTransform`.
* Added previously missing unlit URP 2D shader variant, available under `Universal Render Pipeline/2D/Spine/Skeleton`.
* Added support for light cookies at `Universal Render Pipeline/Spine/Sprite` shader.
* **Breaking changes**
* Made `SkeletonGraphic.unscaledTime` parameter protected, use the new property `UnscaledTime` instead.

View File

@ -7,7 +7,7 @@
#include "SpineCoreShaders/Spine-Common.cginc"
#include "Spine-Common-URP.hlsl"
#if defined(_RIM_LIGHTING) || defined(_ADDITIONAL_LIGHTS) || defined(MAIN_LIGHT_CALCULATE_SHADOWS)
#if defined(_RIM_LIGHTING) || defined(_ADDITIONAL_LIGHTS) || defined(MAIN_LIGHT_CALCULATE_SHADOWS) || defined(_LIGHT_COOKIES)
#define NEEDS_POSITION_WS
#endif
@ -122,6 +122,10 @@ half4 LightweightFragmentPBRSimplified(InputData inputData, half4 texAlbedoAlpha
#else
Light mainLight = GetMainLight();
#endif
#if defined(_LIGHT_COOKIES)
half3 cookieColor = SampleMainLightCookie(inputData.positionWS);
mainLight.color *= cookieColor;
#endif
half3 finalColor = inputData.bakedGI * albedo.rgb;
finalColor += LightingPhysicallyBased(brdfData, mainLight, inputData.normalWS, inputData.viewDirectionWS);
@ -193,6 +197,11 @@ half4 LightweightFragmentBlinnPhongSimplified(InputData inputData, half4 texDiff
#else
Light mainLight = GetMainLight();
#endif
#if defined(_LIGHT_COOKIES)
half3 cookieColor = SampleMainLightCookie(inputData.positionWS);
mainLight.color *= cookieColor;
#endif
half3 diffuseLighting = inputData.bakedGI;
half3 attenuation = mainLight.distanceAttenuation* mainLight.shadowAttenuation;

View File

@ -107,6 +107,8 @@ Shader "Universal Render Pipeline/Spine/Sprite"
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
#pragma multi_compile _ _SHADOWS_SOFT
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
#pragma multi_compile_fragment _ _LIGHT_COOKIES
// Farward+ renderer keywords
#pragma multi_compile_fragment _ _LIGHT_LAYERS
#pragma multi_compile _ _FORWARD_PLUS

View File

@ -2,7 +2,7 @@
"name": "com.esotericsoftware.spine.urp-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)",
"version": "4.1.11",
"version": "4.1.12",
"unity": "2019.3",
"author": {
"name": "Esoteric Software",