Harald
I tried what you proposed. If I'm understanding correctly, by changing #pragma fragment frag
to #pragma fragment constantColorFrag
I'm telling the shader to use this new method to paint the image instead of the frag
method found in ../../Include/Spine-Skeleton-ForwardPass-URP.hlsl
, right?
Just to clarify, I understand that I am not supposed to make any changes to the Spine-Skeleton-ForwardPass-URP.hlsl
file.
So, my new shader now looks like this:
Shader "Universal Render Pipeline/2D/Spine/Blend Modes/Skeleton Constant" {
Properties {
_Color ("Tint Color", Color) = (1,1,1,1)
[NoScaleOffset] _MainTex ("MainTex", 2D) = "black" {}
[Toggle(_STRAIGHT_ALPHA_INPUT)] _StraightAlphaInput("Straight Alpha Texture", Int) = 0
_Cutoff ("Shadow alpha cutoff", Range(0,1)) = 0.1
[MaterialToggle(_TINT_BLACK_ON)] _TintBlack("Tint Black", Float) = 0
_Black(" Dark Color", Color) = (0,0,0,0)
[HideInInspector] _StencilRef("Stencil Reference", Float) = 1.0
[Enum(UnityEngine.Rendering.CompareFunction)] _StencilComp("Stencil Comparison", Float) = 8 // Set to Always as default
}
SubShader {
Tags { "RenderPipeline" = "UniversalPipeline" "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
LOD 100
Fog { Mode Off }
Cull Off
ZWrite Off
Blend One OneMinusSrcColor
Lighting Off
Stencil {
Ref[_StencilRef]
Comp[_StencilComp]
Pass Keep
}
Pass {
Tags { "LightMode" = "Universal2D" }
HLSLPROGRAM
// Required to compile gles 2.0 with standard srp library
#pragma prefer_hlslcc gles
#pragma exclude_renderers d3d11_9x
// -------------------------------------
// Unity defined keywords
#pragma multi_compile_fog
//--------------------------------------
// GPU Instancing
#pragma multi_compile_instancing
//--------------------------------------
// Spine related keywords
#pragma shader_feature _ _STRAIGHT_ALPHA_INPUT
#pragma shader_feature _TINT_BLACK_ON
#pragma vertex vert
#pragma fragment constantColorFrag
#undef LIGHTMAP_ON
#define USE_URP
#define fixed4 half4
#define fixed3 half3
#define fixed half
#define APPLY_MATERIAL_TINT_COLOR
#include "../../Include/Spine-Input-URP.hlsl"
#include "../../Include/Spine-Skeleton-ForwardPass-URP.hlsl"
half4 constantColorFrag(VertexOutput i) : SV_Target
{
float4 texColor = tex2D(_MainTex, i.uv0);
#if defined(_ZWRITE)
clip(texColor.a * i.color.a - _Cutoff);
#endif
return float4(i.color.rgb, texColor.a * i.color.a);
}
ENDHLSL
}
}
}
With this new shader, I'm getting these results:
The color is still performing some kind of additive effect and the clipping is not taking the alpha into account.
This is the current shader inspector config: