3
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

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 に渡しましょう
3
3
0

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
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?