Unity着色器 - 语法错误

时间:2015-09-20 13:47:46

标签: shader

我尝试着色器但是我有一些语法错误。我不明白。 语法错误来自行:

void surf(Input IN, inout SurfaceOuput o)
float3 projNormal = saturate(pow(IN.worldNormal * 1.4, 4));
if (IN.worldNormal > 0)

代码是:

    shader "Triplanar" {
    Properties {
        _Side("Side",2D) = "white"{}
        _Top("Top",2D) = "white"{}
        _Bottom("Bottom",2D) = "white"{}
        _SideScale("Side Scale",float) = 2
        _TopScale("Top Scale",float) = 2
        _BottomScale("Bottom Scale",float) = 2
    }
        SubShader{
            Tags {
                "queue"="Geometry"
                "IgnoreProjector"="False"
                "RenderType"="Opaque"
            }
            Cull Back

                ZWrite on

                CGPROGRAM
                #pragma surface surf Lambert
                #pragma exlude_renderers flash

                sampler2D _Side, _Top, _Bottom;
                float _SideScale, _TopScale, _BottomScale;

        struct Input {
            float3 worldPos;
            float3 worldNormal;
        };

        void surf(Input IN, inout SurfaceOuput o) 
        {
            float3 projNormal = saturate(pow(IN.worldNormal * 1.4, 4));

            //side x
            float3 x = tex2D(_Side, frac(IN.worldPos.zy * _SideScale)) * abs(IN.worldNormal.x);

            //top and bottom
            float3 y = 0;
            if (IN.worldNormal > 0)
            {
                y = tex2D(_Top, frac(IN.worldPos.zx * _TopScale)) * abs(IN.worldNormal.y);
            }
            else
            {
                y = tex2D(_Bottom, frac(IN.worldPos.zs * _BottomScale)) * abs(IN.worldNormal.y);
            }

            // side z

            float3 z tex2D(_Side, frac(IN.worldPos.xy * _SideScale)) * abs(IN.worldNormal.z);

            o.Albedo = z;
            o.Albedo = lerp(o.Albedo, x, projNormal.x)
            o.Albedo = lerp(o.Albedo, y, projNormal.y)


        }
        ENDCG
    } 
    FallBack "Diffuse"
} 

0 个答案:

没有答案