Skip to content

Instantly share code, notes, and snippets.

@asus4
Created June 14, 2020 07:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save asus4/215cc8a85d2fb16aceae0d0185e10db3 to your computer and use it in GitHub Desktop.
Save asus4/215cc8a85d2fb16aceae0d0185e10db3 to your computer and use it in GitHub Desktop.
tf-lite-unity-sample Resize.shader
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