Hello! Is it possible to create material/shader with color overlay (not “overlay” blend mode) with opacity settings for sprite?
can get official built in shaders here
copy sprite shader and replace blend mode with whatever u need here is my ‘additive’ shader using
Blend SrcAlpha One
there may (should) be an easier way?
Shader "Custom/Additive"
{
Properties
{
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
[MaterialToggle] PixelSnap ("Pixel snap", Float) = 0
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Blend SrcAlpha One
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile DUMMY PIXELSNAP_ON
#include "UnityCG.cginc"
struct appdata_t
{
float4 vertex : POSITION;
float4 color : COLOR;
float2 texcoord : TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
half2 texcoord : TEXCOORD0;
};
fixed4 _Color;
v2f vert(appdata_t IN)
{
v2f OUT;
OUT.vertex = mul(UNITY_MATRIX_MVP, IN.vertex);
OUT.texcoord = IN.texcoord;
OUT.color = IN.color * _Color;
#ifdef PIXELSNAP_ON
OUT.vertex = UnityPixelSnap (OUT.vertex);
#endif
return OUT;
}
sampler2D _MainTex;
fixed4 frag(v2f IN) : SV_Target
{
fixed4 c = tex2D(_MainTex, IN.texcoord) * IN.color;
c.rgb *= c.a;
return c;
}
ENDCG
}
}
}
This is for photoshop blend modes…not “layer styles”. And i think this solution is too big for my problem) Im tryng to colorize one of the parallax layers. Layer with trees colored to blue. And i hope to control color of this tint/overlay in future via script.
Like this:

trying to understand shading scripting, but without results.
Found this on similar threads:
Shader "Unlit/Photoshop Overlay"
{
Properties
{
_MainTex ("Base (RGB), Alpha (A)", 2D) = "" {}
}
SubShader
{
LOD 100
Tags
{
"Queue" = "Transparent"
"IgnoreProjector" = "True"
"RenderType" = "Transparent"
}
Pass
{
Cull Off
Lighting Off
ZWrite Off
Fog { Mode Off }
Offset -1, -1
ColorMask RGB
AlphaTest Greater .01
Blend SrcAlpha OneMinusSrcAlpha
ColorMaterial AmbientAndDiffuse
SetTexture [_MainTex]
{
Combine Texture +- Primary, Texture * Primary
}
SetTexture [_MainTex]
{
Combine Texture +- previous, Texture * Primary
}
}
}
}
Effect of overlay is great, but not what i need. I need to colorize pixels of main texture with tint color.
Just gotta lerp the original color to your overlay color (: Tested and below code is working ![]()
Shader "custom/ColorOverlay"
{
Properties
{
[HideInInspector]
_MainTex ("Texture", 2D) = "white" {}
_OverlayColor ("Overlay Color", Color) = (1,1,1,1)
_OverlayOpacity ("Overlay Opacity", Range(0,1)) = 1
}
SubShader
{
Tags {"Queue"="Transparent" "IgnoreProjector"="true" "RenderType"="Transparent"}
ZWrite Off Blend SrcAlpha OneMinusSrcAlpha Cull Off
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
fixed4 color : COLOR;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
fixed4 color : COLOR;
};
v2f vert (appdata v)
{
v2f o;
o.color = v.color;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
sampler2D _MainTex;
fixed4 _OverlayColor;
float _OverlayOpacity;
fixed4 frag (v2f i) : SV_Target
{
fixed4 mainTex = tex2D(_MainTex, i.uv);
mainTex *= i.color;
fixed4 overlay = lerp(mainTex, _OverlayColor, _OverlayOpacity);
overlay.a = mainTex.a;
return overlay;
}
ENDCG
}
}
}
Thank you! I was looking for this already 4 days! Many thanks to you!![]()
This works as described, but how could an artist (like me) animate this? Would it have to be exposed in the inspector?
Also, it would be great to add a Saturation slider, so desaturation could also be achieved.
You might want to check this : http://wonderland.eode.studio/
I think this is the answer to yout prayers ![]()
Thank youuuuuuuuuuu! Your color matrix is all what I searched for Unity for years!!!

