LoginSignup
3

More than 5 years have passed since last update.

Unity 頂点カラーを反映するシェーダー

Posted at

エフェクトとか作ってると頂点単位で色が変えたくなりますよね。

VertexColor.shader
Shader "Custom/VertexColor" {
    SubShader {
        CGPROGRAM
        #pragma surface surf Lambert 

        struct Input {
            float4 color : COLOR;
        };

        void surf(Input IN, inout SurfaceOutput o) {
            o.Albedo = IN.color.rgb;
        }
        ENDCG
    }
}

ポイント:

  • サーフェースシェーダーを使う
  • Input 構造体に COLOR を指定すると頂点カラーが渡ってくる
  • あとはお好みで加工して SurfaceOutput に渡しましょう

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3