Created
June 14, 2020 07:46
-
-
Save asus4/215cc8a85d2fb16aceae0d0185e10db3 to your computer and use it in GitHub Desktop.
tf-lite-unity-sample Resize.shader
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 "Hidden/TFLite/Resize" | |
{ | |
Properties | |
{ | |
_MainTex ("Texture", 2D) = "white" {} | |
} | |
SubShader | |
{ | |
Cull Off | |
ZWrite Off | |
ZTest LEqual | |
Pass | |
{ | |
CGPROGRAM | |
#pragma vertex vert | |
#pragma fragment frag | |
#include "UnityCG.cginc" | |
uniform float4x4 _VertTransform; | |
uniform float4 _UVRect; // the same as _MainTex_ST; | |
struct appdata | |
{ | |
float4 vertex : POSITION; | |
float2 uv : TEXCOORD0; | |
}; | |
struct v2f | |
{ | |
float2 uv : TEXCOORD0; | |
float4 vertex : SV_POSITION; | |
}; | |
v2f vert (appdata v) | |
{ | |
v2f o; | |
o.vertex = UnityObjectToClipPos(mul(_VertTransform, v.vertex)); | |
o.uv = v.uv * _UVRect.xy + _UVRect.zw; | |
return o; | |
} | |
sampler2D _MainTex; | |
fixed4 frag (v2f i) : SV_Target | |
{ | |
return tex2D(_MainTex, i.uv); | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment