Feel Physics Backyard

HoloLensの出張授業をする会社で、教材を開発しています

特定のメッシュの色を変えるシェーダプログラミング、おまじないを省いたコード付き

f:id:weed_7777:20171101102718g:plain

おまじないを省いたコード

Shader "Custom/MyShader53-2" {
    customData = sin(v.vertex.y + _Time.x * 20);
    color += float4(1.0, 0.0, 0.0, 1.0) * customData;
    o.Albedo = tex2D(uv_Texture).rgb;
}

全コード

Shader "Custom/MyShader53-2" {
    Properties {
        _Taxture( "Texture", 2D ) = "white" {}
    }
    SubShader {
        Tags { "RenderType"="Opaque" }
        CGPROGRAM
        #pragma surface surf Lambert finalcolor:mycolor vertex:myvert
        struct Input {
            float2 uv_Texture;
            float customData;
        };
        sampler2D _Taxture;

        void myvert( inout appdata_full v, out Input data ) {
            UNITY_INITIALIZE_OUTPUT(Input, data);
            data.customData = sin(v.vertex.y + _Time.x * 20);
        }

        void mycolor(Input IN, SurfaceOutput o, inout fixed4 color) {
            color += float4(1.0, 0.0, 0.0, 1.0) * IN.customData;
        }

        void surf (Input IN, inout SurfaceOutput o) {
            o.Albedo = tex2D(_Taxture, IN.uv_Texture).rgb;
        }
        ENDCG
    }
    FallBack "Diffuse"
}