Topic was automatically imported from the old Question2Answer platform.
Asked By
dodgyville
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+).
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()
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.
Calinou | 2018-10-13 10:46
Couldn’t you just increase the point size?
SIsilicon | 2018-10-13 13:53
Yeah, I don’t know how to increase the point size of ImmediateGeometry
dodgyville | 2018-10-13 20:53
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.
SIsilicon | 2018-10-14 02:36
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()