Closed HongDeveloper closed 3 months ago
Maybe adding "MToonOutlineRenderFeature" Render Feature will help!
Adding the outline render feature doesn't make a difference to me 🤷🏻
I managed to get the outline working on URP by adding this pass to the shader (Assets/VRM10/MToon10/Resources/VRM10/vrmc_materials_mtoon_urp.shader
) -- I'm not a shader expert, so it may be inefficient or too hacky :)
EDIT 2: I found a workaround for my case and the glitches went away.
EDIT: there's an issue with this code, there are glitches on the mouth, depending on your use case it may be unnoticeable.
// MToon Outline Pass
...
Pass
{
Name "Outline"
Cull Front
Tags { "LightMode" = "SRPDefaultUnlit" }
HLSLPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#define MTOON_URP
#include "./vrmc_materials_mtoon_render_pipeline.hlsl"
#include "./vrmc_materials_mtoon_input.hlsl"
struct appdata
{
float4 vertex : POSITION;
float3 normal : NORMAL;
float2 uv : TEXCOORD0;
};
struct v2f
{
float4 pos : SV_POSITION;
half2 uv : TEXCOORD1;
};
v2f vert(appdata v)
{
v2f output;
float _Offset_Z = 0.04;
float4 _ClipCameraPos = mul(UNITY_MATRIX_VP, float4(_WorldSpaceCameraPos.xyz, 1));
#if defined(UNITY_REVERSED_Z)
_Offset_Z *= -1;
#endif
output.pos = MToon_TransformObjectToHClip(float4(v.vertex.xyz + v.normal * _OutlineWidth * 0.1, 1));
output.pos.z += _Offset_Z * _ClipCameraPos.z;
output.uv = v.uv;
return output;
}
float4 frag(v2f i) : SV_Target
{
half4 texColor = MTOON_SAMPLE_TEXTURE2D(_MainTex, i.uv);
if (texColor.a <= _Cutoff) {
discard;
}
return _OutlineColor;
}
ENDHLSL
}
Turn off 'Depth Priming Mode' in your renderer, Unity's toon shader has a similar issue with their outlines: https://docs.unity3d.com/Packages/com.unity.toonshader@0.9/manual/Known-issue.html#when-using-universal-render-pipeline
That option was already disabled for me and it didn't help.
Thx 👍
v.0.12.0
Unity-2021.3
Mac, Window
Describe the bug
Hi. I have a issue Adjusting the outline value doesn't change. It's not even visible Package is recent release.