使用 3D 加速的图形渲染 [英] Graph rendering using 3D acceleration

查看:33
本文介绍了使用 3D 加速的图形渲染的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们为庞大的数据集生成图表.我们说的是每秒 4096 个样本,每张图 10 分钟.一个简单的计算使得每个折线图有 4096 * 60 * 10 = 2457600 个样本.每个样本都是一个双精度(8 字节)精度的 FP.此外,我们在一个屏幕上渲染多个线图,最多大约一百个.这使我们能够在单个屏幕中渲染大约 2500 万个样本.使用常识和简单的技巧,我们可以使用 CPU 在 2D 画布上绘制此代码,从而提高此代码的性能.高性能,即渲染时间低于一分钟.由于这是科学数据,我们不能省略任何样本.说真的,这不是一个选择.甚至不要开始考虑它.

We generate graphs for huge datasets. We are talking 4096 samples per second, and 10 minutes per graph. A simple calculation makes for 4096 * 60 * 10 = 2457600 samples per linegraph. Each sample is a double (8 bytes) precision FP. Furthermore, we render multiple linegraphs on one screen, up to about a hundred. This makes we render about 25M samples in a single screen. Using common sense and simple tricks, we can get this code performant using the CPU drawing this on a 2D canvas. Performant, that is the render times fall below one minute. As this is scientific data, we cannot omit any samples. Seriously, this is not an option. Do not even start thinking about it.

当然,我们希望使用所有可用技术来缩短渲染时间.多核、预渲染、缓存都很有趣,但不要削减它.我们希望这些数据集的渲染速度至少为 30FPS,首选 60FPS.我们现在这是一个雄心勃勃的目标.

Naturally, we want to improve render times using all techniques available. Multicore, pre-rendering, caching are all quite interesting but do not cut it. We want 30FPS rendering with these datasets at minimum, 60FPS preferred. We now this is an ambitious goal.

卸载图形渲染的一种自然方式是使用系统的 GPU.GPU 用于处理庞大的数据集并并行处理它们.一些简单的 HelloWorld 测试向我们展示了使用 GPU 时渲染速度的白天和黑夜差异.

A natural way to offload graphics rendering is using the GPU of the system. GPU's are made to work with huge datasets and process them parrallel. Some simple HelloWorld tests showed us a difference of day and night in rendering speed, using the GPU.

现在的问题是:像 OpenGL、DirectX 和 XNA 这样的 GPU API 是为 3D 场景而设计的.因此,使用它们来渲染 2D 线图是可能的,但并不理想.在我们开发的概念证明中,我们遇到需要将 2D 世界转换为 3D 世界.突然间,我们必须使用 XYZ 坐标系,其中包含多边形、顶点和更多优点.从发展的角度来看,这远非理想.代码变得不可读,维护是一场噩梦,更多的问题随之而来.

Now the problem is: GPU API's such as OpenGL, DirectX and XNA are made for 3D scenes in mind. Thus, using them to render 2D linegraphs is possible, but not ideal. In the proof of concepts we developed, we encountered that we need to transform the 2D world into a 3D world. Suddnely we have to work with and XYZ coordinate system with polygons, vertices and more of the goodness. That is far from ideal from a development perspective. Code gets unreadable, maintenance is a nightmare, and more issues boil up.

您对此 3D 的建议或想法是什么?这样做的唯一方法是实际转换两个系统(2D 坐标与 3D 坐标和实体)吗?或者有没有更时尚的方法来实现这一目标?

What would your suggestion or idea be to to this in 3D? Is the only way to do this to actually convert the two systems (2D coordinates versus 3D coordinates & entities)? Or is there a sleeker way to achieve this?

-为什么在一个像素上渲染多个样本很有用?因为它更好地代表了数据集.假设在一个像素上,您有值 2、5 和 8.由于某些样本省略算法,仅绘制了 5.这条线只会到 5,而不是 8,因此数据会失真.你也可以反驳,但事实是第一个参数对我们使用的数据集很重要.这正是我们不能省略样本的原因.

-Why is it usefull to render multiple samples on one pixel? Since it represents the dataset better. Say on one pixel, you have the values 2, 5 and 8. Due to some sample omitting algorithm, only the 5 is drawn. The line would only go to 5, and not to 8, hence the data is distorted. You could argue for the opposite too, but fact of the matter is that the first argument counts for the datasets we work with. This is exactly the reason why we cannot omit samples.

推荐答案

一个非常流行的科学可视化工具包是 VTK,我认为它适合您的需求:

A really popular toolkit for scientific visualization is VTK, and I think it suits your needs:

  1. 这是一个高级 API,因此您不必使用 OpenGL(VTK 构建在 OpenGL 之上).有 C++、Python、Java 和 Tcl 的接口.我认为这会让你的代码库保持干净.

  1. It's a high-level API, so you won't have to use OpenGL (VTK is built on top of OpenGL). There are interfaces for C++, Python, Java, and Tcl. I think this would keep your codebase pretty clean.

您可以将各种数据集导入 VTK(从医学成像到财务数据,有大量示例).

You can import all kinds of datasets into VTK (there are tons of examples from medical imaging to financial data).

VTK 速度非常快,如果您想进行非常大的可视化,您可以将 VTK 图形管道分布在多台机器上.

VTK is pretty fast, and you can distribute VTK graphics pipelines across multiple machines if you want to do very large visualizations.

关于:

这使我们能够在单个屏幕中渲染大约 2500 万个样本.

This makes we render about 25M samples in a single screen.

[...]

这是科学数据,我们不能省略任何样本.说真的,这不是一个选择.甚至不要开始考虑它.

As this is scientific data, we cannot omit any samples. Seriously, this is not an option. Do not even start thinking about it.

您可以通过采样和使用 LOD 模型在 VTK 中渲染大型数据集.也就是说,您有一个模型,您可以从远处看到较低分辨率的版本,但如果放大,则会看到较高分辨率的版本.大量的大型数据集渲染就是这样完成的.

You can render large datasets in VTK by sampling and by using LOD models. That is, you'd have a model where you see a lower-resolution version from far out, but if you zoom in you would see a higher-resolution version. This is how a lot of large dataset rendering is done.

您不需要从实际数据集中消除点,但您肯定可以在用户放大时逐步细化它.当用户不可能将 2500 万个点渲染到单个屏幕上时,您没有任何好处处理所有这些数据.我建议您同时查看 VTK 库和 VTK 用户指南,因为其中有一些关于如何可视化大型数据集的宝贵信息.

You don't need to eliminate points from your actual dataset, but you can surely incrementally refine it when the user zooms in. It does you no good to render 25 million points to a single screen when the user can't possibly process all that data. I would recommend that you take a look at both the VTK library and the VTK user guide, as there's some invaluable information in there on ways to visualize large datasets.

这篇关于使用 3D 加速的图形渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆