Skip to content

Commit 7e1df4f

Browse files
committed
add unlit and transparent shaders that have flip-x/y properties.
1 parent 39caa7b commit 7e1df4f

File tree

12 files changed

+177
-0
lines changed

12 files changed

+177
-0
lines changed
5.09 KB
Binary file not shown.
File renamed without changes.
5.19 KB
Binary file not shown.

Assets/uWindowCapture/Materials/uWC_Transparent.mat.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
104 Bytes
Binary file not shown.

Assets/uWindowCapture/Shaders.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#ifndef UWC_COMMON_CGINC
2+
#define UWC_COMMON_CGINC
3+
4+
#include "UnityCG.cginc"
5+
6+
float4 _Color;
7+
sampler2D _MainTex;
8+
float4 _MainTex_ST;
9+
10+
inline void UwcFlipUV(inout float2 uv)
11+
{
12+
#ifdef UWC_FLIP_X
13+
uv.x = 1.0 - uv.x;
14+
#endif
15+
#ifdef UWC_FLIP_Y
16+
uv.y = 1.0 - uv.y;
17+
#endif
18+
}
19+
20+
struct appdata
21+
{
22+
float4 vertex : POSITION;
23+
float2 uv : TEXCOORD0;
24+
};
25+
26+
struct v2f
27+
{
28+
float4 vertex : SV_POSITION;
29+
float2 uv : TEXCOORD0;
30+
UNITY_FOG_COORDS(1)
31+
};
32+
33+
v2f vert(appdata v)
34+
{
35+
v2f o;
36+
o.vertex = UnityObjectToClipPos(v.vertex);
37+
o.uv = TRANSFORM_TEX(v.uv, _MainTex);
38+
UwcFlipUV(o.uv);
39+
UNITY_TRANSFER_FOG(o,o.vertex);
40+
return o;
41+
}
42+
43+
fixed4 frag(v2f i) : SV_Target
44+
{
45+
float4 col = tex2D(_MainTex, i.uv) * _Color;
46+
UNITY_APPLY_FOG(i.fogCoord, col);
47+
return col;
48+
}
49+
50+
#endif

Assets/uWindowCapture/Shaders/UwcCommon.cginc.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
Shader "uWindowCapture/Transparent"
2+
{
3+
4+
Properties
5+
{
6+
_Color("Color", Color) = (1, 1, 1, 1)
7+
_MainTex("Texture", 2D) = "white" {}
8+
[Enum(UnityEngine.Rendering.CullMode)] _Cull("Culling", Int) = 2
9+
[Enum(UnityEngine.Rendering.BlendMode)] _BlendSrc("Blend Src", Float) = 5
10+
[Enum(UnityEngine.Rendering.BlendMode)] _BlendDst("Blend Dst", Float) = 10
11+
[Toggle][KeyEnum(Off, On)] _ZWrite("ZWrite", Float) = 1
12+
[Toggle(UWC_FLIP_X)] _FlipX("Flip X", Int) = 0
13+
[Toggle(UWC_FLIP_Y)] _FlipY("Flip Y", Int) = 0
14+
}
15+
16+
SubShader
17+
{
18+
Tags
19+
{
20+
"Queue" = "Transparent"
21+
"RenderType" = "Transparent"
22+
"IgnoreProjector" = "True"
23+
"PreviewType" = "Plane"
24+
}
25+
26+
Pass
27+
{
28+
Cull [_Cull]
29+
Blend [_BlendSrc] [_BlendDst]
30+
ZWrite [_ZWrite]
31+
32+
CGPROGRAM
33+
#include "./UwcCommon.cginc"
34+
#pragma vertex vert
35+
#pragma fragment frag
36+
#pragma multi_compile_fog
37+
#pragma multi_compile ___ UWC_FLIP_X
38+
#pragma multi_compile ___ UWC_FLIP_Y
39+
ENDCG
40+
}
41+
}
42+
43+
Fallback "Unlit/Transparent"
44+
45+
}

Assets/uWindowCapture/Shaders/UwcTransparent.shader.meta

Lines changed: 9 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)