Skip to content

Commit e7d18eb

Browse files
authored
fixed: URP: on later than 11, UTS materials don't recive shadows. (#93)
1 parent 16ea266 commit e7d18eb

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

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

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,30 +174,31 @@
174174
float3 direction;
175175
float3 color;
176176
float distanceAttenuation;
177-
real shadowAttenuation;
178-
int type;
177+
float shadowAttenuation;
178+
int type;
179179
};
180180

181181
///////////////////////////////////////////////////////////////////////////////
182182
// Light Abstraction //
183183
/////////////////////////////////////////////////////////////////////////////
184-
real MainLightRealtimeShadowUTS(float4 shadowCoord, float4 positionCS)
184+
half MainLightRealtimeShadowUTS(float4 shadowCoord, float4 positionCS)
185185
{
186186
#if !defined(MAIN_LIGHT_CALCULATE_SHADOWS)
187-
return 1.0h;
187+
return 1.0;
188188
#endif
189189
ShadowSamplingData shadowSamplingData = GetMainLightShadowSamplingData();
190190
half4 shadowParams = GetMainLightShadowParams();
191191
#if defined(UTS_USE_RAYTRACING_SHADOW)
192192
float w = (positionCS.w == 0) ? 0.00001 : positionCS.w;
193-
float4 screenPos = ComputeScreenPos(positionCS/ w);
193+
float4 screenPos = ComputeScreenPos(positionCS / w);
194194
return SAMPLE_TEXTURE2D(_RaytracedHardShadow, sampler_RaytracedHardShadow, screenPos);
195-
#endif
196-
195+
#elif defined(_MAIN_LIGHT_SHADOWS_SCREEN)
196+
return SampleScreenSpaceShadowmap(shadowCoord);
197+
#endif
197198
return SampleShadowmap(TEXTURE2D_ARGS(_MainLightShadowmapTexture, sampler_MainLightShadowmapTexture), shadowCoord, shadowSamplingData, shadowParams, false);
198199
}
199200

200-
real AdditionalLightRealtimeShadowUTS(int lightIndex, float3 positionWS, float4 positionCS)
201+
half AdditionalLightRealtimeShadowUTS(int lightIndex, float3 positionWS, float4 positionCS)
201202
{
202203
#if defined(UTS_USE_RAYTRACING_SHADOW)
203204
float w = (positionCS.w == 0) ? 0.00001 : positionCS.w;

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,8 @@
103103
//DoubleShadeWithFeather
104104
#endif
105105

106-
real shadowAttenuation = 1.0;
107-
# ifdef _MAIN_LIGHT_SHADOWS
106+
float shadowAttenuation = 1.0;
107+
#if defined(_MAIN_LIGHT_SHADOWS) || defined(_MAIN_LIGHT_SHADOWS_CASCADE) || defined(_MAIN_LIGHT_SHADOWS_SCREEN)
108108
shadowAttenuation = mainLight.shadowAttenuation;
109109

110110
# endif

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,10 @@
9494
#endif
9595

9696

97-
real shadowAttenuation = 1.0;
98-
99-
# ifdef _MAIN_LIGHT_SHADOWS
97+
float shadowAttenuation = 1.0;
10098

99+
#if defined(_MAIN_LIGHT_SHADOWS) || defined(_MAIN_LIGHT_SHADOWS_CASCADE) || defined(_MAIN_LIGHT_SHADOWS_SCREEN)
101100
shadowAttenuation = mainLight.shadowAttenuation;
102-
103101
# endif
104102

105103

0 commit comments

Comments
 (0)