[unity] URP shaders: Fixed more compile errors with old URP versions.

This commit is contained in:
Harald Csaszar 2023-06-01 16:03:50 +02:00
parent a1f27d74b1
commit 1fe8f95e27
4 changed files with 24 additions and 8 deletions

View File

@ -3,21 +3,37 @@
#ifdef USE_FORWARD_PLUS #ifdef USE_FORWARD_PLUS
#define IS_URP_14_OR_NEWER 1 #define IS_URP_14_OR_NEWER 1
#define IS_URP_12_OR_NEWER 1
#else #else
#define IS_URP_14_OR_NEWER 0 #define IS_URP_14_OR_NEWER 0
#ifdef UNIVERSAL_REALTIME_LIGHTS_INCLUDED
#define IS_URP_12_OR_NEWER 1
#else
#define IS_URP_12_OR_NEWER 0
#endif
#endif #endif
#if defined(_WRITE_RENDERING_LAYERS) && IS_URP_14_OR_NEWER #if defined(_WRITE_RENDERING_LAYERS) && IS_URP_14_OR_NEWER
#define USE_WRITE_RENDERING_LAYERS #define USE_WRITE_RENDERING_LAYERS
#endif #endif
#ifdef _LIGHT_LAYERS #if defined(_LIGHT_LAYERS) && IS_URP_12_OR_NEWER
#define USE_LIGHT_LAYERS
#endif
#if defined(_LIGHT_COOKIES) && IS_URP_12_OR_NEWER
#define USE_LIGHT_COOKIES
#endif
#ifdef USE_LIGHT_LAYERS
uint GetMeshRenderingLayerBackwardsCompatible() uint GetMeshRenderingLayerBackwardsCompatible()
{ {
#if IS_URP_14_OR_NEWER #if IS_URP_14_OR_NEWER
return GetMeshRenderingLayer(); return GetMeshRenderingLayer();
#else #elif IS_URP_12_OR_NEWER
return GetMeshRenderingLightLayer(); return GetMeshRenderingLightLayer();
#else
return 0;
#endif #endif
} }
#else #else

View File

@ -46,7 +46,7 @@ struct VertexOutput {
half3 ProcessLight(float3 positionWS, half3 normalWS, uint meshRenderingLayers, int lightIndex) half3 ProcessLight(float3 positionWS, half3 normalWS, uint meshRenderingLayers, int lightIndex)
{ {
Light light = GetAdditionalLight(lightIndex, positionWS); Light light = GetAdditionalLight(lightIndex, positionWS);
#ifdef _LIGHT_LAYERS #ifdef USE_LIGHT_LAYERS
if (!IsMatchingLightLayer(light.layerMask, meshRenderingLayers)) if (!IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
return half3(0, 0, 0); return half3(0, 0, 0);
#endif #endif

View File

@ -109,7 +109,7 @@ half3 ProcessLightPBRSimplified(InputData inputData, BRDFData brdfData, half4 sh
#else #else
Light light = GetAdditionalLight(lightIndex, inputData.positionWS); Light light = GetAdditionalLight(lightIndex, inputData.positionWS);
#endif #endif
#ifdef _LIGHT_LAYERS #ifdef USE_LIGHT_LAYERS
if (!IsMatchingLightLayer(light.layerMask, meshRenderingLayers)) if (!IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
return half3(0, 0, 0); return half3(0, 0, 0);
#endif #endif
@ -136,7 +136,7 @@ half4 LightweightFragmentPBRSimplified(InputData inputData, half4 texAlbedoAlpha
#else #else
Light mainLight = GetMainLight(); Light mainLight = GetMainLight();
#endif #endif
#if defined(_LIGHT_COOKIES) #if defined(USE_LIGHT_COOKIES)
half3 cookieColor = SampleMainLightCookie(inputData.positionWS); half3 cookieColor = SampleMainLightCookie(inputData.positionWS);
mainLight.color *= cookieColor; mainLight.color *= cookieColor;
#endif #endif
@ -187,7 +187,7 @@ half3 ProcessLightLambert(InputData inputData, half4 shadowMask, uint meshRender
Light light = GetAdditionalLight(lightIndex, inputData.positionWS); Light light = GetAdditionalLight(lightIndex, inputData.positionWS);
#endif #endif
#ifdef _LIGHT_LAYERS #ifdef USE_LIGHT_LAYERS
if (!IsMatchingLightLayer(light.layerMask, meshRenderingLayers)) if (!IsMatchingLightLayer(light.layerMask, meshRenderingLayers))
return half3(0, 0, 0); return half3(0, 0, 0);
#endif #endif
@ -215,7 +215,7 @@ half4 LightweightFragmentBlinnPhongSimplified(InputData inputData, half4 texDiff
#else #else
Light mainLight = GetMainLight(); Light mainLight = GetMainLight();
#endif #endif
#if defined(_LIGHT_COOKIES) #if defined(USE_LIGHT_COOKIES)
half3 cookieColor = SampleMainLightCookie(inputData.positionWS); half3 cookieColor = SampleMainLightCookie(inputData.positionWS);
mainLight.color *= cookieColor; mainLight.color *= cookieColor;
#endif #endif

View File

@ -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.14", "version": "4.1.15",
"unity": "2019.3", "unity": "2019.3",
"author": { "author": {
"name": "Esoteric Software", "name": "Esoteric Software",