Last active
November 16, 2017 23:24
-
-
Save elringus/a1dfab3042727d32acc4d9052f86d2a1 to your computer and use it in GitHub Desktop.
This file contains 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 "BlendModes/Extra/UIOverlay" | |
{ | |
Properties | |
{ | |
[PerRendererData] _MainTex ("Sprite Texture", 2D) = "white" {} | |
_OverlayTex1("Overlay Texture 1", 2D) = "white" {} | |
_OverlayTex2("Overlay Texture 2", 2D) = "white" {} | |
_OverlayTex3("Overlay Texture 3", 2D) = "white" {} | |
_OverlayTex4("Overlay Texture 4", 2D) = "white" {} | |
_OverlayTex5("Overlay Texture 5", 2D) = "white" {} | |
_OverlayColor1("Overlay Color 1", Color) = (1,1,1,0) | |
_OverlayColor2("Overlay Color 2", Color) = (1,1,1,0) | |
_OverlayColor3("Overlay Color 3", Color) = (1,1,1,0) | |
_OverlayColor4("Overlay Color 4", Color) = (1,1,1,0) | |
_OverlayColor5("Overlay Color 5", Color) = (1,1,1,0) | |
_Color ("Tint", Color) = (1,1,1,1) | |
} | |
SubShader | |
{ | |
Tags | |
{ | |
"Queue" = "Transparent" | |
"IgnoreProjector" = "True" | |
"RenderType" = "Transparent" | |
"PreviewType" = "Plane" | |
} | |
Cull Off | |
Lighting Off | |
ZWrite Off | |
ZTest [unity_GUIZTestMode] | |
Fog { Mode Off } | |
Blend SrcAlpha OneMinusSrcAlpha | |
Pass | |
{ | |
CGPROGRAM | |
#include "UnityCG.cginc" | |
#include "../BlendModes.cginc" | |
#pragma target 3.0 | |
#pragma multi_compile BmDarken BmMultiply BmColorBurn BmLinearBurn BmDarkerColor BmLighten BmScreen BmColorDodge BmLinearDodge BmLighterColor BmOverlay BmSoftLight BmHardLight BmVividLight BmLinearLight BmPinLight BmHardMix BmDifference BmExclusion BmSubtract BmDivide BmHue BmSaturation BmColor BmLuminosity | |
#pragma vertex ComputeVertex | |
#pragma fragment ComputeFragment | |
sampler2D _MainTex; | |
sampler2D _MainTex_ST; | |
fixed4 _Color; | |
sampler2D _OverlayTex1, _OverlayTex2, _OverlayTex3, _OverlayTex4, _OverlayTex5; | |
fixed4 _OverlayColor1, _OverlayColor2, _OverlayColor3, _OverlayColor4, _OverlayColor5; | |
struct VertexInput | |
{ | |
float4 Vertex : POSITION; | |
fixed4 Color : COLOR; | |
float2 TexCoord : TEXCOORD; | |
}; | |
struct VertexOutput | |
{ | |
float4 Vertex : SV_POSITION; | |
fixed4 Color : COLOR; | |
float2 TexCoord : TEXCOORD; | |
}; | |
VertexOutput ComputeVertex (VertexInput vertexInput) | |
{ | |
VertexOutput vertexOutput; | |
vertexOutput.Vertex = ObjectToClipPos(vertexInput.Vertex); | |
vertexOutput.TexCoord = vertexInput.TexCoord; | |
#ifdef UNITY_HALF_TEXEL_OFFSET | |
vertexOutput.Vertex.xy += (_ScreenParams.zw - 1.0) * float2(-1.0, 1.0); | |
#endif | |
vertexOutput.Color = vertexInput.Color * _Color; | |
return vertexOutput; | |
} | |
fixed4 ComputeFragment (VertexOutput vertexOutput) : SV_Target | |
{ | |
fixed4 texColor = tex2D(_MainTex, vertexOutput.TexCoord) * vertexOutput.Color; | |
clip(texColor.a - .01); | |
fixed4 grabColor; | |
fixed4 blendResult; | |
grabColor = tex2D(_OverlayTex1, vertexOutput.TexCoord) * _OverlayColor1; | |
blendResult = ColorDodge(grabColor, texColor); | |
texColor = lerp(texColor, blendResult, grabColor.a); | |
texColor = saturate(texColor); | |
grabColor = tex2D(_OverlayTex2, vertexOutput.TexCoord) * _OverlayColor2; | |
blendResult = ColorDodge(grabColor, texColor); | |
texColor = lerp(texColor, blendResult, grabColor.a); | |
texColor = saturate(texColor); | |
grabColor = tex2D(_OverlayTex3, vertexOutput.TexCoord) * _OverlayColor3; | |
blendResult = LinearBurn(grabColor, texColor); | |
texColor = lerp(texColor, blendResult, grabColor.a); | |
//grabColor = tex2D(_OverlayTex4, vertexOutput.TexCoord) * _OverlayColor4; | |
//blendResult = ColorDodge(grabColor, texColor); | |
//texColor = lerp(texColor, blendResult, grabColor.a); | |
//grabColor = tex2D(_OverlayTex5, vertexOutput.TexCoord) * _OverlayColor5; | |
//blendResult = ColorDodge(grabColor, texColor); | |
//texColor = lerp(texColor, blendResult, grabColor.a); | |
return texColor; | |
} | |
ENDCG | |
} | |
} | |
Fallback "UI/Default" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment