Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion com.unity.toonshader/Editor/UTS3GUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ internal void FindTessellationProperties(MaterialProperty[] props) {
internal const string ShaderDefineSHADINGGRADEMAP = "_SHADINGGRADEMAP";
internal const string ShaderDefineANGELRING_ON = "_IS_ANGELRING_ON";
internal const string ShaderDefineANGELRING_OFF = "_IS_ANGELRING_OFF";
internal const string ShaderDefineUTS_USE_RAYTRACING_SHADOW = "UTS_USE_RAYTRACING_SHADOW";
internal const string ShaderPropAngelRing = "_AngelRing";
internal const string ShaderPropMatCap = "_MatCap";
internal const string ShaderPropMainTex = "_MainTex";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ void Frag(PackedVaryingsToPS packedInput,
if (_DirectionalShadowIndex >= 0)
{
DirectionalLightData light = _DirectionalLightDatas[_DirectionalShadowIndex];
#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT) && !defined(UTS_USE_RAYTRACING_SHADOW)
#if defined(SCREEN_SPACE_SHADOWS_ON) && !defined(_SURFACE_TYPE_TRANSPARENT)
if (UtsUseScreenSpaceShadow(light, bsdfData.normalWS))
{
// HDRP Contact Shadow
Expand All @@ -281,42 +281,15 @@ void Frag(PackedVaryingsToPS packedInput,
!ShouldEvaluateThickObjectTransmission(V, L, preLightData, bsdfData, light.shadowIndex))
{

#if defined(UTS_USE_RAYTRACING_SHADOW)
{
/*
struct PositionInputs
{
float3 positionWS; // World space position (could be camera-relative)
float2 positionNDC; // Normalized screen coordinates within the viewport : [0, 1) (with the half-pixel offset)
uint2 positionSS; // Screen space pixel coordinates : [0, NumPixels)
uint2 tileCoord; // Screen tile coordinates : [0, NumTiles)
float deviceDepth; // Depth from the depth buffer : [0, 1] (typically reversed)
float linearDepth; // View space Z coordinate : [Near, Far]
};
float4 size = _RaytracedHardShadow_TexelSize;
*/

float r = UNITY_SAMPLE_SCREEN_SHADOW(_RaytracedHardShadow, float4(posInput.positionNDC.xy, 0.0, 1));
context.shadowValue = r;
}
#else
{
context.shadowValue = GetDirectionalShadowAttenuation(context.shadowContext,
posInput.positionSS, posInput.positionWS, GetNormalForShadowBias(bsdfData),
light.shadowIndex, L);

}
#endif // UTS_USE_RAYTRACING_SHADOW


}
#if defined (UTS_USE_RAYTRACING_SHADOW)
else
{
float r = UNITY_SAMPLE_SCREEN_SHADOW(_RaytracedHardShadow, float4(posInput.positionNDC.xy, 0.0, 1));
context.shadowValue = r;
}
#endif // UTS_USE_RAYTRACING_SHADOW
}

}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,10 @@ float3 UTS_MainLightShadingGrademap(LightLoopContext lightLoopContext, FragInput
//v.2.0.6
float4 _ShadingGradeMap_var = tex2Dlod(_ShadingGradeMap, float4(TRANSFORM_TEX(Set_UV0, _ShadingGradeMap), 0.0, _BlurLevelSGM));
//v.2.0.6
//Minmimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold.
#if !defined (UTS_USE_RAYTRACING_SHADOW)
//Minimum value is same as the Minimum Feather's value with the Minimum Step's value as threshold.
shadowAttenuation *= 2.0f;
shadowAttenuation = saturate(shadowAttenuation);
#endif
float _SystemShadowsLevel_var = (shadowAttenuation *0.5)+0.5+_Tweak_SystemShadowsLevel > 0.001 ? (shadowAttenuation*0.5)+0.5+_Tweak_SystemShadowsLevel : 0.0001;

float _ShadingGradeMapLevel_var = _ShadingGradeMap_var.r < 0.95 ? _ShadingGradeMap_var.r + _Tweak_ShadingGradeMapLevel : 1;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Auto-generated on Fri Nov 07 05:27:25 UTC 2025
//Auto-generated on Tue Nov 18 11:05:20 UTC 2025
Shader "Toon" {
Properties
{
Expand Down Expand Up @@ -1044,8 +1044,6 @@ Shader "Toon" {
// used in ShadingGradeMap
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
// used in Shadow calculation
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
// used in DoubleShadeWithFeather
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
// controlling mask rendering
Expand Down Expand Up @@ -1295,8 +1293,6 @@ Shader "Toon" {
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON

// used in Shadow calculation
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
// used in DoubleShadeWithFeather
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE

Expand Down Expand Up @@ -1562,8 +1558,6 @@ Shader "Toon" {
#pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION
#pragma multi_compile _IS_PASS_FWDBASE

//
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
#if defined(_SHADINGGRADEMAP)

#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc"
Expand Down Expand Up @@ -1647,7 +1641,6 @@ Shader "Toon" {
//v.2.0.4

#pragma multi_compile _IS_PASS_FWDDELTA
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW

#if defined(_SHADINGGRADEMAP)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//Auto-generated on Fri Nov 07 05:27:25 UTC 2025
//Auto-generated on Tue Nov 18 11:05:20 UTC 2025
Shader "Toon(Tessellation)" {
Properties
{
Expand Down Expand Up @@ -1081,8 +1081,6 @@ Shader "Toon(Tessellation)" {
// used in ShadingGradeMap
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
// used in Shadow calculation
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
// used in DoubleShadeWithFeather
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
// controlling mask rendering
Expand Down Expand Up @@ -1332,8 +1330,6 @@ Shader "Toon(Tessellation)" {
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON

// used in Shadow calculation
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
// used in DoubleShadeWithFeather
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE

Expand Down Expand Up @@ -1640,8 +1636,6 @@ Shader "Toon(Tessellation)" {
#pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION
#pragma multi_compile _IS_PASS_FWDBASE

//
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
#if defined(_SHADINGGRADEMAP)

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

#pragma multi_compile _IS_PASS_FWDDELTA
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW

#if defined(_SHADINGGRADEMAP)

Expand Down
35 changes: 1 addition & 34 deletions com.unity.toonshader/Runtime/Legacy/Shaders/UCTS_Light.cginc
Original file line number Diff line number Diff line change
Expand Up @@ -4,40 +4,7 @@
#define __UCTS_LIGHT__

#include "AutoLight.cginc"

#if defined(UTS_USE_RAYTRACING_SHADOW)
#define UTS_LIGHT_ATTENUATION(destName, input, worldPos) fixed destName = UtsLightAttenuation(input, worldPos)

uniform sampler2D _RaytracedHardShadow;
fixed rths_shadowAttenuation(float2 lightmapUV, float3 worldPos, float4 screenPos) {

//Handle division by zero warning, based on how UNITY_SHADOW_ATTENUATION is used in Autolight.cginc
#if (!defined(HANDLE_SHADOWS_BLENDING_IN_GI)) \
&& !(defined(SHADOWS_SCREEN) && !defined(LIGHTMAP_ON) && !defined(UNITY_NO_SCREENSPACE_SHADOWS)) \
&& !(defined(SHADOWS_SHADOWMASK)) \
&& !(defined(SHADOWS_DEPTH) || defined(SHADOWS_SCREEN) || defined(SHADOWS_CUBE)) \
&& (UNITY_LIGHT_PROBE_PROXY_VOLUME)
float r = UNITY_SAMPLE_SCREEN_SHADOW(_RaytracedHardShadow, float4(screenPos.xyz,1)).r;
#else
float r = UNITY_SAMPLE_SCREEN_SHADOW(_RaytracedHardShadow, screenPos).r;
#endif //end handling division by zero

return r;
}

//---------------------------------------------------------------------------------------------------------------------

fixed UtsLightAttenuation(VertexOutput input, float3 worldPos) {
//redefine UnityComputeForwardShadows inside UNITY_LIGHT_ATTENUATION
#define UnityComputeForwardShadows(v0,v1,v2) rths_shadowAttenuation(v0,v1,v2)
UNITY_LIGHT_ATTENUATION(attenuation, input, worldPos);
#undef UnityComputeForwardShadows
return attenuation;
}
#else
// original
#define UTS_LIGHT_ATTENUATION(destName, input, worldPos) UNITY_LIGHT_ATTENUATION(destName, input, worldPos)
#endif //UTS_USE_RAYTRACING_SHADOW
#define UTS_LIGHT_ATTENUATION(destName, input, worldPos) UNITY_LIGHT_ATTENUATION(destName, input, worldPos)

#endif //__UCTS_LIGHT__

Original file line number Diff line number Diff line change
Expand Up @@ -556,8 +556,6 @@ Shader "Toon" {
// used in ShadingGradeMap
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
// used in Shadow calculation
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
// used in DoubleShadeWithFeather
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
// controlling mask rendering
Expand Down Expand Up @@ -807,8 +805,6 @@ Shader "Toon" {
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON

// used in Shadow calculation
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
// used in DoubleShadeWithFeather
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE

Expand Down Expand Up @@ -1074,8 +1070,6 @@ Shader "Toon" {
#pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION
#pragma multi_compile _IS_PASS_FWDBASE

//
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
#if defined(_SHADINGGRADEMAP)

#include "../../Legacy/Shaders/UCTS_ShadingGradeMap.cginc"
Expand Down Expand Up @@ -1159,7 +1153,6 @@ Shader "Toon" {
//v.2.0.4

#pragma multi_compile _IS_PASS_FWDDELTA
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW

#if defined(_SHADINGGRADEMAP)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -577,8 +577,6 @@ Shader "Toon(Tessellation)" {
// used in ShadingGradeMap
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON
// used in Shadow calculation
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
// used in DoubleShadeWithFeather
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE
// controlling mask rendering
Expand Down Expand Up @@ -828,8 +826,6 @@ Shader "Toon(Tessellation)" {
#pragma shader_feature _IS_TRANSCLIPPING_OFF _IS_TRANSCLIPPING_ON
#pragma shader_feature _IS_ANGELRING_OFF _IS_ANGELRING_ON

// used in Shadow calculation
#pragma shader_feature_local _ UTS_USE_RAYTRACING_SHADOW
// used in DoubleShadeWithFeather
#pragma shader_feature _IS_CLIPPING_OFF _IS_CLIPPING_MODE _IS_CLIPPING_TRANSMODE

Expand Down Expand Up @@ -1136,8 +1132,6 @@ Shader "Toon(Tessellation)" {
#pragma shader_feature _EMISSIVE_SIMPLE _EMISSIVE_ANIMATION
#pragma multi_compile _IS_PASS_FWDBASE

//
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW
#if defined(_SHADINGGRADEMAP)

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

#pragma multi_compile _IS_PASS_FWDDELTA
#pragma shader_feature_local UTS_USE_RAYTRACING_SHADOW

#if defined(_SHADINGGRADEMAP)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,7 @@
#endif
ShadowSamplingData shadowSamplingData = GetMainLightShadowSamplingData();
half4 shadowParams = GetMainLightShadowParams();
#if defined(UTS_USE_RAYTRACING_SHADOW)
float w = (positionCS.w == 0) ? 0.00001 : positionCS.w;
float4 screenPos = ComputeScreenPos(positionCS / w);
return SAMPLE_TEXTURE2D(_RaytracedHardShadow, sampler_RaytracedHardShadow, screenPos);
#elif defined(_MAIN_LIGHT_SHADOWS_SCREEN)
#if defined(_MAIN_LIGHT_SHADOWS_SCREEN)
return SampleScreenSpaceShadowmap(shadowCoord);
#endif

Expand All @@ -266,11 +262,6 @@

half AdditionalLightRealtimeShadowUTS(int lightIndex, float3 positionWS, float4 positionCS)
{
#if defined(UTS_USE_RAYTRACING_SHADOW)
float w = (positionCS.w == 0) ? 0.00001 : positionCS.w;
float4 screenPos = ComputeScreenPos(positionCS / w);
return SAMPLE_TEXTURE2D(_RaytracedHardShadow, sampler_RaytracedHardShadow, screenPos);
#endif // UTS_USE_RAYTRACING_SHADOW

#if defined(ADDITIONAL_LIGHT_CALCULATE_SHADOWS)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,10 +157,8 @@
float4 _ShadingGradeMap_var = tex2Dlod(_ShadingGradeMap, float4(TRANSFORM_TEX(Set_UV0, _ShadingGradeMap), 0.0, _BlurLevelSGM));

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

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