Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ void ConvertBuiltInUTS2Materials( string[] guids)
UTS3GUI.MaterialSetInt(material, UTS3GUI.ShaderPropTransparentEnabled, 1);
}

UTS3GUI.SetupTransparentMode(material, transparentMode);
UTS3GUI.SetupTransparentModeForOutline(material, transparentMode);

SetCullingMode(material);
int autoRenderQueue = renderQueueInMaterial == -1 ? 1:0;
Expand Down
41 changes: 17 additions & 24 deletions com.unity.toonshader/Editor/UTS3GUI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,19 +48,6 @@ internal static RenderPipeline currentRenderPipeline {
}
}

internal static string srpDefaultLightModeName {
get {
const string legacyDefaultLightModeName = "Always";

if (currentRenderPipeline == RenderPipeline.Legacy) {
return legacyDefaultLightModeName; // default.
}

return ToonConstants.SHADER_LIGHT_MODE_NAME_FOR_OUTLINE;
}
}


internal void RenderingPerChennelsSetting(Material material) {
if (currentRenderPipeline == RenderPipeline.HDRP) {
RenderingPerChennelsSettingHDRP(material);
Expand Down Expand Up @@ -1198,7 +1185,7 @@ public override void OnGUI(MaterialEditor materialEditor, MaterialProperty[] pro
break;
}

SetupTransparentMode(material, transparencyEnabled == UTS_TransparentMode.On);
SetupTransparentModeForOutline(material, transparencyEnabled == UTS_TransparentMode.On);

ShaderPropertiesGUI(materialEditor, material, props);

Expand Down Expand Up @@ -2093,22 +2080,28 @@ void GUI_Emissive(Material material) {



internal static void SetupTransparentMode(Material material, bool isTransparent) {
string srpDefaultLightModeTag = material.GetTag("LightMode", false, srpDefaultLightModeName);
internal static void SetupTransparentModeForOutline(Material material, bool isTransparent) {


#if URP_IS_INSTALLED_FOR_UTS || HDRP_IS_INSTALLED_FOR_UTS
string srpDefaultLightModeTag = material.GetTag("LightMode", false, ToonConstants.SHADER_LIGHT_MODE_NAME_FOR_OUTLINE);

if (srpDefaultLightModeTag != srpDefaultLightModeName)
if (srpDefaultLightModeTag != ToonConstants.SHADER_LIGHT_MODE_NAME_FOR_OUTLINE)
return;
#endif

const string srpDefaultColorMask = "_SPRDefaultUnlitColorMask";
const string srpDefaultCullMode = "_SRPDefaultUnlitColMode";
const string OUTLINE_COLOR_MASK = "_SPRDefaultUnlitColorMask";
const string OUTLINE_CULL_MODE = "_SRPDefaultUnlitColMode";
Copy link

Copilot AI Dec 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'Col' to 'Cull' in constant name.

Suggested change
const string OUTLINE_CULL_MODE = "_SRPDefaultUnlitColMode";
const string OUTLINE_CULL_MODE = "_SRPDefaultUnlitCullMode";

Copilot uses AI. Check for mistakes.

if (isTransparent) {
material.SetShaderPassEnabled(srpDefaultLightModeName, true);
MaterialSetInt(material, srpDefaultColorMask, 0);
MaterialSetInt(material, srpDefaultCullMode, (int)CullingMode.Backface);
#if URP_IS_INSTALLED_FOR_UTS || HDRP_IS_INSTALLED_FOR_UTS
material.SetShaderPassEnabled(ToonConstants.SHADER_LIGHT_MODE_NAME_FOR_OUTLINE, true);
#endif
MaterialSetInt(material, OUTLINE_COLOR_MASK, 0); //Don't write to the render target
MaterialSetInt(material, OUTLINE_CULL_MODE, (int)CullingMode.Backface);
} else {
MaterialSetInt(material, srpDefaultColorMask, 15);
MaterialSetInt(material, srpDefaultCullMode, (int)CullingMode.Frontface);
MaterialSetInt(material, OUTLINE_COLOR_MASK, 15); //0xFF: presumably write to RGBA channels ?
MaterialSetInt(material, OUTLINE_CULL_MODE, (int)CullingMode.Frontface);
}
}

Expand Down