Last active
May 2, 2020 05:34
-
-
Save the6th/43c4d272ab3eeebbe8f35d4b00304090 to your computer and use it in GitHub Desktop.
uWindowCapture の ShaderをSinglePassInstancedに対応させる
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
// ## Repository | |
// * https://github.com/hecomi/uWindowCapture | |
// * https://github.com/hecomi/uWindowCapture/blob/7e1df4fee1a1c6d812079a4355cbb609686734f2/Assets/uWindowCapture/Shaders/UwcCommon.cginc | |
#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; | |
UNITY_VERTEX_INPUT_INSTANCE_ID //for Single pass instanced | |
}; | |
struct v2f | |
{ | |
float4 vertex : SV_POSITION; | |
float2 uv : TEXCOORD0; | |
UNITY_FOG_COORDS(1) | |
UNITY_VERTEX_OUTPUT_STEREO //for Single pass instanced | |
}; | |
v2f vert(appdata v) | |
{ | |
v2f o; | |
UNITY_SETUP_INSTANCE_ID(v); //for Single pass instanced | |
UNITY_INITIALIZE_OUTPUT(v2f, o); //for Single pass instanced | |
UNITY_INITIALIZE_VERTEX_OUTPUT_STEREO(o); //for Single pass instanced | |
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 = float4(tex2D(_MainTex, i.uv).rgb * _Color, _Color.a); | |
UNITY_APPLY_FOG(i.fogCoord, col); | |
return col; | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment