What is suggested approach for realtime rendering of photogrammetry point cloud data in godot?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By humbletang

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 Unity - Scripting API: Graphics.DrawMeshInstancedIndirect inside of godot. Thanks for any and all information to spare!

similar threads that don’t match my issue:

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.

skysphr | 2022-01-23 19:48

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()

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("now doing things with the vertices")
	arr[0] = vertices
	var instance = MeshInstance.new()
	instance.mesh = array_mesh
func _exit_tree():
	for i in range(numthreads):

humbletang | 2022-01-24 06:09

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).

skysphr | 2022-01-24 23:07

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.

humbletang | 2022-01-30 22:10