FaceShader.shader 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. Shader "Custom/FaceShader"
  2. {
  3. Properties
  4. {
  5. _MainTex("Main", 2D) = "white" {}
  6. _Eyes("Eyes", 2D) = "white" {}
  7. _EyesTint("EyesTint", Color) = (1.0, 1.0, 1.0, 1.0)
  8. _Eyelines("Eyelines", 2D) = "white" {}
  9. _EyelinesTint("EyelinesTint", Color) = (1.0, 1.0, 1.0, 1.0)
  10. _EyeShadows("EyeShadows", 2D) = "white" {}
  11. _EyeShadowsTint("EyeShadowsTint", Color) = (1.0, 1.0, 1.0, 1.0)
  12. _Lips("Lips", 2D) = "white" {}
  13. _LipsTint("LipsTint", Color) = (1.0, 1.0, 1.0, 1.0)
  14. }
  15. SubShader
  16. {
  17. Tags{ "RenderType" = "Opaque" }
  18. LOD 100
  19. Pass
  20. {
  21. CGPROGRAM
  22. #pragma vertex vert
  23. #pragma fragment frag
  24. #pragma multi_compile_fog
  25. #include "UnityCG.cginc"
  26. struct appdata
  27. {
  28. float4 vertex : POSITION;
  29. float2 uv : TEXCOORD0;
  30. };
  31. struct v2f
  32. {
  33. float2 uv : TEXCOORD0;
  34. UNITY_FOG_COORDS(1)
  35. float4 vertex : SV_POSITION;
  36. };
  37. sampler2D _MainTex;
  38. float4 _MainTex_ST;
  39. sampler2D _Eyes;
  40. float4 _Eyes_ST;
  41. float4 _EyesTint;
  42. sampler2D _Eyelines;
  43. float4 _Eyelines_ST;
  44. float4 _EyelinesTint;
  45. sampler2D _EyeShadows;
  46. float4 _EyeShadows_ST;
  47. float4 _EyeShadowsTint;
  48. sampler2D _Lips;
  49. float4 _Lips_ST;
  50. float4 _LipsTint;
  51. v2f vert(appdata v)
  52. {
  53. v2f o;
  54. o.vertex = UnityObjectToClipPos(v.vertex);
  55. o.uv = TRANSFORM_TEX(v.uv, _MainTex);
  56. UNITY_TRANSFER_FOG(o,o.vertex);
  57. return o;
  58. }
  59. fixed4 getColor(half4 overlay)
  60. {
  61. return (1 - overlay.a) + (overlay.rgba * overlay.a);
  62. }
  63. fixed4 frag(v2f i) : SV_Target
  64. {
  65. half4 eyesColor = tex2D(_Eyes, i.uv) * _EyesTint;
  66. half4 eyelinesColor = tex2D(_Eyelines, i.uv) * _EyelinesTint;
  67. half4 eyeShadowsColor = tex2D(_EyeShadows, i.uv) * _EyeShadowsTint;
  68. half4 lipsColor = tex2D(_Lips, i.uv) * _LipsTint;
  69. fixed4 col = tex2D(_MainTex, i.uv);
  70. UNITY_APPLY_FOG(i.fogCoord, col);
  71. fixed4 result = col.rgba * (getColor(eyesColor) * getColor(eyeShadowsColor) * getColor(eyelinesColor) * getColor(lipsColor));
  72. result.a = 1;
  73. return result;
  74. }
  75. ENDCG
  76. }
  77. }
  78. }