03_use_Struct

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,)' with 'UnityObjectToClipPos()'

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,)' with 'UnityObjectToClipPos()'

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,)' with 'UnityObjectToClipPos()'

// Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,)' with 'UnityObjectToClipPos()'

shader "xxg/03_useSturct"
{
Properties{

}
SubShader
{
    Pass{
    CGPROGRAM
    //顶点函数,这里只是声明了,顶点函数的函数名

pragma vertex vert

    //片元函数,这里只是声明了,片元函数的函数名
    //基本作用,返回模型对应的屏幕上的每一个像素的颜色值

pragma fragment frag

    struct a2v {

    float4 vertex:POSITION;//告诉Unity把模型空间下的顶点坐标填充该vertex;
    float3 normal:NORMAL;//告诉Unity把模型空间下的法线方向填充给normal;
    float4 texcoord:TEXCOORD0;//告诉Unity把第一套纹理坐标填充给texcoord
    };
struct v2f {
    float4 position: SV_POSITION;
    float3 temp:COLOR0;
};
v2f vert(a2v v) {
    v2f f;
    //f.position=UnityObjectToClipPos(v.vertex);
    f.position = UnityObjectToClipPos(v.vertex);
    f.temp = v.normal;
    return f;
}
fixed4 frag(v2f f) :SV_TARGET{
//return fixed4(0.5,0.5,0.5,0.5);
    return fixed4(f.temp,1);
}


    ENDCG
}
}
    Fallback "VertexLit"

}

你可能感兴趣的:(03_use_Struct)