Procházet zdrojové kódy

[unity] Added support for Unity 6 Adaptive Probe Volumes at URP Sprite shader. See #2750.

Harald Csaszar před 7 měsíci
rodič
revize
44646bedfa

+ 2 - 1
CHANGELOG.md

@@ -167,7 +167,8 @@
   - URP Shaders: Added `ZWrite` variant of outline shader `Universal Render Pipeline/Spine/Outline/Skeleton-OutlineOnly ZWrite`. Suitable for e.g. depth of field (DoF) effect where writing to the depth buffer is required. Note that for DoF effect, `Render Queue` needs to be set to `Alpha Test`.
   - SkeletonGraphic: Exposed `SetScaledPivotOffset` as public method outside of the editor to support programatically moving mesh offsets at runtime based on mesh bounds.
   - SkeletonMecanim: Added `Scene Preview` option to preview an Animation Clip for e.g. easier event placement. When enabled, the Animation Clip selected in the Animation window is previewed in the Scene and Game views. Lock the `SkeletonMecanim` Inspector window, open the Animation window and select the Animation Clip. Then in the Animation window scrub through the timeline to see the current animation frame previewed.
-  - `Universal Render Pipeline/Spine/Skeleton Lit` shader now supports [Adaptive Probe Volumes (APV)](https://docs.unity3d.com/6000.0/Documentation/Manual/urp/probevolumes-concept.html) introduced in Unity 6. The shader also provides a new material property `APV per Pixel` to either calculate APV lighting contribution per pixel (the default) or per vertex. 
+  - `Universal Render Pipeline/Spine/Skeleton Lit` shader now supports [Adaptive Probe Volumes (APV)](https://docs.unity3d.com/6000.0/Documentation/Manual/urp/probevolumes-concept.html) introduced in Unity 6. The shader also provides a new material property `APV per Pixel` to either calculate APV lighting contribution per pixel (the default) or per vertex.
+  - `Universal Render Pipeline/Spine/Sprite` shader now also supports [Adaptive Probe Volumes (APV)](https://docs.unity3d.com/6000.0/Documentation/Manual/urp/probevolumes-concept.html) introduced in Unity 6. APV lighting contribution is automatically calculated per pixel.
 
 - **Breaking changes**
 

+ 23 - 0
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Include/Spine-Sprite-ForwardPass-URP.hlsl

@@ -18,6 +18,10 @@
 	#define NEEDS_POSITION_WS
 #endif
 
+#if !defined(DYNAMICLIGHTMAP_ON) && !defined(LIGHTMAP_ON) && (defined(PROBE_VOLUMES_L1) || defined(PROBE_VOLUMES_L2))
+#define USE_ADAPTIVE_PROBE_VOLUMES
+#endif
+
 ////////////////////////////////////////
 // Vertex output struct
 //
@@ -48,6 +52,9 @@ struct VertexOutputLWRP
 #if defined(_TINT_BLACK_ON)
 	float3 darkColor : TEXCOORD9;
 #endif
+#if defined(USE_ADAPTIVE_PROBE_VOLUMES)
+	float3 positionCS : TEXCOORD10;
+#endif
 
 	UNITY_VERTEX_OUTPUT_STEREO
 };
@@ -324,6 +331,9 @@ VertexOutputLWRP ForwardPassVertexSprite(VertexInput input)
 	#endif
 #else
 	OUTPUT_SH(normalWS.xyz, output.vertexSH);
+#endif
+#if defined(USE_ADAPTIVE_PROBE_VOLUMES)
+	output.positionCS = output.pos;
 #endif
 	return output;
 }
@@ -370,7 +380,20 @@ half4 ForwardPassFragmentSprite(VertexOutputLWRP input
 #endif
 
 	inputData.normalWS = normalWS;
+#if defined(USE_ADAPTIVE_PROBE_VOLUMES)
+	half4 shadowMask = 1.0;
+	float4 ignoredProbeOcclusion;
+	inputData.bakedGI = SAMPLE_GI(input.vertexSH,
+		GetAbsolutePositionWS(input.positionWS),
+		inputData.normalWS.xyz,
+		GetWorldSpaceNormalizeViewDir(input.positionWS),
+		input.positionCS.xy,
+		ignoredProbeOcclusion,
+		shadowMask);
+#else // USE_ADAPTIVE_PROBE_VOLUMES
 	inputData.bakedGI = SAMPLE_GI(input.lightmapUV, input.vertexSH, inputData.normalWS);
+#endif
+
 #if defined(_RIM_LIGHTING) || defined(_ADDITIONAL_LIGHTS) || defined(USE_LIGHT_COOKIES)
 	inputData.positionWS = input.positionWS.rgb;
 #endif

+ 1 - 0
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/Shaders/Spine-Sprite-URP.shader

@@ -121,6 +121,7 @@ Shader "Universal Render Pipeline/Spine/Sprite"
 			// Unity defined keywords
 			#pragma multi_compile _ DIRLIGHTMAP_COMBINED
 			#pragma multi_compile _ LIGHTMAP_ON
+			#pragma multi_compile _ PROBE_VOLUMES_L1 PROBE_VOLUMES_L2
 
 			//--------------------------------------
 			// GPU Instancing

+ 1 - 1
spine-unity/Modules/com.esotericsoftware.spine.urp-shaders/package.json

@@ -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.2.\n(See http://esotericsoftware.com/git/spine-runtimes/spine-unity)",
-  "version": "4.2.40",
+  "version": "4.2.41",
   "unity": "2019.3",
   "author": {
     "name": "Esoteric Software",