UnderStand Perspective Rasterization, SV_POSITION(gl_FragCoord) to Pixel, SV mean Systems Value

Shader "UnderStandPRR"
{
Properties
{
_MainTex ("Texture", 2D) = "white" {}
}
SubShader
{
Tags { "RenderType"="Opaque" }
LOD 100
 
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
 
#include "UnityCG.cginc"
 
struct appdata
{
float4 vertex : POSITION;
};
 
struct v2f
{
float4 vertex : SV_POSITION;
};
 
sampler2D _MainTex;
float4 _MainTex_ST;
 
v2f vert (appdata v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
return o;
}
 
fixed4 frag (v2f i) : SV_Target
{
// i.vertex.xy are pixel coordinates 
// i.vertex.z is depth value 
// i.vertex.w is SV_POSITION w - z value (Perspective interpolation)
return  fixed4(i.vertex.x * (_ScreenParams.z - 1), i.vertex.y * (_ScreenParams.w - 1), i.vertex.z, i.vertex.w);
}
ENDCG
}
}
}

UnderStand Perspective Rasterization, SV_POSITION(gl_FragCoord) to Pixel, SV mean Systems Value

上一篇:android中的文件(图片)上传


下一篇:Running Solr in Docker