Skip to content

Commit 4a98399

Browse files
H3idi-XHum9183
andauthored
Dev/decal (#336)
* Add decal feature (URP only) (#335) * fixed errors on 2020.3 --------- Co-authored-by: Miyakawa Takeshi <[email protected]>
1 parent fb1a456 commit 4a98399

File tree

5 files changed

+35
-2
lines changed

5 files changed

+35
-2
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,6 +1217,7 @@ Shader "Toon" {
12171217
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
12181218
#pragma multi_compile _ _SHADOWS_SOFT
12191219
#pragma multi_compile _ _FORWARD_PLUS
1220+
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
12201221

12211222
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
12221223
// -------------------------------------

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1278,7 +1278,8 @@ Shader "Toon(Tessellation)" {
12781278
#pragma multi_compile _ _ADDITIONAL_LIGHT_SHADOWS
12791279
#pragma multi_compile _ _SHADOWS_SOFT
12801280
#pragma multi_compile _ _FORWARD_PLUS
1281-
1281+
#pragma multi_compile_fragment _ _DBUFFER_MRT1 _DBUFFER_MRT2 _DBUFFER_MRT3
1282+
12821283
#pragma multi_compile _ _MIXED_LIGHTING_SUBTRACTIVE
12831284
// -------------------------------------
12841285
// Unity defined keywords

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

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,30 @@
126126
#endif
127127
return EnvironmentBRDF(brdfData, indirectDiffuse, indirectSpecular, fresnelTerm);
128128
}
129-
129+
#if UNITY_VERSION >= 202120
130+
void ApplyDecalToSurfaceDataUTS(float4 positionCS, inout float3 albedo, inout SurfaceData surfaceData, inout float3 normalWS)
131+
{
132+
#ifdef _SPECULAR_SETUP
133+
half metallic = 0;
134+
ApplyDecal(positionCS,
135+
albedo,
136+
surfaceData.specular,
137+
normalWS,
138+
metallic,
139+
surfaceData.occlusion,
140+
surfaceData.smoothness);
141+
#else
142+
half3 specular = 0;
143+
ApplyDecal(positionCS,
144+
albedo,
145+
specular,
146+
normalWS,
147+
surfaceData.metallic,
148+
surfaceData.occlusion,
149+
surfaceData.smoothness);
150+
#endif
151+
}
152+
#endif
130153
struct VertexInput {
131154
float4 vertex : POSITION;
132155
float3 normal : NORMAL;

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@
8484
half3 mainLightColor = GetLightColor(mainLight);
8585
float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex));
8686

87+
#ifdef _DBUFFER
88+
ApplyDecalToSurfaceDataUTS(input.positionCS, _MainTex_var.rgb, surfaceData, normalDirection);
89+
#endif
90+
8791
//v.2.0.4
8892
#if defined(_IS_CLIPPING_MODE)
8993
//DoubleShadeWithFeather_Clipping

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@
8181

8282
float4 _MainTex_var = SAMPLE_TEXTURE2D(_MainTex, sampler_MainTex, TRANSFORM_TEX(Set_UV0, _MainTex));
8383

84+
#ifdef _DBUFFER
85+
ApplyDecalToSurfaceDataUTS(input.positionCS, _MainTex_var.rgb, surfaceData, normalDirection);
86+
#endif
87+
8488
//v.2.0.4
8589
#ifdef _IS_TRANSCLIPPING_OFF
8690
//

0 commit comments

Comments
 (0)