Particle-Transparent(Additive) Grayscale Shader

Use bwBlend to change saturation
Use alpha to fade object in and out

Shader “Custom/BulletDesat” {
Properties {
_MainTex (“Base (RGB)”, 2D) = “white” {}
_bwBlend (“Black & White blend”, Range (0, 1)) = 0
_alpha (“Alpha”, Range(0, 1)) = 0
}
SubShader {
Tags { “Queue”=”Transparent” “IgnoreProjector”=”True” “RenderType”=”Transparent” }
Blend SrcAlpha One
Cull Off Lighting Off ZWrite Off Fog { Color (0,0,0,0) }
Pass {
CGPROGRAM
#pragma vertex vert_img
#pragma fragment frag

#include “UnityCG.cginc”

uniform sampler2D _MainTex;
uniform float _bwBlend;
uniform float _alpha;

float4 frag(v2f_img i) : COLOR {
float4 c = tex2D(_MainTex, i.uv);

float lum = c.r*.3 + c.g*.59 + c.b*.11;
float3 bw = float3( lum, lum, lum );
float4 trans = float4(0,0,0,0);

float4 result = c;
result.rgb = lerp(c.rgb, bw, _bwBlend);
result.rgba = lerp(result.rgba, trans, 1-_alpha);
return result;
}
ENDCG
}
}
}

Advertisements


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s