unity vert-frag 着色器中的纹理色调

问题描述

我对统一着色器非常陌生。 (和英语) 我无法在我的项目中使用着色器图(更改所有材质为时已晚), 所以我尝试修改

https://gist.github.com/keijiro/b91fd4c1a711a0fd3295

https://gamedev.stackexchange.com/questions/135375/animated-textures-for-models-how-to-write-a-shader

这些代码并设法使这个着色器着色并使纹理移动。 但我想要的是只移动主纹理而不是色调纹理。 我该如何解决这个问题?

Shader "Unlit/MovingAdditive"
{
Properties
{
    _TintColor("Tint Color",Color) = (0.5,0.5,0.5)
    _MainTex("Particle Texture",2D) = "white" {}
    _ScrollSpeeds("Scroll Speeds",vector) = (-5,-20,0)
    _TintTex("Mixture Texture",2D) = "white" {}
}

    CGINCLUDE

#include "UnityCG.cginc"

sampler2D _MainTex;
sampler2D _TintTex;
float4 _MainTex_ST;
float4 _Tint_ST;
fixed4 _TintColor;
float4 _ScrollSpeeds;

struct appdata_t
{
    float4 position : POSITION;
    float4 texcoord : TEXCOORD0;
    fixed4 color : COLOR;
};

struct v2f
{
    float4 position : SV_POSITION;
    float2 texcoord : TEXCOORD0;
    fixed4 color : COLOR;
    UNITY_FOG_COORDS(1)
};

v2f vert(appdata_t v)
{
    v2f o;
    o.position = UnityObjectToClipPos(v.position);
    o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
    o.color = v.color;
    UNITY_TRANSFER_FOG(o,o.vertex);
    o.texcoord += _ScrollSpeeds * _Time.x;
    return o;
}

fixed4 frag(v2f i) : SV_Target
{

//something wrong here

    fixed4 col = 2.0f * i.color * _TintColor * tex2D(_MainTex,i.texcoord) * tex2D(_TintTex,i.texcoord);
    UNITY_APPLY_FOG_COLOR(i.fogCoord,col,(fixed4)0);
    return col;
}

ENDCG

SubShader
{
    Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }

        Blend SrcAlpha One
        Cull Off Lighting Off ZWrite Off Fog{ Mode Off }

        Pass
    {
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #pragma multi_compile_particles
        #pragma multi_compile_fog
        ENDCG
    }
}
}

我想看到的(着色移动主纹理): enter image description here

我现在看到的(着色的主要纹理在移动): enter image description here

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)