Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Shader "Custom/Particles/Ramp" {
- Properties{
- _MainTex("Particle Texture", 2D) = "white" {}
- _RampBlack("Ramp Black", Color) = (0, 0, 0, 1)
- _RampWhite("Ramp White", Color) = (1, 1, 1, 1)
- }
- Category{
- Tags{ "Queue" = "Transparent" "IgnoreProjector" = "True" "RenderType" = "Transparent" }
- Blend SrcAlpha OneMinusSrcAlpha
- AlphaTest Greater .01
- ColorMask RGB
- Cull Off Lighting Off ZWrite Off Fog{ Color(0,0,0,0) }
- BindChannels{
- Bind "Color", color
- Bind "Vertex", vertex
- Bind "TexCoord", texcoord
- }
- SubShader{
- Pass{
- CGPROGRAM
- #pragma vertex vert
- #pragma fragment frag
- #pragma fragmentoption ARB_precision_hint_fastest
- #pragma fragmentoption ARB_fog_exp2
- #include "UnityCG.cginc"
- sampler2D _MainTex;
- float4 _RampBlack;
- float4 _RampWhite;
- struct appdata_t {
- float4 vertex : POSITION;
- float4 color : COLOR;
- float2 texcoord : TEXCOORD0;
- };
- struct v2f {
- float4 vertex : POSITION;
- float4 color : COLOR;
- float2 texcoord : TEXCOORD0;
- };
- float4 _MainTex_ST;
- v2f vert(appdata_t v)
- {
- v2f o;
- o.vertex = UnityObjectToClipPos(v.vertex);
- o.color = v.color;
- o.texcoord = TRANSFORM_TEX(v.texcoord,_MainTex);
- return o;
- }
- half4 frag(v2f i) : COLOR
- {
- float4 color = i.color * tex2D(_MainTex, i.texcoord);
- float grayscale = (color.r + color.g + color.b) / 3;
- float lerpR = _RampBlack.r + (_RampWhite.r - _RampBlack.r) * grayscale;
- float lerpG = _RampBlack.g + (_RampWhite.g - _RampBlack.g) * grayscale;
- float lerpB = _RampBlack.b + (_RampWhite.b - _RampBlack.b) * grayscale;
- return half4 (lerpR, lerpG, lerpB, color.a);
- }
- ENDCG
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment