MatCap_Plain_Additive.shader 1.5 KB

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