MatCap_TextureMult.shader 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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/Textured Multiply"
  5. {
  6. Properties
  7. {
  8. _MainTex ("Base (RGB)", 2D) = "white" {}
  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 uv : TEXCOORD0;
  27. float2 cap : TEXCOORD1;
  28. UNITY_FOG_COORDS(2)
  29. };
  30. uniform float4 _MainTex_ST;
  31. v2f vert (appdata_base v)
  32. {
  33. v2f o;
  34. o.pos = UnityObjectToClipPos (v.vertex);
  35. o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
  36. half2 capCoord;
  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 sampler2D _MainTex;
  44. uniform sampler2D _MatCap;
  45. fixed4 frag (v2f i) : COLOR
  46. {
  47. fixed4 tex = tex2D(_MainTex, i.uv);
  48. fixed4 mc = tex2D(_MatCap, i.cap) * tex * 2.0;
  49. UNITY_APPLY_FOG(i.fogCoord, mc);
  50. return mc;
  51. }
  52. ENDCG
  53. }
  54. }
  55. Fallback "VertexLit"
  56. }