Skip to content

Instantly share code, notes, and snippets.

@pacoelayudante
Created March 2, 2020 17:57
Show Gist options
  • Save pacoelayudante/85782412ef6695200de931fdacab76f2 to your computer and use it in GitHub Desktop.
Save pacoelayudante/85782412ef6695200de931fdacab76f2 to your computer and use it in GitHub Desktop.
Colorea Shader Sin Perder Blanco
Shader "Sprites/KeepSat"
{
Properties
{
[PerRendererData] _MainTex ("Texture", 2D) = "white" {}
_Color ("Tint", Color) = (1,1,1,1)
_Exponente ("Exponente", Float) = 2.4
[MaterialToggle] PixelSnap("Pixel snap", Float) = 0
[MaterialToggle] Premultiply("Premultiply Alfa y Color", Int) = 1
[HideInInspector] _RendererColor ("RendererColor", Color) = (1,1,1,1)
[HideInInspector] _Flip ("Flip", Vector) = (1,1,1,1)
[PerRendererData] _AlphaTex ("External Alpha", 2D) = "white" {}
[PerRendererData] _EnableExternalAlpha ("Enable External Alpha", Float) = 0
}
SubShader
{
Tags
{
"Queue"="Transparent"
"IgnoreProjector"="True"
"RenderType"="Transparent"
"PreviewType"="Plane"
"CanUseSpriteAtlas"="True"
}
LOD 100
Blend One OneMinusSrcAlpha
Cull Off
Lighting Off
ZWrite Off
//Blend SrcAlpha OneMinusSrcAlpha
Pass
{
CGPROGRAM
#pragma vertex SpriteVert
#pragma fragment frag
#pragma target 2.0
#pragma multi_compile_instancing
#pragma multi_compile _ PIXELSNAP_ON
#pragma multi_compile _ PREMULTIPLY_ON
#pragma multi_compile _ ETC1_EXTERNAL_ALPHA
// make fog work
#pragma multi_compile_fog
//#include "UnityCG.cginc"
#include "UnitySprites.cginc"
/*struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
float4 color : COLOR;
};*/
/*struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
float4 color : COLOR;
};*/
/*v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
o.color = v.color;
return o;
}*/
fixed _Exponente;
fixed4 frag (v2f IN) : SV_Target
{
// sample the texture
//fixed4 colTextura = tex2D(_MainTex, IN.texcoord);
fixed4 colTextura = SampleSpriteTexture(IN.texcoord);
fixed lum = Luminance(colTextura.rgb);
colTextura.rgb *= lerp(IN.color.rgb,1.0, pow(lum,_Exponente) );
colTextura.a *= IN.color.a;
colTextura.rgb *= colTextura.a;
return colTextura;
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment