Last active
January 23, 2023 03:58
-
-
Save jcowles/9637038631babe1ad07eb2669e3737d3 to your computer and use it in GitHub Desktop.
Make a standard Unity Quad full-screen, purely in the 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
// | |
// 1. Add a Quad in Unity | |
// 2. Parent the quad under camera, to prevent frustum culling. | |
// 3. Attach this shader. | |
// | |
Shader "Quad/Fullscreen" | |
{ | |
Properties | |
{ | |
} | |
SubShader | |
{ | |
Cull Off ZWrite Off | |
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; | |
}; | |
v2f vert(appdata v) | |
{ | |
v2f o; | |
o.vertex = v.vertex; | |
o.vertex.xy *= 2; | |
o.uv = v.uv; | |
return o; | |
} | |
fixed4 frag(v2f i) : SV_Target | |
{ | |
return fixed4(i.uv, 0, 1); | |
} | |
ENDCG | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi I'm trying to use this shader but having trouble merging this with the shader I already have. This is my shader:
`Shader "alphaMaskShader"
{
Properties{
_MainTex("Base (RGB)", 2D) = "white" {}
_Alpha("Alpha (A)", 2D) = "white" {}
}
SubShader{
Tags{ "RenderType" = "Transparent" "Queue" = "Overlay" }
}`
I tried inserting your gist right after the pass but it isn't rendering anything. Are these just incompatible?