Home > front end >  I can't understand the result of my fragment shader
I can't understand the result of my fragment shader

Time:09-22

I'm very newbie at unity shader programming. And I've tried some lines of Shader codes. But I couldn't understand the result of it.

Here's my shader codes.

Shader "Test/MyShader"{
Properties
{}

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

    Pass
    {
        CGPROGRAM
        #pragma vertex vert
        #pragma fragment frag
        #include "UnityCG.cginc"

        struct vertInput
        {
            float4 vertex : POSITION;
        };

        struct fragInput
        {
            float4 vertex : SV_POSITION;
        };

        fragInput vert (vertInput IN)
        {
            fragInput o;
            o.vertex = UnityObjectToClipPos(IN.vertex);
            return o;
        }

        fixed4 frag (fragInput IN) : SV_Target
        {
            return fixed4(IN.vertex);
        }
        ENDCG
    }
}

}

I applied this shader code to the normal Plane. I expected the result to be seemed like spectrums. But what I've got is very different from what I've expected.

enter image description here

Usefull links:

  • Related