【问题标题】:Fog Of War for Unity3DUnity3D的战争迷雾
【发布时间】:2015-09-22 16:45:39
【问题描述】:

我一直在试验战争迷雾。我一直在关注这个tutorial,显然这是unity 4,我正在使用unity 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"
}

【问题讨论】:

    标签: c# unity3d shader


    【解决方案1】:

    你在那个着色器中有一行写着:

    #pragma surface surf Lambert vertex:vert alpha:blend
    

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

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

    #pragma surface surf NoLighting noambient alpha:blend
    

    这应该可以解决问题。

    【讨论】:

    • 好的,谢谢。显然我对如何使用着色器一无所知。有办法解决这个问题吗?
    猜你喜欢
    • 2017-11-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-24
    • 1970-01-01
    • 2020-10-04
    相关资源
    最近更新 更多