Integration of Image Processing Techniques Into the Unity Game Engine
Total Page:16
File Type:pdf, Size:1020Kb
Integration of Image Processing Techniques into the Unity Game Engine Leon Masopust1, Sebastian Pasewaldt2,Jurgen¨ Dollner¨ 1 and Matthias Trapp1 a 1Hasso Plattner Institute, Faculty of Digital Engineering, University of Potsdam, Germany 2Digital Masterpieces GmbH, Potsdam, Germany fleon.masopust, juergen.doellner, [email protected], [email protected] Keywords: Image Processing, Game Engines, Unity, Integration Approaches Abstract: This paper describes an approach for using the Unity game engine for image processing by integrating a custom GPU-based image processor. For it, it describes different application levels and integration approaches for extending the Unity game engine. It further documents the respective software components and implementation details required, and demonstrates use cases such as scene post-processing and material-map processing. 1 INTRODUCTION choose Unity because, it represents a popular and a common-used real-time GE that is freely available and Game Engines (GEs) such as the Unity or the Un- well documented. It is easily extendable at different real Engine, gain increasing popularity in Computer levels (Section 3.2), e.g., using native rendering plug- Science with respect to teaching, training, or for pro- ins. Further, it potentially supports multiple platforms totyping interactive visualization techniques. Besides and provides sophisticated Augmented Reality (AR) the potential support for multiple target platforms, GEs and VR components and interfaces. offer basically a technology platform used for perform- This paper presents the methodology and applica- ing feasibility studies, performance tests, rapid appli- tion examples for performing image and video pro- cation development, and to generate test data for the cessing techniques within real-time GEs using dedi- development of new techniques (Lewis and Jacobson, cated hardware support, such as Graphics Processing 2002). Units (GPUs). Therefore, it presents a concept for rd Using such functionality enable faster iterations on integrating 3 -party image processors into Unity and prototypes and support simplification of the overall discusses the results by means of different applica- implementation process. Thus, one major advantage tion examples. To summarize, this paper makes the of using GEs as a integration and implementation plat- following contributions: form is rapid prototyping, i.e., to effectively perform 1. It describes and discusses different application lev- feasibility studies or for teaching purposes. Further, els as well as suitable integration strategies for 3D GEs can be considered a base system for integrating GEs. 3D rendering to multiple back-ends and Virtual Real- 2. It reports on a feasibility study regarding the ity (VR) applications. Generally, it lowers the techni- Unity GE and different Visual Computing As- cal barrier as well minimize project setup and deploy- sets (VCAs) (Durschmid¨ et al., 2017). ment costs and thus enable practitioners and students to focus on algorithm technique development instead 3. It demonstrates our approach using different appli- of engineering tasks. cation examples. Although previous work exist, that uses Unity as a The remainder of this paper is structured as follows. platform for image processing (de Goussencourt and Section 2 reviews related and previous work with re- Bertolino, 2015; Anraku. et al., 2018), possible inte- spect to using GEs in scientific contexts. Section 3 gration approaches and its implementation and impli- describes the concept and implementation of integrat- cations are not covered so far. For a feasibility study, ing a 3rd-party image and video processing component the paper uses Unity as an example for a 3D GE, how- into the Unity GE. Based on that, Section 4 presents ever, the described concepts are not limited to. We and discusses different case studies and present ideas for future research directions. Finally, Section 5 con- a https://orcid.org/0000-0000-0000-0000 cludes this work. Unity Engine UnityPackage Generic Unity Interface Custom Image Processor OnRenderImage() GL.IssuePluginEvent() DoProcessing() Figure 1: Overview of a basic integration approach of a 3rd-party image processor into the Unity GE. 2 RELATED WORK et al. extend the Unreal GE to prototypical implement metaphors for visualization of trend data in interactive In recent work, game engines are often used for pro- software maps (Wurfel¨ et al., 2015). totyping interactive visualization techniques and for More recently, Bille et al. present an approach to vi- educational purposes in 3D Computer Graphics (CG). sualize Building Information Model (BIM) data using This section focuses on research results that use GEs a GE (Bille et al., 2014). Their case study demon- in scientific work, tools, and integration approaches. strates the conversion from BIM to GEs from the BIM tool Revit to the Unity game engine. Similar thereto, Ratcliffe uses GEs to create photo-realistic Game Engines in Visualization. In the past, GE interactive architectural visualizations (Ratcliffe and were often used for innovations and prototyping inter- Simons, 2017). Specific to terrain visualization, Mat active visualization (Rhyne, 2002; Wagner et al., 2016) et al. present a review of 3D terrain visualization tech- and pre-visualization (Nitsche, 2008). With respect niques using game engines (Mat et al., 2014). to geovisualization, Herwig and Paar discuss options In addition to real-time rendering capabilities, Ja- and limitations of GEs as low-priced tools for land- cobson and Lewis emphasis the importance of GEs for scape visualization and planning (Herwig and Paar, VR applications (Jacobson and Lewis, 2005). They use 2002). They argue and demonstrate that particular the Unreal GE as a low cost alternative to construct software components are useful alternatives to land- a CAVE installation. Similar thereto, the approach scape architects and planners, e.g., to support collabo- of Lugrin et al. relies on a distributed architecture to rative landscape planning, although a number of pro- synchronize the user’s point-of-view and interactions fessional features are not supported. Further, Fritsch within a multi-screen installation in real-time (Lugrin and Kada emphasis the usefulness real-time visualiza- et al., 2012). An accompanying user study also demon- tion using GEs with respect to presentation purposes in strates the capacity of GE’s VR middleware toelicit the domain of Geographic Information Systems (GIS) high spatial presence while maintaining low cyber- and Computer Aided Facility Management-Systems sickness effects. There is also a number of recent (CAFM) (Fritsch and Kada, 2004), especially consid- work that focus on other GE aspects besides render- ering the possibilities for mobile devices such as note- ing. For example, Juang et al. use GEs for physics- books and cell phones. They show that the integration based simulations (Juang et al., 2011) while Leahy of additional data and functionality into such systems and Dulay present cyber-physical platform for crowd can be achieved by extending the internal data struc- simulation (Leahy and Dulay, 2017). tures and by modifying the accompanying dynamic link libraries. Andreoli et al. provide a categorization of 3D GEs Education using Game Engines. Another applica- regarding their usage in creating interactive 3D worlds tion field of GEs is education. For example, Marks and a comparison of the most important characteris- et al. evaluated GEs for simulated surgical training, tics (Andreoli et al., 2005) regarding interactive ar- concluding that these represent a good foundation for chaeological site visualization. In addition thereto, low cost virtual surgery applications and identified Wunsche¨ et al. analyze the suitability of GEs for visu- limitations of physical simulation capabilities (Marks alization research in general and present a software ar- et al., 2007). Targeting high-resolution displays, Sig- chitecture and framework for a data transformation and itov et al. present an extension of Unity that allows mapping process to facilitates their extension as well for the implementation of applications that are suitable as further evaluate the suitability of popular engines re- to run on both single-display and multi-display sys- spectively (Wunsche¨ et al., 2005). A similar approach tems (Sigitov et al., 2015). This approach simplifies and comparison was conducted by Kot et al. targeting software development, especially in educational con- the domain of information visualization (Kot et al., text where the time that students have for their projects 2005). In the domain of software visualization, Wurfel¨ is limited. UnityPackage CustomPlugin UnityProcessor GenericMaterial GenericPostProcessor C++ C# -instances : List<UnityPluginHandler> +GenericMaterial(texture: RenderTexture) +Init() +Init() : int +~GenericMaterial() +ShutDown() +ShutDown(id : int) +ApplyVCA() +OnRender() +PassRenderToTextureInfos(id: int, sourceTextureID : uint, targetTextureID : uint) +RenderEventCallback(id : int) +SetVCA(id : int, vca : String) +SetPreset(id : int, preset : String) CustomMaterial +SetParameter(id : int, parameter : String, value : String) CustomPostProcessor +GetVCAString() : String -VCA : String +GetPresetString() : String -Preset : String -VCA : String <<use>> +GetParameterString() : String +UpdateInformation() -Preset: String -Parameters : List<Parameter> 0..* +UpdateInformation() CustomProcessor UnityPluginHandler +Init() : int -vca : String +ShutDown(id