Last active
September 1, 2015 23:50
-
-
Save elringus/1e008c39e09bf24380ba to your computer and use it in GitHub Desktop.
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 "GrabTexBug" | |
{ | |
Properties | |
{ | |
[PerRendererData] | |
_MainTex ("Sprite Texture", 2D) = "white" {} | |
_Color ("Tint", Color) = (1,1,1,1) | |
} | |
SubShader | |
{ | |
Tags | |
{ | |
"Queue" = "Transparent" | |
"RenderType" = "Transparent" | |
} | |
Cull Off | |
Lighting Off | |
ZWrite Off | |
Blend SrcAlpha OneMinusSrcAlpha | |
GrabPass { } | |
Pass | |
{ | |
CGPROGRAM | |
#include "UnityCG.cginc" | |
#pragma vertex ComputeVertex | |
#pragma fragment ComputeFragment | |
sampler2D _MainTex; | |
sampler2D _GrabTexture; | |
fixed4 _Color; | |
struct VertexInput | |
{ | |
float4 vertex : POSITION; | |
float4 color : COLOR; | |
float2 texcoord : TEXCOORD0; | |
}; | |
struct VertexOutput | |
{ | |
float4 vertex : SV_POSITION; | |
fixed4 color : COLOR; | |
half2 texcoord : TEXCOORD0; | |
float4 screenPos : TEXCOORD1; | |
}; | |
VertexOutput ComputeVertex (VertexInput vertexInput) | |
{ | |
VertexOutput vertexOutput; | |
vertexOutput.vertex = mul(UNITY_MATRIX_MVP, vertexInput.vertex); | |
vertexOutput.screenPos = vertexOutput.vertex; | |
vertexOutput.texcoord = vertexInput.texcoord; | |
vertexOutput.color = vertexInput.color * _Color; | |
return vertexOutput; | |
} | |
fixed4 ComputeFragment (VertexOutput vertexOutput) : SV_Target | |
{ | |
return tex2D(_GrabTexture, vertexOutput.texcoord); | |
} | |
ENDCG | |
} | |
} | |
Fallback "Sprites/Default" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment