Skip to content

Commit

Permalink
add unlit and transparent shaders that have flip-x/y properties.
Browse files Browse the repository at this point in the history
  • Loading branch information
hecomi committed Jan 5, 2019
1 parent 39caa7b commit 7e1df4f
Show file tree
Hide file tree
Showing 12 changed files with 177 additions and 0 deletions.
Binary file not shown.
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/uWindowCapture/Materials/uWC_Transparent.mat.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file modified Assets/uWindowCapture/Materials/uWC_Unlit.mat
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/uWindowCapture/Shaders.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

50 changes: 50 additions & 0 deletions Assets/uWindowCapture/Shaders/UwcCommon.cginc
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#ifndef UWC_COMMON_CGINC
#define UWC_COMMON_CGINC

#include "UnityCG.cginc"

float4 _Color;
sampler2D _MainTex;
float4 _MainTex_ST;

inline void UwcFlipUV(inout float2 uv)
{
#ifdef UWC_FLIP_X
uv.x = 1.0 - uv.x;
#endif
#ifdef UWC_FLIP_Y
uv.y = 1.0 - uv.y;
#endif
}

struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};

struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
UNITY_FOG_COORDS(1)
};

v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
UwcFlipUV(o.uv);
UNITY_TRANSFER_FOG(o,o.vertex);
return o;
}

fixed4 frag(v2f i) : SV_Target
{
float4 col = tex2D(_MainTex, i.uv) * _Color;
UNITY_APPLY_FOG(i.fogCoord, col);
return col;
}

#endif
9 changes: 9 additions & 0 deletions Assets/uWindowCapture/Shaders/UwcCommon.cginc.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

45 changes: 45 additions & 0 deletions Assets/uWindowCapture/Shaders/UwcTransparent.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
Shader "uWindowCapture/Transparent"
{

Properties
{
_Color("Color", Color) = (1, 1, 1, 1)
_MainTex("Texture", 2D) = "white" {}
[Enum(UnityEngine.Rendering.CullMode)] _Cull("Culling", Int) = 2
[Enum(UnityEngine.Rendering.BlendMode)] _BlendSrc("Blend Src", Float) = 5
[Enum(UnityEngine.Rendering.BlendMode)] _BlendDst("Blend Dst", Float) = 10
[Toggle][KeyEnum(Off, On)] _ZWrite("ZWrite", Float) = 1
[Toggle(UWC_FLIP_X)] _FlipX("Flip X", Int) = 0
[Toggle(UWC_FLIP_Y)] _FlipY("Flip Y", Int) = 0
}

SubShader
{
Tags
{
"Queue" = "Transparent"
"RenderType" = "Transparent"
"IgnoreProjector" = "True"
"PreviewType" = "Plane"
}

Pass
{
Cull [_Cull]
Blend [_BlendSrc] [_BlendDst]
ZWrite [_ZWrite]

CGPROGRAM
#include "./UwcCommon.cginc"
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma multi_compile ___ UWC_FLIP_X
#pragma multi_compile ___ UWC_FLIP_Y
ENDCG
}
}

Fallback "Unlit/Transparent"

}
9 changes: 9 additions & 0 deletions Assets/uWindowCapture/Shaders/UwcTransparent.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

39 changes: 39 additions & 0 deletions Assets/uWindowCapture/Shaders/UwcUnlit.shader
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
Shader "uWindowCapture/Unlit"
{

Properties
{
_Color("Color", Color) = (1, 1, 1, 1)
_MainTex("Texture", 2D) = "white" {}
[Enum(UnityEngine.Rendering.CullMode)] _Cull("Culling", Int) = 2
[Toggle(UWC_FLIP_X)] _FlipX("Flip X", Int) = 0
[Toggle(UWC_FLIP_Y)] _FlipY("Flip Y", Int) = 0
}

SubShader
{
Tags
{
"RenderType" = "Opaque"
"Queue" = "Geometry"
"PreviewType" = "Plane"
}

Pass
{
Cull [_Cull]

CGPROGRAM
#include "./UwcCommon.cginc"
#pragma vertex vert
#pragma fragment frag
#pragma multi_compile_fog
#pragma multi_compile ___ UWC_FLIP_X
#pragma multi_compile ___ UWC_FLIP_Y
ENDCG
}
}

Fallback "Unlit/Texture"

}
9 changes: 9 additions & 0 deletions Assets/uWindowCapture/Shaders/UwcUnlit.shader.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 7e1df4f

Please sign in to comment.