MatCap_Lit.shader 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
  2. // MatCap Shader, (c) 2015-2017 Jean Moreno
  3. Shader "MatCap/Vertex/Textured Lit"
  4. {
  5. Properties
  6. {
  7. _Color ("Color", Color) = (0.5,0.5,0.5,1)
  8. _MainTex ("Base (RGB)", 2D) = "white" {}
  9. _MatCap ("MatCap (RGB)", 2D) = "white" {}
  10. }
  11. SubShader
  12. {
  13. Tags { "RenderType"="Opaque" }
  14. LOD 200
  15. CGPROGRAM
  16. #pragma surface surf Lambert vertex:vert
  17. sampler2D _MainTex;
  18. sampler2D _MatCap;
  19. float4 _Color;
  20. struct Input
  21. {
  22. half2 uv_MainTex : TEXCOORD0;
  23. float2 matcapUV;
  24. };
  25. void vert (inout appdata_full v, out Input o)
  26. {
  27. UNITY_INITIALIZE_OUTPUT(Input,o);
  28. float3 worldNorm = normalize(unity_WorldToObject[0].xyz * v.normal.x + unity_WorldToObject[1].xyz * v.normal.y + unity_WorldToObject[2].xyz * v.normal.z);
  29. worldNorm = mul((float3x3)UNITY_MATRIX_V, worldNorm);
  30. o.matcapUV = worldNorm.xy * 0.5 + 0.5;
  31. }
  32. void surf (Input IN, inout SurfaceOutput o)
  33. {
  34. half4 c = tex2D(_MainTex, IN.uv_MainTex);
  35. half4 mc = tex2D(_MatCap, IN.matcapUV);
  36. o.Albedo = c.rgb * mc.rgb * _Color.rgb * 2.0;
  37. }
  38. ENDCG
  39. }
  40. Fallback "VertexLit"
  41. }