!!!頂点カラーの反映 Surface Shaderとして以下のように記述。 VertexColor.shader Shader "Custom/Vertex color" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Lambert // サーフェスShaderとしての処理. sampler2D _MainTex; struct Input { float2 uv_MainTex; float4 color : COLOR; // 頂点カラーを受け取る. }; void surf (Input IN, inout SurfaceOutput o) { half4 c = tex2D (_MainTex, IN.uv_MainTex); c *= IN.color; // 頂点カラーの反映. o.Albedo = c.rgb; o.Alpha = c.a; } ENDCG } Fallback "Diffuse" } Meshを生成したときに「Mesh.colors」にColorの配列を渡すと、それが頂点カラーになります。 なお、格納する要素数はverticesと同じである必要があります。 !!影響度を指定 Shaderのパラメータとして「Influence」というのを追加。 これは0.0-1.0の数値を指定することができ、1.0に近づくほど頂点カラーの影響を受けます。 VertexColor.shader Shader "Custom/Vertex color" { Properties { _MainTex ("Base (RGB)", 2D) = "white" {} _Influence ("Influence", Range(0, 1)) = 1.0 // <== これを追加. } SubShader { Tags { "RenderType"="Opaque" } LOD 200 CGPROGRAM #pragma surface surf Lambert // サーフェスShaderとしての処理. sampler2D _MainTex; float _Influence; // <== これを追加. struct Input { float2 uv_MainTex; float4 color : COLOR; // 頂点カラーを受け取る. }; void surf (Input IN, inout SurfaceOutput o) { half4 c = tex2D (_MainTex, IN.uv_MainTex); c *= (IN.color * _Influence) + (half4(1, 1, 1, 1) * (1.0f - _Influence)); // <== 変更. o.Albedo = c.rgb; o.Alpha = c.a; } ENDCG } Fallback "Diffuse" } ---- {{lastmodified}}