MatCap_TextureAdd.shader 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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 Add"
  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. float3 worldNorm = normalize(unity_WorldToObject[0].xyz * v.normal.x + unity_WorldToObject[1].xyz * v.normal.y + unity_WorldToObject[2].xyz * v.normal.z);
  37. worldNorm = mul((float3x3)UNITY_MATRIX_V, worldNorm);
  38. o.cap.xy = worldNorm.xy * 0.5 + 0.5;
  39. UNITY_TRANSFER_FOG(o, o.pos);
  40. return o;
  41. }
  42. uniform sampler2D _MainTex;
  43. uniform sampler2D _MatCap;
  44. fixed4 frag (v2f i) : COLOR
  45. {
  46. fixed4 tex = tex2D(_MainTex, i.uv);
  47. fixed4 mc = (tex + (tex2D(_MatCap, i.cap)*2.0) - 1.0);
  48. UNITY_APPLY_FOG(i.fogCoord, mc);
  49. return (tex + (mc*2.0)-1.0);
  50. }
  51. ENDCG
  52. }
  53. }
  54. Fallback "VertexLit"
  55. }