Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Help  Spatial queries
#1
Hi,

I have two emitters parented by the same solver on the scene. Their particle systems are turned as I don't need it.  And I want to apply spatial queries to both of the emitters fluid particles. 

What is the best way for an efficient query on the both actors at the same time ? 
The obvious method is setting a for-loop on an actors solverIndices and make the query and open another for-loop for going through the results. But what is the better way if I would like to combine a query on both emitters ? Running a for-loop on each actor separately ?

Another question is; I see a a significant framerate drop when running a spatial query. Would it be an idea to use a compute shader for running a similar process ? 
Meaning that, sending the sover positions array to the compute shader on each update step and then getting the simplice proximity results from the compute shader. I have used compute shader for N-body gravitational system simulation and it has a similar nested for-loop obviously. 

thank you for your directions.
Reply
#2
(25-10-2023, 07:12 AM)CosmosST Wrote: Hi,

I have two emitters parented by the same solver on the scene. Their particle systems are turned as I don't need it.  And I want to apply spatial queries to both of the emitters fluid particles. 

What is the best way for an efficient query on the both actors at the same time ? 
The obvious method is setting a for-loop on an actors solverIndices and make the query and open another for-loop for going through the results. But what is the better way if I would like to combine a query on both emitters ? Running a for-loop on each actor separately ?

Hi,

All spatial queries are performed on a per-solver basis, all actors in the solver are queried in parallel. No need to use a for loop over individual actors. It's also possible to perform multiple queries in parallel, so you can for instance issue 10 raycasts against all actors in the solver in a single call. See:
http://obi.virtualmethodstudio.com/manua...eries.html



(25-10-2023, 07:12 AM)CosmosST Wrote: Another question is; I see a a significant framerate drop when running a spatial query. Would it be an idea to use a compute shader for running a similar process ? 

The cost of bringing back query results from the GPU would quickly exceed the cost of performing the query on the CPU, as if you want query results on the same frame you've requested them this will stall the GPU and force it to flush the entire pipeline.

This said, Obi 7 (released later this year) has a full compute-shader based physics backend. Queries in that backend can be performed, but have a few frames of latency which means you get the results asynchronously a few frames after requesting the query.

kind regards,
Reply
#3
Thanks for the reply. I will work on your comments. 

However at the sametime, I have implemented a compute shader for calculating the spatial requirements taking the fluid particle position as an input ( the relevant indexes are stores as well ). It finds the 3 nearest particle for each particle in the fluid system. And all these are drawn with LineRenderers with smooth updates.

The result is very satisfying, no frame-rate drops and I am quite happy with that and will move on. 

You can never know without trying, there is the CPU-GPU traffic indeed but also a remarkable increase in overall performance. 

thanks
Reply