Web 2.0 on Steroids -2-

The name of Unity3D may implies that it is only a 3D engine, but Unity is much more. It can be used even without any interface, for example as a background service or a game server. The 2D and 3D capabilities of Unity are sharing the same technology. Your output is rendered in 3D, even if you target only 2D. The hardware acceleration of 3D makes it so fast, that its worth it to render everything in 3D. On 2D output the z-value of the game objects are neglected, so all objects are appearing on a plane. Most modern games are mixing 2D and 3D content.

User interfaces in Unity are rendered through a separate system. This system is optimized for GUIs and organizes output and user input events. With animation support this objects can be structured and presented in a beautiful way. Every UI element are drawn onto a canvas element. This can be in screen space or even in world space. The drawing process will not differ, but the resulting texture will be positioned according the chosen space.  For static UI elements the screen space will guarantee, that the interfaces will be on the same position, even if the used camera will move or rotate. A world space canvas will result in a user interface, that is positioned in the scene and will only be visible, if the camera is looking at it.

The important question is: Why should I consider using this, if I could use HTML as in the good old days? Do you remember WebGL? You do not need 3D? OK, so it is a question of what are you needing. The usage of Unity worthens only from a certain point. If you reach this point you will benefit from the possibilities of this great engine. But if not, you will hunt dugs with your bazooka. So this article will only be useful if I can provide some numbers and cases, but this will happen next time…

Web 2.0 on Steroids

Emerging new technologies are changing the web from its usual 2D in- and outputs to 3D and virtual worlds. Even smartphones have enough power to project new worlds on the go.  Instead of forming a new web standard, known technologies are recycled to support this kind of spectacular output. This is a blessing or a curse. While developers have not to change tools and their habits, the available possibilities are limited by the legacy. For usual stuff this is enough, but for performance demanding application, as VR, this bottleneck is an important motive to develop platform dependent non-web content.

This weekly blog series will try to discover possibilities and spot on challenging bottlenecks and limitations. I will try to lighten the world of WebGL and Unity3D from a non-technical perspective.

Our first entry will review the technology used to project 3D spaces onto you 2D screen. WebGL is the key technology, that enables the usage of OpenGL in your browser. While OpenGL was the first widespread standard, that enabled 3D on your computer since 1992, WebGL is an extension in your browser, that enables the usage of OpenGL ES 2.0 (WebGL 1.0).

OpenGL is a well-known rasterizer API that generates graphical outputs mainly through a state machine. You set the OpenGL state to the right behavior, set your matrices, send geometrical information, textures to your GPU and start the rasterization, which will be influenced by used shaders. Shaders are really fast GPU programs that changes the visual output nearly instantly.

At the first view, you will detect, that this process is fundamentally different from the dynamic REST approach, where you mainly use events to create the right behavior. And for this event-driven approach JavaScript was designed for. With WebGL two different worlds collides. This is one of the main reasons why this standard is not so popular among web developers. Most times only a graphics programmer can handle the complexity of an OpenGL program.

At this step Unity3D (and other great engines) will come to rescue you from the dark voids of mathematical programming. Unity3D is cross platform engine, that can generate all kinds of visual stunning output in a convenient way. The asset store will help you to build your own development stack and will shorten your development cycles. For implementing custom behaviors, you can use C# or even a modified JavaScript version. This called scripts are attached to game objects, that are your actors in your scene graph. This organization structure will be translated into OpenGL commands and JavaScript logic on your WebGL output.

With bypassing direct WebGL you are able to develop 3D content in a fast, cheap and convenient way. Without to knowing details of the rendering pipeline or mathematical backgrounds of the rasterizing process. This does not mean, that this knowledge is useless if you are using Unity3D. But you can achieve great results without this expertise. And if you need more, there are really good specialists out there, which can help you with your projects.


In our next blog entry I will try to show some great use cases for 3D (or even 2D) with Unity3D on user interfaces and on the web.