-
-
Save unitycoder/5c4435d59ae4f66a040728ae55c0df0e to your computer and use it in GitHub Desktop.
Make a standard Unity Quad full-screen, purely in the shader
This file contains hidden or 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