// Upgrade NOTE: replaced '_Object2World' with 'unity_ObjectToWorld'
Shader "Unlit/VerifyGL"
{
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;
float4 uv:TEXCOORD0;
};
struct v2f
{
float4 vertex : SV_POSITION;
float4 uv:TEXCOORD0;
float4 world:TEXCOORD1;
float4 screen:TEXCOORD2;
};
sampler2D _MainTex;
sampler2D _src;
float4 _MainTex_ST;
float4x4 _VP;
float4 xa;
v2f vert (appdata v)
{
v2f o;
o.vertex = UnityObjectToClipPos(v.vertex);
o.uv = v.uv;
o.world = mul(unity_ObjectToWorld, v.vertex);
o.screen = ComputeScreenPos(o.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
// 1.使用世界坐标插值
/* float4 clipPos = mul(UNITY_MATRIX_VP, i.world);
float2 uv = clipPos / clipPos.w;
uv = uv * 0.5 + 0.5;
float4 col = tex2D(_MainTex, uv);
return col;*/
// 2.使用ComputeScreenPos
/* float4 col = tex2D(_MainTex, i.screen.xy / i.screen.w);
return col;*/
// 3. 使用unity的屏幕空间坐标
float2 uv;
uv.x = i.vertex.x / 800; //800是屏幕宽度
uv.y = 1-i.vertex.y / 600; //600是屏幕高度
float4 col = tex2D(_MainTex, uv);
return col;
}
ENDCG
}
}
}
FIG paste Smectite: