MatCap_Plain.shader 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. // Upgrade NOTE: replaced '_World2Object' with 'unity_WorldToObject'
  2. // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObjectToClipPos(*)'
  3. // MatCap Shader, (c) 2015-2017 Jean Moreno
  4. Shader "MatCap/Vertex/Plain"
  5. {
  6. Properties
  7. {
  8. _Color ("Main Color", Color) = (0.5,0.5,0.5,1)
  9. _MatCap ("MatCap (RGB)", 2D) = "white" {}
  10. }
  11. Subshader
  12. {
  13. Tags { "RenderType"="Opaque" }
  14. Pass
  15. {
  16. Tags { "LightMode" = "Always" }
  17. CGPROGRAM
  18. #pragma vertex vert
  19. #pragma fragment frag
  20. #pragma fragmentoption ARB_precision_hint_fastest
  21. #pragma multi_compile_fog
  22. #include "UnityCG.cginc"
  23. struct v2f
  24. {
  25. float4 pos : SV_POSITION;
  26. float2 cap : TEXCOORD0;
  27. UNITY_FOG_COORDS(1)
  28. };
  29. v2f vert (appdata_base v)
  30. {
  31. v2f o;
  32. o.pos = UnityObjectToClipPos (v.vertex);
  33. float3 worldNorm = normalize(unity_WorldToObject[0].xyz * v.normal.x + unity_WorldToObject[1].xyz * v.normal.y + unity_WorldToObject[2].xyz * v.normal.z);
  34. worldNorm = mul((float3x3)UNITY_MATRIX_V, worldNorm);
  35. o.cap.xy = worldNorm.xy * 0.5 + 0.5;
  36. UNITY_TRANSFER_FOG(o, o.pos);
  37. return o;
  38. }
  39. uniform float4 _Color;
  40. uniform sampler2D _MatCap;
  41. float4 frag (v2f i) : COLOR
  42. {
  43. float4 mc = tex2D(_MatCap, i.cap);
  44. mc = _Color * mc * 2.0;
  45. UNITY_APPLY_FOG(i.fogCoord, mc);
  46. return mc;
  47. }
  48. ENDCG
  49. }
  50. }
  51. Fallback "VertexLit"
  52. }