Preview_DesaturateNode.shader 650 B

1234567891011121314151617181920212223242526272829303132333435
  1. Shader "Hidden/DesaturateNode"
  2. {
  3. Properties
  4. {
  5. _A ( "_RBG", 2D ) = "white" {}
  6. _B ( "_Fraction", 2D ) = "white" {}
  7. }
  8. SubShader
  9. {
  10. Pass
  11. {
  12. CGPROGRAM
  13. #include "UnityCG.cginc"
  14. #include "Preview.cginc"
  15. #pragma vertex vert_img
  16. #pragma fragment frag
  17. uniform sampler2D _A;
  18. uniform sampler2D _B;
  19. float4 frag ( v2f_img i ) : SV_Target
  20. {
  21. float3 rgb = tex2D ( _A, i.uv ).rgb;
  22. float fraction = tex2D ( _B, i.uv ).r;
  23. float dotResult = dot ( rgb, float3( 0.299, 0.587, 0.114 ) );
  24. float3 finalColor = lerp ( rgb, dotResult.xxx, fraction );
  25. return float4( finalColor, 1 );
  26. }
  27. ENDCG
  28. }
  29. }
  30. }