Shader "Custom/ScreenSpacePerspectiveQuad" {
_MainTex ("Texture", 2D) = "white" {}
_Tilt ("Tilt", float) = 0.5
Tags { "RenderType"="Opaque" "Queue"="Overlay" }
// Vertex input structure
float4 vertex : POSITION; // Expected in NDC or object space for a full-screen quad
// Data passed to the fragment shader
float4 vertex : SV_POSITION;
// Here we define a custom perspective matrix that tilts along the y axis.
// This matrix leaves x and y unchanged except that it adjusts the w component:
// For a vertex (x, y, z, 1), the multiplication yields:
// After the GPU’s automatic perspective division, the final screen position becomes:
// (x / (1 + _Tilt*y), y / (1 + _Tilt*y), z, 1)
// This creates a simple perspective effect in screen space.
float4x4 persp = float4x4(
o.vertex = mul(persp, v.vertex);
fixed4 frag (v2f i) : SV_Target
// Sample the texture normally.
fixed4 col = tex2D(_MainTex, i.uv);