0 votes

If I have a list of points with x,y,z coordinates and want to draw/render/place them in a 3D scene what would be the best way to do it? Especially if there are a lot of points (100k+).

Thanks for any suggestions!

in Engine by (204 points)

2 Answers

+1 vote

Point clouds, you will probably want to look at OpenGl tutorials and Godot shaders.

The concept is simple. Every point has 2 values, a vector and a color; making it the most efficient point.
Then to render large worlds you will want to do some octree sorting, to only render what is seen.
Simple octree explanation: https://www.gamedev.net/articles/programming/general-and-gameplay-programming/introduction-to-octrees-r3529/

by (1,451 points)
+1 vote

Ok, I got some results using ImmediateGeometry. But the dots are tiny and strobe in and out (even with AA switched on).

var im = ImmediateGeometry.new()
add_child(im)
var m = SpatialMaterial.new()
im.set_material_override(m)
im.clear()
im.begin(Mesh.PRIMITIVE_POINTS, null)
for vector in pts:
    im.add_vertex(vector)
im.end()
by (204 points)

You could create small cubes or billboarded planes instead of using OpenGL primitive points (which are very limited). However, Godot doesn't support mesh batching out of the box (unless you use something like MultiMesh), so you would have to implement it yourself to keep the number of draw calls to a reasonable value.

Couldn't you just increase the point size?

Yeah, I don't know how to increase the point size of ImmediateGeometry

If you're using a SpatialMaterial then just set the point_sizein the parameter tab section.
If you're using a ShaderMaterial on the other hand, then set this variable POINT_SIZE in the vertex shader to whatever you want.

Perfect! Thank you so much!

Had to also set flags_use_point_size to true. In case anyone else needs it:

var point_size = 5
var im = ImmediateGeometry.new()
add_child(im)
var m = SpatialMaterial.new()
m.flags_use_point_size = true
m.params_point_size = point_size
im.set_material_override(m)
im.clear()
im.begin(Mesh.PRIMITIVE_POINTS, null)
for p in pts: #list of Vector3s
    im.add_vertex(p)
im.end()
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.