Is it possible that the vertex position given in the struct appdata_base are already the transformed? I need to get the local positions of my vertices in the vertex shader but after 30 min of confusion and testing I noticed that the vertex position are already in the world space and all the matrices are changed to compensate this. e.g. _Object2World seems to be a normal identity matrix. I can’t find any documentation about this.
How do I get the actual local vertex positions and the real world/model matrix? Is there any documentation?
Example shader:
Shader "own/markercell"
{
Properties
{
_MaskTex ("_MaskTex", 2D) = "white" {}
_MainColor ("_MainColor", Color) = (1,1,1,1)
_NeighbourPos("_NeighbourPos", Vector) = (1,1,1,1)
}
SubShader
{
Lighting Off
Fog { Mode Off }
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
Tags { "Queue"="Transparent" "RenderType"="Transparent" }
Pass
{
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
#include "UnityCG.cginc"
sampler2D _MaskTex;
uniform fixed4 _MainColor;
uniform float _Scale;
uniform float4 _NeighbourPos;
struct vertOut
{
float4 pos : SV_POSITION;
float2 tex : TEXCOORD0;
float3 lpos : TEXCOORD2;
};
vertOut vert(appdata_full input)
{
vertOut output;
fixed4 pos = input.vertex;
output.lpos = input.vertex;
output.pos = mul (UNITY_MATRIX_MVP, pos);
output.tex = input.texcoord;
return output;
}
fixed4 frag(vertOut input) : COLOR0
{
fixed4 output = fixed4(0,0,0,0);
output.a = 1;
output.rgb = input.lpos;
return output;
}
ENDCG
}
}
}
The shader should simply show the local position as color but it shows the world position.