MatCap_Plain_AdditiveZ.shader 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 Additive Z"
  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 { "Queue"="Transparent" "IgnoreProjector"="True" "RenderType"="Transparent" }
  14. Lighting Off
  15. Pass
  16. {
  17. ColorMask 0
  18. }
  19. Pass
  20. {
  21. ZWrite Off
  22. Cull Off
  23. Blend One OneMinusSrcColor
  24. ColorMask RGB
  25. Lighting Off
  26. Tags { "LightMode" = "Always" }
  27. CGPROGRAM
  28. #pragma vertex vert
  29. #pragma fragment frag
  30. #pragma fragmentoption ARB_precision_hint_fastest
  31. #pragma multi_compile_fog
  32. #include "UnityCG.cginc"
  33. struct v2f
  34. {
  35. float4 pos : SV_POSITION;
  36. float2 cap : TEXCOORD0;
  37. UNITY_FOG_COORDS(1)
  38. };
  39. v2f vert (appdata_base v)
  40. {
  41. v2f o;
  42. o.pos = UnityObjectToClipPos (v.vertex);
  43. half2 capCoord;
  44. float3 worldNorm = normalize(unity_WorldToObject[0].xyz * v.normal.x + unity_WorldToObject[1].xyz * v.normal.y + unity_WorldToObject[2].xyz * v.normal.z);
  45. worldNorm = mul((float3x3)UNITY_MATRIX_V, worldNorm);
  46. o.cap.xy = worldNorm.xy * 0.5 + 0.5;
  47. UNITY_TRANSFER_FOG(o, o.pos);
  48. return o;
  49. }
  50. uniform float4 _Color;
  51. uniform sampler2D _MatCap;
  52. float4 frag (v2f i) : COLOR
  53. {
  54. float4 mc = tex2D(_MatCap, i.cap) * _Color * 2.0;
  55. UNITY_APPLY_FOG_COLOR(i.fogCoord, mc, float4(0,0,0,0));
  56. return mc;
  57. }
  58. ENDCG
  59. }
  60. }
  61. Fallback "VertexLit"
  62. }