是否可以以每秒 60 次的速度从点数据构建热图?

2021-12-19 00:00:00 opengl visualization heatmap simulation c++

我正在对云(实际云)进行模拟,其中云由 3D 点模拟,然后投影到大约 640x480 单位大的 2D 热图.点数大约是 50k,这是在没有模拟中断的情况下我所能做的最小的,但我似乎无法找到一种以任何速度执行此操作的方法(通常需要 3-5 秒的运行时间)

我想我的问题是,普通计算机是否能够做到这一点?我通常会低估当今计算机的速度,但在这种情况下,我可能高估了它们.我还没有优化模拟,但如果完全不可能,最好现在知道并避免麻烦.

如果可能,是否有任何技术可以证明对从点数据到热图的转换速度足够快以达到每秒更新 60 次有用?它实际上只是查看点数据并将转换后的结果写入二维数组,因此我认为它主要与内存查找有关.

解决方案

这绝对是可行的,可能即使计算是由 CPU 完成的.理想情况下,您应该使用 GPU.所需的 API 是 OpenCL 或者由于您正在呈现结果,因此您可能希望使用 计算着色器.

这两种技术都允许您编写一个小程序(着色器)来处理单个元素(点).这些都在 GPU 上并行运行,这应该能让它们运行得非常快.

I'm working on a simulation for clouds (actual clouds) where the clouds are simulated by 3D points, then projected into a 2D heatmap, about 640x480 units big. The number of points is about 50k, which is as small as I can go without the simulation breaking, but I can't seem to find a way to perform this with any speed (it usually takes 3-5 seconds of runtime)

I suppose my question is, is it feasible for an average computer to be able to do this yet? I usually underestimate how fast computers are nowadays, but I might be overestimating them in this case. I haven't optimized the simulation yet, but if it's flat-out not possible, it'd be good to know and save the trouble now.

If it is possible, is there any technique that might prove useful for making the conversion from point data to heatmap fast enough to update 60 times a second? It really is just looking at the point data and writing to a 2D array the results after a transformation, so it's mostly bound to memory lookup I think.

解决方案

It is definitely feasible, probably even if the calculation are done by the CPU. Ideally you should be using the GPU. The APIs needed are either OpenCL or since you are rendering the results you might want to make use of Compute Shaders.

Both techniques allow you to write a small program (shader) that works on a single element (point). These all get run in parallel on the GPU which should allow them to run really fast.

相关文章