How do I change the size of vertices in a mesh?
I would like to change the size of the vertices in a mesh that is being procedurally generated but I am unsure how to do so
Here is the mesh generation code:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(MeshFilter), typeof(MeshRenderer))]
public class PointCloudTestMesh : MonoBehaviour {
private Mesh mesh;
int numPoints = 100;
// 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(Random.Range(0.0f,1.0f),Random.Range (0.0f,1.0f),Random.Range(0.0f,1.0f),1.0f);
}
mesh.vertices = points;
mesh.colors = colors;
mesh.SetIndices(indecies, MeshTopology.Points,0);
}
}
What do I need to do to get these vertices to be a different size?
What exactly do you mean with size? Vertices are mathematical points, they don't have a size.
If you want visible "points", ins$$anonymous$$d of cresting a new mesh, you could create a new, empty gameobject and add small spheres as children of that object.
https://docs.unity3d.com/ScriptReference/GameObject.CreatePrimitive.html
I was hoping that there was some kind of shader or method I could use to make the points bigger than 1 pixel. $$anonymous$$aybe a method that would create a group of points that represent a single point which is what I will probably end up doing unless there is a better way. The goal is to be able to display up to several million points at a time. I could do this with gameobjects but I think that unity cannot handle millions of gameobjects at a time. However, I could be wrong on Unity's ability to handle millions of gameobjects as I haven't tested it yet.
Answer by timetosmile · Oct 05, 2017 at 10:28 AM
I also looking for the same answer. I cannot believe that it is no more possible to change the size of a vertex.
I found a view description how to solve this problem, but there only work with openGl oder DX9 but this also doesn't work for me.
I tried it with glEnable(GL_VERTEX_PROGRAM_POINT_SIZE); an -force-opengl --> no changes. I changed the graphics API of Unity to all different possibilites but still no changes.
I am desperated an have no clue why nothing is changed. I used this http://www.kamend.com/2014/05/rendering-a-point-cloud-inside-unity/#comments for ma problem but it only allows to show colored small points. But I need to fill the emptyroom between them.
An other hint is to bild for each vertx a quad, but I think this would be to much for 90M Points. And a simple outside mesh is also not wanted cause I want to see in the model and compare changes in it.
Hopefully someone has a good idea or hint for me.
Thank you
Your answer
Follow this Question
Related Questions
Vertex coordinates of mesh imported from Blender as fbx are all equal to 0,0,0? 0 Answers
Adding Vertices to Coded Mesh? 0 Answers
Colliders position and scaling are misaligned with object meshes 0 Answers
How to dynamically scale an object to a fixed, predefined size at runtime? 0 Answers
Meshes in build occupy too much space 0 Answers