Skip to content

Commit

Permalink
integrated PCA palette to render pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
inhibitor1217 committed Jul 30, 2019
1 parent 64592cf commit bdd3c8e
Show file tree
Hide file tree
Showing 19 changed files with 726 additions and 86 deletions.
Binary file not shown.
62 changes: 62 additions & 0 deletions Assets/Resources/Shaders/PCAWater.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
Shader "Compute/PCAWater"
{
Properties
{
_MainTex ("Source", 2D) = "white" {}
_LowTex ("Low", 2D) = "white" {}
_HighTex ("High", 2D) = "white" {}
_MaskTex ("Mask", 2D) = "white" {}
}
SubShader
{
Pass
{
name "Default"
CGPROGRAM
#include "UnityCG.cginc"
#include "UnityUI.cginc"

#pragma vertex vert
#pragma fragment frag

sampler2D _MainTex;
sampler2D _LowTex;
sampler2D _HighTex;
sampler2D _MaskTex;

struct appdata_t
{
float4 vertex : POSITION;
float2 texcoord : TEXCOORD0;
};

struct v2f
{
float4 vertex : SV_POSITION;
float2 texcoord : TEXCOORD0;
};

v2f vert(appdata_t v)
{
v2f OUT;

OUT.vertex = UnityObjectToClipPos(v.vertex);
OUT.texcoord = v.texcoord;

return OUT;
}

half4 frag(v2f IN) : SV_Target
{
float a = tex2D(_MaskTex, IN.texcoord).r;
clip(a - 0.01);

half4 color = lerp(tex2D(_LowTex, IN.texcoord), tex2D(_HighTex, IN.texcoord), tex2D(_MainTex, IN.texcoord).r);
color.a = a;

return color;
}
ENDCG
}
}
}
6 changes: 5 additions & 1 deletion Assets/Resources/Shaders/UIMask.shader
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,11 @@ Shader "UI/Mask"
half4 frag(v2f IN) : SV_Target
{
half4 color = _Color;
color.a *= tex2D(_MainTex, IN.texcoord).r;
float v = tex2D(_MainTex, IN.texcoord).r;

clip(v - 0.01);

color.a *= v;

return color;
}
Expand Down
Loading

0 comments on commit bdd3c8e

Please sign in to comment.