统一着色器中的下标无效

问题描述 投票:-1回答:1

对于着色器编码来说我还很陌生,但是我通过将2个未着色的着色器分组来完成了这一工作当我尝试制作此着色器时,该着色器旨在创建轮廓并让我对2个纹理进行插值,这表明存在此错误:第61行的下标“顶点”无效

我已经尝试了一些方法,但是如果有人知道我必须做些什么,那么我将无法使此着色器正常工作

Shader "Unlit/Combined"
{
    Properties
    {
        _MainTex("Texture", 2D) = "white" {}
        _SecondaryTex("Secondary Texture", 2D) = "white" {}
        _LerpValue("Transition float", Range(0,1)) = 0.5

        _OutlineColor("Outline color", color) = (0,0,0,1)
        _OutlineWidth("Outline width", Range(1.0,5.0)) = 1.01
    }





        SubShader
        {
            Tags { "RenderType" = "Opaque"  "Queue" = "Transparent"}
            LOD 100

            Pass
            {
                CGPROGRAM

                #pragma vertex vert
                #pragma fragment frag

                // make fog work
                #pragma multi_compile_fog

                #include "UnityCG.cginc"

                struct appdata
                {
                    //float4 vertex : POSITION;
                    float2 uv : TEXCOORD0;
                    float3 normal : NORMAL;
                };

                struct v2f
                {
                    float2 uv : TEXCOORD0;
                    UNITY_FOG_COORDS(1)
                    float4 outvertex : SV_POSITION;
                    float4 pos : POSITION;
                    float3 normal : NORMAL;
                };

                sampler2D _MainTex;
                float4 _MainTex_ST;
                sampler2D _SecondaryTex;
                float4 _SecondaryTex_ST;
                float _LerpValue;
                float _OutlineWidth;
                float4 _OutlineColor;

                v2f vert(appdata v)
                {
                    v2f o;
                    v.vertex.xyz *= _OutlineWidth;
                    o.outvertex = UnityObjectToClipPos(v.vertex);
                    o.pos = UnityObjectToClipPos(v.vertex);
                    o.uv = TRANSFORM_TEX(v.uv, _MainTex);
                    UNITY_TRANSFER_FOG(o,o.vertex);
                    return o;
                }

                fixed4 frag(v2f i) : SV_Target
                {
                    // sample the texture
                    fixed4 col = lerp(tex2D(_MainTex, i.uv),tex2D(_SecondaryTex, i.uv), _LerpValue);

                    return col;
                    return _OutlineColor;
                }

                ENDCG
            }


            Pass//Normal render
            {
                ZWrite On

                Material
                {
                    Diffuse[_Color]
                    Ambient[_Color]
                }

                Lighting On

                SetTexture[_MainTex]
                {
                    ConstantColor[_Color]
                }

                SetTexture[_MainTex]
                {
                    Combine previous * primary DOUBLE
                }

            }
        }
}
c# visual-studio unity3d shader
1个回答
1
投票

有问题的行是第61行:

© www.soinside.com 2019 - 2024. All rights reserved.