I create a mesh in Unity3D based on a point cloud in this way:
// The standard sequence for creating a mesh
Mesh mesh = new Mesh();
Vector3[] points = new Vector3[numPoints];
int[] indecies = new int[numPoints];
Color[] colors = new Color[numPoints];
// Fill in points, indecies, colors
mesh.vertices = points;
mesh.colors = colors;
mesh.SetIndices(indecies, MeshTopology.Points, 0);
I learned that it is possible to set the size of points in PSIZE through Vertex Shader. Applied such a Shader, but without result.
Shader "VertexColor"
{
Properties
{
_PointSize("Point size", Float) = 5.0
}
SubShader
{
Pass
{
LOD 200
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
uniform float _PointSize;
struct VertexInput
{
float4 vertex: POSITION;
float4 color: COLOR;
};
struct VertexOutput
{
float4 pos: SV_POSITION;
float4 col: COLOR;
float size: PSIZE;
};
VertexOutput vert(VertexInput v)
{
VertexOutput o;
o.pos = UnityObjectToClipPos(v.vertex);
o.col = v.color;
o.size = _PointSize;
return o;
}
float4 frag(VertexOutput o) : COLOR
{
return o.col;
}
ENDCG
}
}
}
Tell me, please, how to set the size of points correctly?