Visualizations have become an indispensable part of the scientific process. A vibrant ecosystem of visualization tools exists, catering to a wide variety of different needs. Real-time visualizations of numerical simulations offer scientists immediate feedback about the status of their simulations and can also be valuable educational and outreach tools. Developing a visualization tool with support for different operating systems, CPU/GPU architectures, and programming languages can be a challenge. It is common to use one or more graphics or UI libraries to act as abstraction layers and hide the underlying complexity. Whereas external libraries greatly simplify the initial programming effort, we argue that relying on them introduces new dependencies and problems, such as a higher entry barriers for new developers and users, and uncertainty regarding long-term support. In this paper we present a new approach for real time visualizations which we have implemented for the N-body package REBOUND. We propose to use a web browser to handle GPU accelerated rendering. This enables us to offer 3D, interactive visualizations on all major operating systems. What makes our new approach unique is that we achieve this without the need for any external libraries. We utilize WebAssembly to reuse existing OpenGL visualization code. Using communication via HTTP and a custom built-in web server, we are able to provide both local and remote real time visualizations. In addition to the browser based real time visualization, our approach offers other additional operating modes, including simulations running entirely within the browser, visualizations within jupyter notebooks, and traditional standalone visualizations using OpenGL. We focus on the implementation in REBOUND but the concepts and ideas discussed can be applied to many other areas in need of scientific and non-scientific real time visualizations.
翻译:可视化已成为科学进程中不可或缺的组成部分。当前存在一个充满活力的可视化工具生态系统,能够满足各种不同的需求。数值模拟的实时可视化不仅能为科研人员提供模拟状态的即时反馈,也可作为宝贵的教育与科普工具。然而,开发一款支持不同操作系统、CPU/GPU架构及编程语言的可视化工具颇具挑战。通常,人们会使用一个或多个图形或用户界面库作为抽象层以隐藏底层复杂性。尽管外部库极大简化了初期编程工作,但我们认为依赖这些库会引入新的依赖项与问题,例如提高了新开发者和用户的使用门槛,以及长期支持的不确定性。本文提出了一种实时可视化的新方法,并已在N体软件包REBOUND中实现。我们建议利用网页浏览器处理GPU加速渲染,从而在所有主流操作系统上实现三维交互式可视化。本方法的独特之处在于无需任何外部库即可达成此目标。我们通过WebAssembly复用现有的OpenGL可视化代码,并借助基于HTTP的通信协议与内置定制网页服务器,同时支持本地与远程实时可视化。除基于浏览器的实时可视化外,本方法还提供其他多种运行模式,包括完全在浏览器内运行的模拟、Jupyter Notebook内的可视化,以及使用OpenGL的传统独立可视化方案。本文虽以REBOUND的实现为重点,但所讨论的概念与思路可广泛应用于其他需要科学或非科学实时可视化的领域。