#pragma vertex vert #pragma fragment frag #include "UnityCG.cginc" struct VertexInput { float4 vertex : POSITION; float3 normal : NORMAL; }; struct VertexOutput { float4 pos : SV_POSITION; float4 posWorld : TEXCOORD0; float3 normalDir : TEXCOORD1; }; VertexOutput vert (VertexInput v) { VertexOutput o = (VertexOutput)0; o.normalDir = UnityObjectToWorldNormal(v.normal); o.posWorld = mul(_Object2World, v.vertex); o.pos = mul(UNITY_MATRIX_MVP, v.vertex ); TRANSFER_VERTEX_TO_FRAGMENT(o) return o; } float4 frag(VertexOutput i) : COLOR { i.normalDir = normalize(i.normalDir); float3 normalDirection = i.normalDir; float3 lightDirection = normalize(_WorldSpaceLightPos0.xyz); float node_64 = max(0,dot(i.normalDir,lightDirection)); float3 emissive = float3(node_64,node_64,node_64); float3 finalColor = emissive; return fixed4(finalColor,1); } ENDCG 同じもの