Created
January 11, 2014 00:44
-
-
Save Azzizi/8365455 to your computer and use it in GitHub Desktop.
Low-effort shader for Unity that tints each color channel of a texture with a set color. I used this for tintable, multi-color engine flares on starships and similar effects.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Shader "Custom/EngineFlare" | |
{ | |
Properties | |
{ | |
_MainTex ("Base (RGB)", 2D) = "white" {} | |
_Color1 ("Color 1", Color) = (1,1,1,1) | |
_Color2 ("Color 2", Color) = (1,1,1,1) | |
_Color3 ("Color 3", Color) = (1,1,1,1) | |
_Intensity ("Intensity", Range(0.0, 2.0)) = 1.0 | |
} | |
SubShader | |
{ | |
Tags {"Queue" = "Transparent" } | |
Cull Off Lighting Off ZWrite Off | |
Blend One One | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
float4 _Color1; | |
float4 _Color2; | |
float4 _Color3; | |
float _Intensity; | |
sampler2D _MainTex; | |
struct v2f | |
{ | |
float4 pos : SV_POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
float4 _MainTex_ST; | |
v2f vert (appdata_base v) | |
{ | |
v2f o; | |
o.pos = mul (UNITY_MATRIX_MVP, v.vertex); | |
o.uv = TRANSFORM_TEX (v.texcoord, _MainTex); | |
return o; | |
} | |
half4 frag (v2f i) : COLOR | |
{ | |
half4 texcol = tex2D (_MainTex, i.uv); | |
return (texcol.r * _Color1 + texcol.g * _Color2 + texcol.b * _Color3) * _Intensity; | |
} | |
ENDCG | |
} | |
} | |
FallBack "Unlit" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment