Ok so I’m trying to wrap my head around shaders. One very simple thing that I’ve read over and over again is that to get a vertex position in screen space you do
mul(UNITY_MATRIX_MVP, v.vertex);
and you should get a float4 with x and y ranging from -1 to 1.
When I do this I’m getting a value that ranges from 0 to screen width/height;
EX:
Shader "Unlit/VertexPositionShader"
{
Properties
{
}
SubShader
{
Tags { "RenderType"="Opaque" }
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
struct appdata
{
float4 vertex : POSITION;
};
struct v2f
{
float4 vertex : SV_POSITION;
};
v2f vert (appdata v)
{
v2f o;
o.vertex = mul(UNITY_MATRIX_MVP, v.vertex);
return o;
}
fixed4 frag (v2f i) : SV_Target
{
fixed4 col;
if (i.vertex.x > _ScreenParams.x/2)
col = 0;//black
else
col = 1;//white
return col;
}
ENDCG
}
}
}
The Result is
Am I missing something here?