Skip to content
Draft
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
2 changes: 1 addition & 1 deletion com.unity.toonshader/Editor/UTS3GUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -995,7 +995,7 @@ void OnOpenGUI(Material material, MaterialEditor materialEditor, MaterialPropert
m_MaterialScopeList.RegisterHeaderScope(Styles.emissionFoldout, Expandable.Emission, GUI_Emissive, (uint)UTS_Mode.ThreeColorToon,
(uint)UTS_TransparentMode.Off, isTessellation: 0);
m_MaterialScopeList.RegisterHeaderScope(Styles.outlineFoldout, Expandable.Outline, GUI_Outline, (uint)UTS_Mode.ThreeColorToon,
(uint)UTS_TransparentMode.On, isTessellation: 0);
(uint)UTS_TransparentMode.Off, isTessellation: 0);

m_MaterialScopeList.RegisterHeaderScope(Styles.tessellationFoldout, Expandable.TessellationLegacy, GUI_Tessellation, (uint)UTS_Mode.ThreeColorToon,
(uint)UTS_TransparentMode.Off, isTessellation: 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ VertexOutput vert(VertexInput v) {
//end
float Set_Outline_Width = (_Outline_Width * 0.001 * smoothstep(_Farthest_Distance, _Nearest_Distance,
distance(objPos.rgb, _WorldSpaceCameraPos)) * _Outline_Sampler_var.rgb).r;
#ifndef _UTS_OUTLINE_FORCE_VISIBLE
Set_Outline_Width *= (1.0f - _ZOverDrawMode);
#endif
//v.2.0.7.5
float4 _ClipCameraPos = mul(UNITY_MATRIX_VP, float4(_WorldSpaceCameraPos.xyz, 1));
//v.2.0.7
Expand Down Expand Up @@ -70,10 +72,12 @@ VertexOutput vert(VertexInput v) {

float4 frag(VertexOutput i) : SV_Target {
//v.2.0.5
#ifndef _UTS_OUTLINE_FORCE_VISIBLE
if (_ZOverDrawMode > 0.99f)
{
return float4(1.0f, 1.0f, 1.0f, 1.0f); // but nothing should be drawn except Z value as colormask is set to 0
}
#endif
_Color = _BaseColor;
float4 objPos = mul(GetObjectToWorldMatrix(), float4(0, 0, 0, 1));
//v.2.0.9
Expand Down
54 changes: 54 additions & 0 deletions com.unity.toonshader/Runtime/Shaders/UnityToon.shader
Original file line number Diff line number Diff line change
Expand Up @@ -1210,6 +1210,60 @@ Shader "Toon/Toon" {
ENDHLSL
}

// EXPERIMENT: visible outline for transparent materials. Drawn via the
// UniversalForwardOnly tag (URP transparent tag index 2) so it renders AFTER the
// body (UniversalForward, index 1), while the SRPDefaultUnlit "Outline" pass above
// stays as the transparency depth pre-pass (index 0). Uses hardcoded render state
// and _UTS_OUTLINE_FORCE_VISIBLE so it ignores the _ZOverDrawMode width collapse.
Pass {
Name "OutlineTransparent"
Tags {
"LightMode" = "UniversalForwardOnly"
}
Cull Front
ColorMask 15
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Stencil
{
Ref[_StencilNo]
Comp[_StencilComp]
Pass[_StencilOpPass]
Fail[_StencilOpFail]

}

HLSLPROGRAM
#pragma target 2.0
#pragma vertex vert
#pragma fragment frag

#define _UTS_OUTLINE_FORCE_VISIBLE

//V.2.0.4
#pragma multi_compile _IS_OUTLINE_CLIPPING_NO _IS_OUTLINE_CLIPPING_YES
#pragma multi_compile _OUTLINE_NML _OUTLINE_POS
// Outline is implemented in UniversalToonOutline.hlsl.
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Core.hlsl"
#include "Packages/com.unity.render-pipelines.universal/ShaderLibrary/Lighting.hlsl"

//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
#if UNITY_VERSION >= 202230 // Requires Universal RP 14.0.7
#include_with_pragmas "Packages/com.unity.render-pipelines.universal/ShaderLibrary/DOTS.hlsl"
#else
#pragma multi_compile _ DOTS_INSTANCING_ON
#endif

#ifdef UNIVERSAL_PIPELINE_CORE_INCLUDED
#include "URP/UniversalToonInput.hlsl"
#include "URP/UniversalToonHead.hlsl"
#include "URP/UniversalToonOutline.hlsl"
#endif
ENDHLSL
}

Pass
{
Name "Universal2D"
Expand Down