将透明的着色器更改为彩色黑色(统一)



我想在这里做的是我想让这头发变成黑色。我更改了检查员上的颜色色调,但仍然没有起作用。

这是我的发型剂到目前为止我的代码:

Shader "Custom/Paul/Hair" {
Properties {
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
_Color ("Color Tint", Color) = (1,1,1,1) 
}
SubShader {
    Tags {"Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent"}
    LOD 100
    ZWrite off
    Lighting Off
    Blend SrcAlpha OneMinusSrcAlpha
    Cull back
    Pass {
        CGPROGRAM
             #pragma vertex vert
             #pragma fragment frag
             #pragma multi_compile_fog
             #include "UnityCG.cginc"
             struct appdata_t {
                 float4 vertex : POSITION;
                 float2 texcoord : TEXCOORD0;
             };
             struct v2f {
                 float4 vertex : SV_POSITION;
                 half2 texcoord : TEXCOORD0;
                 UNITY_FOG_COORDS(1)
                 half4 color: COLOR;
             };
             sampler2D _MainTex;
             float4 _MainTex_ST;
             v2f vert (appdata_t v)
             {
                 v2f o;
                 o.vertex = UnityObjectToClipPos(v.vertex);
                 o.texcoord = TRANSFORM_TEX(v.texcoord, _MainTex);
                 UNITY_TRANSFER_FOG(o,o.vertex);
                 return o;
             }
             fixed4 frag (v2f i) : SV_Target
             {
                 fixed4 col = tex2D(_MainTex, i.texcoord);
                 //fixed4 col = tex2D(_MainTex, i.texcoord) * _Color;
                 UNITY_APPLY_FOG(i.fogCoord, col);
                 return col;
             }
        ENDCG
    }
  }
}

我尝试更改属性中的颜色色彩,但不会改变头发的颜色。有没有一种方法可以在着色器属性中动态更改头发颜色,即使仅仅在代码上也不是在着色器属性中。对不起,我的英语不好。

还有一件事。我没有任何错误。

我最终做到了。

Shader "Custom/Paul/Hair" {

Properties
{
    _MainTex ("Texture", 2D) = "white" {}
    _Color("Color", Color) = (1,1,1,1)
}
SubShader
{
    Tags{ "Queue" = "AlphaTest" "RenderType" = "TransparentCutout" "IgnoreProjector" = "True" }
    LOD 100
    Blend SrcAlpha OneMinusSrcAlpha
    ZWrite off
    Lighting Off
    Cull back
    Pass
    {
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"
        struct appdata
        {
            float4 vertex : POSITION;
            float2 uv : TEXCOORD0;
        };
        struct v2f
        {
            float4 vertex : SV_POSITION;
            half2 uv : TEXCOORD0;
        };
        float4 _MainTex_ST;
        sampler2D _MainTex;
        fixed4 _Color;
        v2f vert (appdata v)
        {
            v2f o = (v2f)0;
            o.vertex = UnityObjectToClipPos(v.vertex);
            o.uv = TRANSFORM_TEX(v.uv, _MainTex);
            o.uv = v.uv;
            return o;
        }
        fixed4 frag (v2f i) : SV_Target
        {
            fixed4 col = tex2D(_MainTex, i.uv) * _Color;
            return col;
        }
        ENDCG
    }
}

这可能有助于其他与我面临同一问题的人。

最新更新