https://github.com/xjine/unity_grabpasssamples
Smallest GrabPass samples are included.
https://github.com/xjine/unity_grabpasssamples
sample shader unity
Last synced: about 1 year ago
JSON representation
Smallest GrabPass samples are included.
- Host: GitHub
- URL: https://github.com/xjine/unity_grabpasssamples
- Owner: XJINE
- License: bsd-3-clause
- Created: 2018-12-04T04:57:58.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-12-04T08:24:11.000Z (over 7 years ago)
- Last Synced: 2025-02-08T22:28:17.340Z (over 1 year ago)
- Topics: sample, shader, unity
- Language: ShaderLab
- Homepage:
- Size: 49.8 KB
- Stars: 1
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Unity_GrabPassSamples
Smallest ``GrabPass`` samples are included.
GrabPassShaderGrabPassImageEffect


Following code is one of these.
```shader
// NOTE:
// Call after almost objects are rendered.
Tags
{
"Queue" = "Transparent"
}
GrabPass
{
"_GrabTex"
}
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
struct v2f
{
float4 vertex : SV_POSITION;
float2 uv : TEXCOORD0;
float4 uvg : TEXCOORD1;
};
sampler2D _GrabTex;
sampler2D _MainTex;
float4 _MainTex_ST;
v2f vert (appdata_base v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = TRANSFORM_TEX(v.texcoord, _MainTex);
o.uvg = ComputeGrabScreenPos(o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
float4 mainColor = tex2D(_MainTex, i.uv);
// NOTE:
// Following patterns are same.
float4 grabColor = tex2Dproj(_GrabTex, i.uvg);
grabColor = tex2D(_GrabTex, i.uvg.xy / i.uvg.w);
return mainColor * 0.5 + grabColor * 0.5;
}
ENDCG
}
```