Skip to content

Commit d2dac4e

Browse files
authored
refactor: remove UTS_USE_RAYTRACING_SHADOW define (#578)
* remove constant in cs code * remove UTS_USE_RAYTRACING_SHADOW declaration in shader parts * remove from includes * regenerate shaders
1 parent 971ef0e commit d2dac4e

File tree

10 files changed

+7
-108
lines changed

10 files changed

+7
-108
lines changed

com.unity.toonshader/Editor/UTS3GUI.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ internal void FindTessellationProperties(MaterialProperty[] props) {
7979
internal const string ShaderDefineSHADINGGRADEMAP = "_SHADINGGRADEMAP";
8080
internal const string ShaderDefineANGELRING_ON = "_IS_ANGELRING_ON";
8181
internal const string ShaderDefineANGELRING_OFF = "_IS_ANGELRING_OFF";
82-
internal const string ShaderDefineUTS_USE_RAYTRACING_SHADOW = "UTS_USE_RAYTRACING_SHADOW";
8382
internal const string ShaderPropAngelRing = "_AngelRing";
8483
internal const string ShaderPropMatCap = "_MatCap";
8584
internal const string ShaderPropMainTex = "_MainTex";

com.unity.toonshader/Runtime/HDRP/Shaders/ShaderPassForwardUTS.hlsl

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ void Frag(PackedVaryingsToPS packedInput,
263263
if (_DirectionalShadowIndex >= 0)
264264
{
265265
DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex];
266-
#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(UTS_USE_RAYTRACING_SHADOW)
266+
#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT)
267267
if (UtsUseScreenSpaceShadow(light, bsdfData.normalWS))
268268
{
269269
// HDRP Contact Shadow
@@ -281,42 +281,15 @@ void Frag(PackedVaryingsToPS packedInput,
281281
!ShouldEvaluateThickObjectTransmission(V, L, preLightData, bsdfData, light.shadowIndex))
282282
{
283283

284-
#if defined(UTS_USE_RAYTRACING_SHADOW)
285-
{
286-
/*
287-
struct PositionInputs
288-
{
289-
float3 positionWS; // World space position (could be camera-relative)
290-
float2 positionNDC; // Normalized screen coordinates within the viewport : [0, 1) (with the half-pixel offset)
291-
uint2 positionSS; // Screen space pixel coordinates : [0, NumPixels)
292-
uint2 tileCoord; // Screen tile coordinates : [0, NumTiles)
293-
float deviceDepth; // Depth from the depth buffer : [0, 1] (typically reversed)
294-
float linearDepth; // View space Z coordinate : [Near, Far]
295-
};
296-
float4 size = _RaytracedHardShadow_TexelSize;
297-
*/
298-
299-
float r = UNITY_SAMPLE_SCREEN_SHADOW(_RaytracedHardShadow, float4(posInput.positionNDC.xy, 0.0, 1));
300-
context.shadowValue = r;
301-
}
302-
#else
303284
{
304285
context.shadowValue = GetDirectionalShadowAttenuation(context.shadowContext,
305286
posInput.positionSS, posInput.positionWS, GetNormalForShadowBias(bsdfData),
306287
light.shadowIndex, L);
307288

308289
}
309-
#endif // UTS_USE_RAYTRACING_SHADOW
310290

311291

312292
}
313-
#if defined (UTS_USE_RAYTRACING_SHADOW)
314-
else
315-
{
316-
float r = UNITY_SAMPLE_SCREEN_SHADOW(_RaytracedHardShadow, float4(posInput.positionNDC.xy, 0.0, 1));
317-
context.shadowValue = r;
318-
}
319-
#endif // UTS_USE_RAYTRACING_SHADOW
320293
}
321294

322295
}

com.unity.toonshader/Runtime/HDRP/Shaders/ShadingGrademapMainLight.hlsl

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -120,11 +120,10 @@ float3 UTS_MainLightShadingGrademap(LightLoopContext lightLoopContext, FragInput
120120
//v.2.0.6
121121
float4 _ShadingGradeMap_var = tex2Dlod(_ShadingGradeMap, float4(TRANSFORM_TEX(Set_UV0, _ShadingGradeMap), 0.0, _BlurLevelSGM));
122122
//v.2.0.6
123-
//Minmimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold.
124-
#if !defined (UTS_USE_RAYTRACING_SHADOW)
123+
//Minimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold.
125124
shadowAttenuation *= 2.0f;
126125
shadowAttenuation = saturate(shadowAttenuation);
127-
#endif
126+
128127
float _SystemShadowsLevel_var = (shadowAttenuation *0.5)+0.5+_Tweak_SystemShadowsLevel > 0.001 ? (shadowAttenuation*0.5)+0.5+_Tweak_SystemShadowsLevel : 0.0001;
129128

130129
float _ShadingGradeMapLevel_var = _ShadingGradeMap_var.r < 0.95 ? _ShadingGradeMap_var.r + _Tweak_ShadingGradeMapLevel : 1;

com.unity.toonshader/Runtime/Integrated/Shaders/UnityToon.shader

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Auto-generated on Fri Nov 07 05:27:25 UTC 2025
1+
//Auto-generated on Tue Nov 18 11:05:20 UTC 2025
22
Shader "Toon" {
33
Properties
44
{
@@ -1044,8 +1044,6 @@ Shader "Toon" {
10441044
// used in ShadingGradeMap
10451045
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
10461046
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
1047-
// used in Shadow calculation
1048-
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
10491047
// used in DoubleShadeWithFeather
10501048
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
10511049
// controlling mask rendering
@@ -1295,8 +1293,6 @@ Shader "Toon" {
12951293
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
12961294
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
12971295

1298-
// used in Shadow calculation
1299-
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
13001296
// used in DoubleShadeWithFeather
13011297
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
13021298

@@ -1562,8 +1558,6 @@ Shader "Toon" {
15621558
#pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION
15631559
#pragma multi_compile _IS_PASS_FWDBASE
15641560

1565-
//
1566-
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
15671561
#if defined(_SHADINGGRADEMAP)
15681562

15691563
#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc"
@@ -1647,7 +1641,6 @@ Shader "Toon" {
16471641
//v.2.0.4
16481642

16491643
#pragma multi_compile _IS_PASS_FWDDELTA
1650-
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
16511644

16521645
#if defined(_SHADINGGRADEMAP)
16531646

com.unity.toonshader/Runtime/Integrated/Shaders/UnityToonTessellation.shader

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//Auto-generated on Fri Nov 07 05:27:25 UTC 2025
1+
//Auto-generated on Tue Nov 18 11:05:20 UTC 2025
22
Shader "Toon(Tessellation)" {
33
Properties
44
{
@@ -1081,8 +1081,6 @@ Shader "Toon(Tessellation)" {
10811081
// used in ShadingGradeMap
10821082
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
10831083
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
1084-
// used in Shadow calculation
1085-
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
10861084
// used in DoubleShadeWithFeather
10871085
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
10881086
// controlling mask rendering
@@ -1332,8 +1330,6 @@ Shader "Toon(Tessellation)" {
13321330
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
13331331
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
13341332

1335-
// used in Shadow calculation
1336-
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
13371333
// used in DoubleShadeWithFeather
13381334
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
13391335

@@ -1640,8 +1636,6 @@ Shader "Toon(Tessellation)" {
16401636
#pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION
16411637
#pragma multi_compile _IS_PASS_FWDBASE
16421638

1643-
//
1644-
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
16451639
#if defined(_SHADINGGRADEMAP)
16461640

16471641
#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc"
@@ -1737,7 +1731,6 @@ Shader "Toon(Tessellation)" {
17371731
//v.2.0.4
17381732

17391733
#pragma multi_compile _IS_PASS_FWDDELTA
1740-
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
17411734

17421735
#if defined(_SHADINGGRADEMAP)
17431736

com.unity.toonshader/Runtime/Legacy/Shaders/UCTS_Light.cginc

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4,40 +4,7 @@
44
#define __UCTS_LIGHT__
55

66
#include "AutoLight.cginc"
7-
8-
#if defined(UTS_USE_RAYTRACING_SHADOW)
9-
#define UTS_LIGHT_ATTENUATION(destName, input, worldPos) fixed destName = UtsLightAttenuation(input, worldPos)
10-
11-
uniform sampler2D _RaytracedHardShadow;
12-
fixed rths_shadowAttenuation(float2 lightmapUV, float3 worldPos, float4 screenPos) {
13-
14-
//Handle division by zero warning, based on how UNITY_SHADOW_ATTENUATION is used in Autolight.cginc
15-
#if (!defined(HANDLE_SHADOWS_BLENDING_IN_GI)) \
16-
&& !(defined(SHADOWS_SCREEN) && !defined(LIGHTMAP_ON) && !defined(UNITY_NO_SCREENSPACE_SHADOWS)) \
17-
&& !(defined(SHADOWS_SHADOWMASK)) \
18-
&& !(defined(SHADOWS_DEPTH) || defined(SHADOWS_SCREEN) || defined(SHADOWS_CUBE)) \
19-
&& (UNITY_LIGHT_PROBE_PROXY_VOLUME)
20-
float r = UNITY_SAMPLE_SCREEN_SHADOW(_RaytracedHardShadow, float4(screenPos.xyz,1)).r;
21-
#else
22-
float r = UNITY_SAMPLE_SCREEN_SHADOW(_RaytracedHardShadow, screenPos).r;
23-
#endif //end handling division by zero
24-
25-
return r;
26-
}
27-
28-
//---------------------------------------------------------------------------------------------------------------------
29-
30-
fixed UtsLightAttenuation(VertexOutput input, float3 worldPos) {
31-
//redefine UnityComputeForwardShadows inside UNITY_LIGHT_ATTENUATION
32-
#define UnityComputeForwardShadows(v0,v1,v2) rths_shadowAttenuation(v0,v1,v2)
33-
UNITY_LIGHT_ATTENUATION(attenuation, input, worldPos);
34-
#undef UnityComputeForwardShadows
35-
return attenuation;
36-
}
37-
#else
38-
// original
39-
#define UTS_LIGHT_ATTENUATION(destName, input, worldPos) UNITY_LIGHT_ATTENUATION(destName, input, worldPos)
40-
#endif //UTS_USE_RAYTRACING_SHADOW
7+
#define UTS_LIGHT_ATTENUATION(destName, input, worldPos) UNITY_LIGHT_ATTENUATION(destName, input, worldPos)
418

429
#endif //__UCTS_LIGHT__
4310

com.unity.toonshader/Runtime/Shaders/Common/Parts/UnityToon.shadertemplate

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -556,8 +556,6 @@ Shader "Toon" {
556556
// used in ShadingGradeMap
557557
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
558558
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
559-
// used in Shadow calculation
560-
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
561559
// used in DoubleShadeWithFeather
562560
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
563561
// controlling mask rendering
@@ -807,8 +805,6 @@ Shader "Toon" {
807805
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
808806
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
809807

810-
// used in Shadow calculation
811-
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
812808
// used in DoubleShadeWithFeather
813809
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
814810

@@ -1074,8 +1070,6 @@ Shader "Toon" {
10741070
#pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION
10751071
#pragma multi_compile _IS_PASS_FWDBASE
10761072

1077-
//
1078-
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
10791073
#if defined(_SHADINGGRADEMAP)
10801074

10811075
#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc"
@@ -1159,7 +1153,6 @@ Shader "Toon" {
11591153
//v.2.0.4
11601154

11611155
#pragma multi_compile _IS_PASS_FWDDELTA
1162-
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
11631156

11641157
#if defined(_SHADINGGRADEMAP)
11651158

com.unity.toonshader/Runtime/Shaders/Common/Parts/UnityToonTessellation.shadertemplate

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -577,8 +577,6 @@ Shader "Toon(Tessellation)" {
577577
// used in ShadingGradeMap
578578
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
579579
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
580-
// used in Shadow calculation
581-
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
582580
// used in DoubleShadeWithFeather
583581
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
584582
// controlling mask rendering
@@ -828,8 +826,6 @@ Shader "Toon(Tessellation)" {
828826
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
829827
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
830828

831-
// used in Shadow calculation
832-
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
833829
// used in DoubleShadeWithFeather
834830
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
835831

@@ -1136,8 +1132,6 @@ Shader "Toon(Tessellation)" {
11361132
#pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION
11371133
#pragma multi_compile _IS_PASS_FWDBASE
11381134

1139-
//
1140-
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
11411135
#if defined(_SHADINGGRADEMAP)
11421136

11431137
#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc"
@@ -1233,7 +1227,6 @@ Shader "Toon(Tessellation)" {
12331227
//v.2.0.4
12341228

12351229
#pragma multi_compile _IS_PASS_FWDDELTA
1236-
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
12371230

12381231
#if defined(_SHADINGGRADEMAP)
12391232

com.unity.toonshader/Runtime/UniversalRP/Shaders/UniversalToonBody.hlsl

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -252,11 +252,7 @@
252252
#endif
253253
ShadowSamplingData shadowSamplingData = GetMainLightShadowSamplingData();
254254
half4 shadowParams = GetMainLightShadowParams();
255-
#if defined(UTS_USE_RAYTRACING_SHADOW)
256-
float w = (positionCS.w == 0) ? 0.00001 : positionCS.w;
257-
float4 screenPos = ComputeScreenPos(positionCS / w);
258-
return SAMPLE_TEXTURE2D(_RaytracedHardShadow, sampler_RaytracedHardShadow, screenPos);
259-
#elif defined(_MAIN_LIGHT_SHADOWS_SCREEN)
255+
#if defined(_MAIN_LIGHT_SHADOWS_SCREEN)
260256
return SampleScreenSpaceShadowmap(shadowCoord);
261257
#endif
262258

@@ -266,11 +262,6 @@
266262

267263
half AdditionalLightRealtimeShadowUTS(int lightIndex, float3 positionWS, float4 positionCS)
268264
{
269-
#if defined(UTS_USE_RAYTRACING_SHADOW)
270-
float w = (positionCS.w == 0) ? 0.00001 : positionCS.w;
271-
float4 screenPos = ComputeScreenPos(positionCS / w);
272-
return SAMPLE_TEXTURE2D(_RaytracedHardShadow, sampler_RaytracedHardShadow, screenPos);
273-
#endif // UTS_USE_RAYTRACING_SHADOW
274265

275266
#if defined(ADDITIONAL_LIGHT_CALCULATE_SHADOWS)
276267

com.unity.toonshader/Runtime/UniversalRP/Shaders/UniversalToonBodyShadingGradeMap.hlsl

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,8 @@
157157
float4 _ShadingGradeMap_var = tex2Dlod(_ShadingGradeMap, float4(TRANSFORM_TEX(Set_UV0, _ShadingGradeMap), 0.0, _BlurLevelSGM));
158158

159159
//the value of shadowAttenuation is darker than legacy and it cuases noise in terminaters.
160-
#if !defined (UTS_USE_RAYTRACING_SHADOW)
161160
shadowAttenuation *= 2.0f;
162161
shadowAttenuation = saturate(shadowAttenuation);
163-
#endif
164162

165163
//v.2.0.6
166164
//Minmimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold.

0 commit comments

Comments
 (0)