Unity3D的战争迷雾

时间:2015-09-22 07:34:52

标签: c# unity3d shader

我一直在试验战争迷雾。我一直关注这个tutorial显然这是团结4而且我使用了团结5,我现在得到了这个错误:

  

表面着色器顶点函数' vert'找不到

我在这个youtube视频的评论部分阅读,我跟着他们,但它给了我错误。尝试了原始版本(视频中的那个版本),但它使我的平面始终位于下方,即使它的y轴为零,主要地图的y轴为-10。

顺便说一下,这是我的着色器的代码:

Shader "Custom/FogOWarShader" {
Properties {
    _Color ("Main Color", Color) = (1,1,1,1)
    _MainTex ("Base (RGB)", 2D) = "white" {}
}
SubShader {
    Tags { "RenderType"="Transparent" "LightMode"="ForwardBase" }
    Blend SrcAlpha  OneMinusSrcAlpha
    Lighting Off
    LOD 200

    CGPROGRAM

    //#pragma surface surf NoLighting Lambert alpha:blend --the one that makes the map always on top
    #pragma surface surf Lambert vertex:vert alpha:blend

    fixed4 LightingNoLighting(SurfaceOutput s, fixed3 lightDir, float aten){

        fixed4 color;
        color.rgb = s.Albedo;
        color.a = s.Alpha;
        return color;

    }

    fixed4 _Color;
    sampler2D _MainTex;

    struct Input {
        float2 uv_MainTex;
    };


    void surf (Input IN, inout SurfaceOutput o) {

        half4 baseColor = tex2D (_MainTex, IN.uv_MainTex);
        o.Albedo = _Color.rgb * baseColor.b;
        o.Alpha = _Color.a - baseColor.g;
        }
        ENDCG
    } 
    FallBack "Diffuse"
}

1 个答案:

答案 0 :(得分:1)

你在该着色器中有一行说:

#pragma surface surf Lambert vertex:vert alpha:blend

所以你说你有一个名为vert的顶点着色器,但是在你的其余代码中没有这样的函数。这就是它的抱怨。

看了一下实际的着色器,你需要做的就是设置混合。您可以通过将原始着色器中的pragma修改为

来实现
#pragma surface surf NoLighting noambient alpha:blend

这应该可以解决问题。

相关问题