Skip to content

Instantly share code, notes, and snippets.

@tsubaki
Created June 30, 2016 15:08
Show Gist options
  • Save tsubaki/ab36101f2df6a1973b36fe2932625970 to your computer and use it in GitHub Desktop.
Save tsubaki/ab36101f2df6a1973b36fe2932625970 to your computer and use it in GitHub Desktop.
頂点カラー付きシェーダー
Shader "Particle/StandardVertex" {
Properties{
_Color("Color", Color) = (1,1,1,1)
_MainTex("Albedo (RGB)", 2D) = "white" {}
_Glossiness("Smoothness", Range(0,1)) = 0.5
_Metallic("Metallic", Range(0,1)) = 0.0
}
SubShader{
Tags{ "RenderType" = "Opaque" }
LOD 200
CGPROGRAM
#pragma surface surf Standard vertex:vert fullforwardshadows
#pragma target 3.0
struct Input {
float2 uv_MainTex;
float3 vertexColor; // 頂点カラーを格納する
};
void vert(inout appdata_full v, out Input o)
{
UNITY_INITIALIZE_OUTPUT(Input,o);
o.vertexColor = v.color; // パーティクルの頂点カラーを取得
}
sampler2D _MainTex;
half _Glossiness;
half _Metallic;
fixed4 _Color;
void surf(Input IN, inout SurfaceOutputStandard o)
{
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
o.Albedo = c.rgb * IN.vertexColor; // 頂点カラーを流し込む
o.Metallic = _Metallic;
o.Smoothness = _Glossiness;
o.Alpha = c.a;
}
ENDCG
}
FallBack "Diffuse"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment