0 votes

Hello there,

I recently completed a project with a group of students to recreate a section of the Biosphere2 using 1500 photos converted to a point cloud using Metashape. I have already used unity to render the resulting 18million point dataset, but I'd love to use godot in future projects of this type and want to recreate the project as a test. In my experiments I haven't been able to render more than 5-6 million points with the built in particle system, or with the multimeshinstance3d and I'm wondering if this task accomplished in godot with the use of VisualServer, custom modules or something else? I'm essentially after the equivalent method to unity's https://docs.unity3d.com/ScriptReference/Graphics.DrawMeshInstancedIndirect.html inside of godot. Thanks for any and all information to spare!

similar threads that don't match my issue:

Godot version 3.4
in Engine by (12 points)

Not sure if this will be useful or not but have you tried Godot 4? I hear there's significant improvements regarding particle rendering and whatnot.

Hello there,

I haven't tried Godot 4 but I'm hearing all sorts of exciting stuff about it. Support for compute shaders seems like a really neat addition that will open up tons for those of us interested in godot and physical simulation.

I'll look into that but I imagine I'll probably be wondering the same thing. Is it just the standard godot 4 particle emitted that is so impressive?

I decided to attempt a naive series of tests. The idea was to see what the performance would be like if I rendered ~20 million points in godot 3.4 using this script. I had to bring in the threading because I found that the game window wouldn't respond if I left things in the _ready function. Now a test scene is free to define things like number of threads and number of points instantiated each time. I believe this means that I'm increasing the number of draw calls and that each draw puts less points on the screen but ultimately I'll be working with some systems that have a high number of cpu cores to support the thread numbers. Could have all this backwards again so open to hearing so. This example of course doesn't begin to handle point coloration, or reading in point cloud as input to Godot. Both of these are still things that I'd love to hear about from some folks more knowledgeable

extends Spatial


# Declare member variables here. Examples:
# var a = 2
# var b = "text"

export var material: SpatialMaterial
export var scalef: float =1
export var numpoints: int = 100
export var numthreads : int = 1
var mutex
var threads =[]

# Called when the node enters the scene tree for the first time.
func _ready():
    # call thread to add all the vertices
    # wait for finish in join

    mutex = Mutex.new()
    for i in range(numthreads):
        var thread = Thread.new()
        thread.start(self,"tf",[i,numpoints])
        threads.append(thread)


func tf(data):

    var vertices
    var id = data[0]
    var nump = data[1]

    vertices = PoolVector3Array()
    var array_mesh = ArrayMesh.new()
    var arr = []
    for i in range(nump):
        if i%100000 == 0:
            print("checkpoint",id ,(float(i)/nump)*100,"%")
        vertices.append(scalef*Vector3(randf(),randf(),randf()) - Vector3(scalef/2,scalef/2,scalef/2))
    print("finish")
    print("now doing things with the vertices")
    arr.resize(array_mesh.ARRAY_MAX)
    arr[0] = vertices
    array_mesh.add_surface_from_arrays(PrimitiveMesh.PRIMITIVE_POINTS,arr)
    var instance = MeshInstance.new()
    instance.mesh = array_mesh
    instance.set_surface_material(0,material)
    mutex.lock()
    add_child(instance)
    print(instance)
    mutex.unlock()

func _exit_tree():
    for i in range(numthreads):
        threads[i].wait_to_finish()

Out of curiosity I tried generating a cube of 18M random points more or less similarly to the above code snippet (the data was generated quickly enough that I didn't even resort to threading) and it looks like my rx580 can handle it pretty well, although frame rate goes down to around 40 fps when going inside the cloud (when shading is enabled; unshaded it keeps a clean 60fps).

Ah that's good to know! I expected unshaded would still allow for an albedo color to be set which is all I need. Perhaps this is the method that I'll use as it seems pretty straight forward. I'll leave this issue open just to see if anyone else wants to comment later on.

Please log in or register to answer this question.

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.