Billboard (LookAt camera) vert
https://forum.unity.com/threads/standard-surface-shader-billboard.513060/
void vert(inout appdata_full v, out Input o) { UNITY_INITIALIZE_OUTPUT(Input, o); // apply object scale v.vertex.xy *= float2(length(unity_ObjectToWorld._m00_m10_m20), length(unity_ObjectToWorld._m01_m11_m21)); // get the camera basis vectors float3 forward = -normalize(UNITY_MATRIX_V._m20_m21_m22); float3 up = normalize(UNITY_MATRIX_V._m10_m11_m12); float3 right = normalize(UNITY_MATRIX_V._m00_m01_m02); // rotate to face camera float4x4 rotationMatrix = float4x4(right, 0, up, 0, forward, 0, 0, 0, 0, 1); v.vertex = mul(v.vertex, rotationMatrix); v.normal = mul(v.normal, rotationMatrix); // undo object to world transform surface shader will apply v.vertex.xyz = mul((float3x3)unity_WorldToObject, v.vertex.xyz); v.normal = mul(v.normal, (float3x3)unity_ObjectToWorld); }
Unity シェーダーチュートリアル 基本とサーフェースシェーダー – Tsumiki Tech Times|積木製作
#pragma surface 関数名 ライティングモデル オプション
Standard
Unity5 で追加された物理ベースライティングモデル。
Lambert
100%拡散反射モデル。
ライトを当ててもスペキュラ(光源の強い反射)がでません。
リフレクションプローブが適用されません。
BlinnPhong
スペキュラライティングモデル。
パラメーターでスペキュラ(光源の強い反射)を調節できます。
リフレクションプローブが適用されません。
surface shaderでのラインティングカスタム
サーフェスシェーダーの記述
struct SurfaceOutput { fixed3 Albedo; // diffuse color fixed3 Normal; // tangent space normal, if written fixed3 Emission; half Specular; // specular power in 0..1 range fixed Gloss; // specular intensity fixed Alpha; // alpha for transparencies }; struct SurfaceOutputStandard { fixed3 Albedo; // base (diffuse or specular) color fixed3 Normal; // tangent space normal, if written half3 Emission; half Metallic; // 0=non-metal, 1=metal half Smoothness; // 0=rough, 1=smooth half Occlusion; // occlusion (default 1) fixed Alpha; // alpha for transparencies }; struct SurfaceOutputStandardSpecular { fixed3 Albedo; // diffuse color fixed3 Specular; // specular color fixed3 Normal; // tangent space normal, if written half3 Emission; half Smoothness; // 0=rough, 1=smooth half Occlusion; // occlusion (default 1) fixed Alpha; // alpha for transparencies };