UnityカスタムシェーダでPOINTSIZEを変更する。
Shader "Custom/VertexColor"
{
Properties{
_Size("ShaderSize", Float) = 1.000000
_PointSize("PointSize", Float) = 5.0
}
SubShader{
Pass {
LOD 200
CGPROGRAM
#pragma vertex vert
#pragma fragment frag
uniform float _PointSize;
struct VertexInput {
float4 v : POSITION;
float4 color: COLOR;
};
struct VertexOutput {
float4 pos : SV_POSITION;
float4 col : COLOR;
float psize : PSIZE;
};
VertexOutput vert(VertexInput v) {
VertexOutput o;
o.pos = UnityObjectToClipPos(v.v);
o.col = v.color;
o.psize = _PointSize;
return o;
}
float4 frag(VertexOutput o) : COLOR {
return o.col;
}
ENDCG
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class PointCloud : MonoBehaviour
{
private Mesh mesh;
int numPoints = 600000;
// Use this for initialization
void Start()
{
mesh = new Mesh();
GetComponent<MeshFilter>().mesh = mesh;
CreateMesh();
}
void CreateMesh()
{
Vector3[] points = new Vector3[numPoints];
int[] indecies = new int[numPoints];
Color[] colors = new Color[numPoints];
for (int i = 0; i < points.Length; ++i)
{
points[i] = new Vector3(Random.Range(-10, 10), Random.Range(-10, 10), Random.Range(-10, 10));
indecies[i] = i;
colors[i] = new Color(0,0,1, 1.0f);
}
mesh.indexFormat = UnityEngine.Rendering.IndexFormat.UInt32;
mesh.vertices = points;
mesh.colors = colors;
mesh.SetIndices(indecies, MeshTopology.Points, 0);
}
}