Skip to content

Instantly share code, notes, and snippets.

@jcowles
Last active January 23, 2023 03:58
Show Gist options
  • Save jcowles/9637038631babe1ad07eb2669e3737d3 to your computer and use it in GitHub Desktop.
Save jcowles/9637038631babe1ad07eb2669e3737d3 to your computer and use it in GitHub Desktop.
Make a standard Unity Quad full-screen, purely in the shader
//
// 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
}
}
}
@alexbu92
Copy link

alexbu92 commented Mar 2, 2018

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" }

	ZWrite Off
	ZTest Off

	Blend SrcAlpha OneMinusSrcAlpha
	//ColorMask RGB

	Pass{
	    SetTexture[_MainTex]{
	        Combine texture
            }
	    SetTexture[_Alpha]{
	        Combine previous, texture
            }
        }
}

}`

I tried inserting your gist right after the pass but it isn't rendering anything. Are these just incompatible?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment