Skip to content

Instantly share code, notes, and snippets.

@Forenard
Created June 29, 2023 19:58
Show Gist options
  • Save Forenard/535fa46e3d95f8b6949095aaf62de2d8 to your computer and use it in GitHub Desktop.
Save Forenard/535fa46e3d95f8b6949095aaf62de2d8 to your computer and use it in GitHub Desktop.
Blitでuint4をそのままコピーするシェーダー
Shader "Unlit/Uint4Copy"
{
Properties
{
[NoScaleOffset] _MainTex ("Texture", 2D) = "white" { }
}
SubShader
{
Tags { "RenderType" = "Opaque" }
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct appdata
{
float4 vertex : POSITION;
float2 uv : TEXCOORD0;
};
struct v2f
{
float2 uv : TEXCOORD0;
float4 vertex : SV_POSITION;
};
Texture2D<uint4> _MainTex;
v2f vert(appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
return o;
}
uint4 frag(v2f i) : SV_Target
{
int2 size;
_MainTex.GetDimensions(size.x, size.y);
return _MainTex[int2(i.uv * float2(size))];
}
ENDCG
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment