• Ingen resultater fundet

This thesis has presented the design and implementation of a shader graph edi-tor. The editor can be used to create shaders in a simplified way, by connecting nodes with different functionality to create an specific effect. The presented sys-tem ensures that these connections are both syntactically and mathematically correct, by disallowing connections of differently typed variables, and automat-ically handling transformations from one mathematical space to another. The automatic space transformation has been demonstrated during the creation of a parallax mapping shader, where automatic transformations to both tangent and world space are performed, without the user has to think about that. It should be noted that under some circumstances, the automatic transformations can cause a graph shader to perform slower than a handcoded shader. Generally the two shaders will perform equally well though.

In order to increase the usability of the editor, we have implemented a group-ing feature, so several nodes can be turned into one. We have demonstrated through examples, how this can be used to increase the overview of a shader graph. We have further more introduced an preview option for the nodes, that will demonstrate the intermediate results throughout the shader graph. This preview option will make debugging the shaders generated with the graph eas-ier, as it will be possible to see where something goes wrong. The features such as creating group nodes, are handled from our simple but yet fully functional GUI system.

On the contrary to other accessible shader graph editors, we are able to handle both vertex and fragment shading using the editor described here. This has given the possibility to perform optimizations by putting more calculations in the vertex program, and has enabled the shader graph user to create shaders that actually transform the vertex position. During both vertex and fragment shading, swizzeling can be needed, so this has been supported by making specific swizzle nodes. In the case that more nodes are needed, it should be possible for programmers to create those, by using the simple node interface where basically only a single function has to be created.

The presented shader graph has been integrated with a commercial game engine, which has given us the unique opportunity to support effects such as shadows and different light attenuation in the created shaders. This has been done by creating a novel processing step, where several versions of the vertex and frag-ment programs are generated, to match the effects that should be supported by

the shader. The engine integration has also led to the use of effect files for stor-ing the shaders, which gives the user the option to handle OpenGL renderstor-ing state settings, such as blending and culling.

Appendix A

Introduction to Unity

A.1 Introduction to Unity

Unity is a Mac based game development platform, developed with ease of use in mind. The system combines a powerful game engine with an editing interface.

Unity has always been developed with ease of use and workflow in mind. Every-thing in Unity is contained within one window, that can look like the screenshot in figureA.1.

The top-left view of the application is the scene view. When creating a game the user sets up her scene in this view by dragging objects and models into it. Models from most modeling packages are imported into unity automatically, if they are saved in the folder for the active project. It is not possible to do any modeling inside Unity itself. The contents of the project folder can be ex-amined in the project view, which is situated to the bottom right of the scene view. It is possible to use the create button on the top of this view to create new materials, render-textures and so on. Any selection will be shown in the inspector to the right of the project view. Here is is possible to manipulate the selected game object in any way it supports. For the case of the selected material it is possible to assign its texture, change it to use a different shader and so on. The whole scene hirachy is displayed in the middle-top view, and the left-bottom view displays the result as it will look in the actual game. Unity has

Figure A.1: The Unity application

build-in physics, using the well known Novodex API from Ageia. Physics and other game-play related behaviors can be scripted using the .NET framework (C#, javascript) or the phyton like language Boo. Unity also has packages for importing and playing audio-clips and text rendering. The text rendering were implemented as a part of the shader graph project, and will be discussed briefly later. Unity is primarely aimed towards indie game developers for casual games creation. It is also possible to use it for architectural renderings, 3D commer-cials and much more. The standard Unity user will be an artist that knows a little programming, or an indie developer that knows a little bit of everything.

More information on Unity and projects involving Unity can be found on the applications home-page: www.otee.dk.

As this project concerns the creation of shaders, we will primarily concern our-selves with the material system in Unity, and focus on a way to develop and integrate a graphical approach to shader creation. The motivation for this is that very few users take advantage of the advanced shader capabilities Unity offers. Unity has a build in shading language (discussed in the next section), but most users are intimidated by the level of difficulty, and graphics programming knowledge required, to master such a language. We therefore with to present

an more accessible way, to utilize the powerful graphics capabilities of modern computers.

Appendix B

#pragma p r o f i l e s a r b f p 1

f l o a t 4 c o l o r ;