A long over due post about Unreal Engine

I realised today that I haven’t posted anything about Unreal Engine, and since my final major project for uni is made in it I thought this might be a good chance to show off some of the work we’ve done with it. Should be mentioned that I am working with two very talented artists on this project, so the models are not my own, however the shading/rendering is all mine in the following screenshots. Bare in mind this is all work in process stuff.

Most of the shaders are a standard PBR workflow from substance designer/painter, often starting off from substance B2M. I’m trying where possible to stay on top of the new features in UE4, using volumetic fog/lightmaps where I can. Since the game is designed to be played in VR having the 3D volumetric effects has been a real help in getting the look we wanted. As the next few weeks go on I’m excited to have more of the artists work put into the project and really start to get something that feels like a real speakeasy!

Also I post more of my work on twitter,  so follow me there if you want to see more!

Maya MEL exporter part 2

I made some changes to my MEL OBJ exporter so it exports the selected objects one by one, feel free to copy it from below, credits to Rob The Bloke for his MEL script examples on his website and to Jon Macey for hosting it. (Lucky enough to have a guest lecture from Rob recently, he really knows his stuff!)

 

Anyway here is the script feel free to copy: (and let me know if it could be better)

// Adapted from:
// https://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/mel/GUI_dialogs.html

// This procedure is called when the 'Open' button of the dialog is clicked.
// The procedure recieves the name of the file and it's extension
proc int onOk(string $dirpath,string $type) 
{
   string $path;
   string $name;
   $path = ($dirpath + "/");
   print("Path Set To: "+$path+"\n");
   // create a prompt dialog to request the users name
		
		    string $nameList[] = `ls -selection -long`;
		    select -cl  ;
            for($object in $nameList)
            {
                select -r $object;
                
                xform -cp;
                
    		    string $result = `promptDialog 
    			-title "Name The Asset: "
    			-message ("Enter Name: (" + $object + ")")
    			-button "OK" -button "Cancel"
    			-defaultButton "OK" -cancelButton "Cancel"
    			-dismissString "Cancel"`;
	 
        	 	// if OK pressed
        		if ($result == "OK") {
                    
                        // query the entry typed by the user
        			    $name = `promptDialog -query -text`;
        			    print("Exporting: " + $path + $name + "\n");
                        
                        float $x = getAttr($object+".tx");
                        float $y = getAttr($object+".ty");
                        float $z = getAttr($object+".tz");
                        
                        move -xyz -rpr 0.0 0.0 0.0 $object;
                        rotate -r -os -fo 90 0 0 ;
                    
                        file -force -options "groups=1;ptgroups=0;materials=0;smoothing=1;normals=1" -type "OBJexport" -pr -es ($path + $name);
                        
                        move -xyz $x $y $z $object;
                        rotate -r -os -fo -90 0 0 ;
                    }
        						  
        		else {
        			print("Export Canceled\n");
        		}
		}
   return true;
}

// The final parameter indicates the type of file dialog. 4=Folder Dialog
// The 1st parameter is a function to call when OK is pressed.
// The 2nd parameter is the text to appear on the OK button.
// The 3rd parameter is the type of file, somewhat meaningless here
fileBrowser( "onOk", "Text", "", 4 );

Pizza Jam – Dino Boi

Recently had a free weekend, so with a friend we took part in a game jam hosted on itch.io.

The theme of the jam was movement, and after some brainstorming at the pub we decided on an homage to this great scene in Jurassic Park:

The game is a simple platformer cobbled together in Unity over around 24 hours of dev time (Two 12 hour days). The twist being that only moving objects are visable, with the exception being your own dead body parts.

As you muddle through the levels you create a clearer picture of the map with the litter from your previous attempts. The video below shows one of the levels being finished after a few attempts:

My partner did the level design while I did the programming, and we both contributing to the art. It was pretty fun to just create some platform game staples (crushers, moving platforms etc.) and then see how we could put them together into 20 unique levels.

I always love doing game jams like this, taking a simple gameplay mechanic and letting it drive the development  always makes for something fun and interesting to play. Check out the game is you wanna play and the other games from the jam!

Smoothing Motion Capture Data

As part of my uni course I have to create a piece of original research into something in the CG field. For my project I designed and implemented a novel method of skeleton data smoothing. (This is the project I talked about a couple of posts ago).

I’d like to share some of the results of my research in a couple of videos. First video shows tracking of star jumps, to show the much smoother animation of my system compared to raw tracking data:

My system takes the tracking data broadcast across the network at 20Hz and plays it back at 60fps using a Kalman filter to interpolate across frames.

 

The Second video shows the estimation/fitting method I developed, applied to a couple of stretches. You should be able to see that the system makes accurate predictions about where the limbs should be in some cases or returns to a rest position if we have no data.

I’m really happy with the results we have achieved for the project and have submitted it to a conference for a poster submission and hope to get it accepted!

Export OBJ from Maya for UE4 : quick script

Here is a quick script I put together this morning,

It exports OBJs from Maya rotating so they are oriented correctly in UE4,

It has a nice file browser UI too!

// Adapted from:
// https://nccastaff.bournemouth.ac.uk/jmacey/RobTheBloke/www/mel/GUI_dialogs.html

// This procedure is called when the 'Open' button of the dialog is clicked.
// The procedure recieves the name of the file and it's extension
proc int onOk(string $dirpath,string $type) 
{
   string $path;
   string $name;
   $path = ($dirpath + "/");
   print("Path Set To: "+$path+"\n");
   // create a prompt dialog to request the users name
		string $result = `promptDialog 
			-title "Name The Asset"
			-message "Enter Name: (Dont put the extension)"
			-button "OK" -button "Cancel"
			-defaultButton "OK" -cancelButton "Cancel"
			-dismissString "Cancel"`;
	 
	 	// if OK pressed
		if ($result == "OK") {
		
			// query the entry typed by the user
			$name = `promptDialog -query -text`;
			print("Exporting: " + $path + $name + "\n");
			
			select -all;
            rotate -r -os -fo 90 0 0 ;
            
            file -force -options "groups=1;ptgroups=0;materials=0;smoothing=0;normals=1" -type "OBJexport" -pr -ea ($path + $name);
            
            rotate -r -os -fo -90 0 0 ;
		}				  
		else {
			print("Export Canceled\n");
		}
   return true;
}

// The final parameter indicates the type of file dialog. 4=Folder Dialog
// The 1st parameter is a function to call when OK is pressed.
// The 2nd parameter is the text to appear on the OK button.
// The 3rd parameter is the type of file, somewhat meaningless here
fileBrowser( "onOk", "Text", "", 4 );

The Project That Didn’t Want To Start

Before I start I also considered the following titles:

  • Developing on Windows for the first (and hopefully last) time
  • Putting the aarrrrrgggg in RnD (Shoutout to Ian Stephenson for that one)

As part of my final year at the NCCA I am doing a piece undergrad research. My research will be into “Integrating Live Skeleton data into a VR Environment”.

While this post will detail the lengthy process of getting the project off the ground, I will briefly describe the project for reference.

The idea is to have a VR environment that is a simulation of a room. Inside the real life room is a person walking around, using an Xbox Kinect we can track that person and map their skeleton onto a virtual skeleton. The VR client does not have to be linked to the Kinect, the data will be sent over the network.

The networking is handled using the MQTT protocol that uses a simple system of publishing to a broker and then subscribing to that broker to get the information. (The diagram explains it way better than I could, just look at that)

 

So step one of the project, set up an MQTT broker and publish to it and subscribe to get the messages back. This is implemented by a bit of software called mosquitto, a command line tool to handle setting up the broker and clients. This was pretty trivial to set up on my Mac (Screenshot below), or any Unix system for that matter. To set it up on Windows was a little more tricky for me since I’m not used to using cmd, but also pretty simple to get it running.

The day after I took this screenshot I got it working across my local network easily between a few machines. So far so good, feeling good about the project, working with this kinda thing is pretty fun so it was a nice way to start the project. But it gets worse don’t worry.

To add a bit more context, the project follows on from another that took place over the summer by another student at BU. Adam’s project set up MQTT in Unity using a C# library, which was nice since it was a piece of groundwork I didn’t have to do. This took a little bit of refactoring but I got it working on my Mac, but after discussing with my tutor we thought it would be best to use the same computer Adam used since it was on Windows, meaning I could do Kinect development on there too.

Seems like a good idea, saves the ‘works on my machine’ problem since the focus is on the research. Little did I know, this particular box of silicon and circuit boards had it in for me.

At this point, for those unfamiliar with the joys of Microsoft peripheral development I’ll do a little bit of Background. Kinect V1 came out for the Xbox 360. This was when the dominant Windows version was 7. The Kinect V1 also works on Windows * (The OS the machine was running when I received it). However it is not supported on Windows 10, only the Kinect V2 is supported on Windows 10 (And only 10, not 8 or 7). So when I received the Kinect V1 for use on the Windows 8 machine, no problems right?

Wrong.

Visual Studio Community 2017.

Microsoft are happy with the “Redefined fundamentals” of VS2017. However I found myself unhappy with how they redefined the “Sign In” button to act as a close button. This is particularly troublesome as signing in is required to use all of the great features, such as editing and running code. (A handy feature in for an IDE to have)

Microsoft’s Kinect SDK is tied in to Visual Studio, and rewriting the Kinect SDK for Unix didn’t seem like a measured response to this particular problem. (The thought crossed my mind a few times though) So what to do? Installing an older version of VS seems like a good plan, but it seems like the Sign in bug (or feature, I won’t judge) goes back to older versions of VS too.

So I decided to troubleshoot this problem with VS2017. I actually tried to debug the crash with an older version of VS but it still needed me to sign in, damn. I trawled the Microsoft forums a lot, but couldn’t find anything there to help. I tried turning off the internet, connect via LAN and WiFi, manually installing the license, at one low point I even tried a virus scan.

Reinstalling Windows seemed like a good idea at this point, however without a valid Windows 8 key, we had to use the free upgrade to Windows 10. Now some of you will have spotted the problem that I am about to run into, that’s right, Kinect V1 doesn’t run on Windows 10. It doesn’t even use the same SDK as the V2.

A few days spent waiting for the new Kinect, and a new operating system later, we seem to be ready to go. I sign in to VS2017, the sign in button seems to perform the function you would expect it to on Windows 10, so that’s a plus. I plug in the new Kinect, but something is wrong, I load up the Kinect config tool.

Oh no. Why. What did I do to in a previous life to deserve this, etc.

Kinect V2 can transfer much more data per second than its predecessor, in fact so much more that a regular USB 2.0 won’t cut it, it needs a USB 3.0. Something that the computer I was given does not provide, in fact at this point all it seems to provide is misery.

It has been around a week and a half of delays at this point, so waiting for a USB 3.0 PCI card to arrive didn’t seem to bad, I have Amazon Prime and just about made it for next day deliver so it wasn’t too bad at all. Inside the machine I had to move some components around to get the power cables to reach the new card, but all in all it wasn’t too bad. Remembering to plug in the Kinect helped a lot at this point, in fact it all just clicked into place after that.

Using cutting edge technology we can generate a 3D point cloud of a software student’s raw joy, as after 2 weeks of trying he successfully installed a fancy webcam.

Only took a change of OS, IDE, Kinect, USB Card, Moving the GPU, Downloading some drivers and some other bits and bobs and now I can begin to work on my Research.

 

To be honest it is fun to solve these kinds of problems, and in the long run I probably learnt some valuable lessons about Windows development (avoid it being the main one I think). And now I have set up a client that can send live skeleton data from a Kinect, through a Raspberry Pi broker, and back to whoever wants to subscribe to it and read the stream. (It is normally tracking me at my desk so I probably won’t share the ip, it’ll only be upsetting I’m sure). Which to be honest is pretty neat, I’ve never done anything like this before, and I’m not completely put off this kind of thing in future.

The moral of this story is don’t give up, the longer it takes the more satisfying it is when it finally works. And to a lesser extent, software that requires you to sign in to ‘improve user experience’ is a real ass sometimes.

5 things I wish I’d known about Unity 3 months ago

I just spent 3 months on a contract to develop a prototype for an app in Unity, these are five things I learned during development that you might find useful:

Proper commenting:

Just a simple one to start, using triple slashes above a variable declaration:

///A descriptive description
public GameObject myGameObject;

Now when we type the name of the variable the tool-tip box will have our nice description, handy!

Declutter your inspector window:

If you want public variable, but don’t want it to show in your editor:

[HideInInspector]

For some that will be obvious, for others I might have just changed your life.

Reclutter your inspector window:

Now we freed up some space in the inspector, lets fill it with something useful:

https://unity3d.com/learn/tutorials/topics/interface-essentials/adding-buttons-custom-inspector

This tutorial will get you started on making some custom editor buttons. The time you can save here will make you far more productive, for example a quick button to bypass your menus, or something like this:

if(GUILayout.Button("Print useful data"))
{
    Debug.Log(usefulData);
}

Just as a forewarning these buttons will work when you are still in the editor, so use EditorApplication.isPlaying to check if you’re playing if you need to.

C sharp is kinda nifty:

C sharp has some pretty nice built in functionality we can exploit for example:

MailMessage mail = new MailMessage();
[...]
SmtpClient smtpServer = new SmtpClient("smtp.gmail.com");
		smtpServer.Port = 587;
		smtpServer.Credentials = new System.Net.NetworkCredential("myGmailEmail@gmail.com", "myPassword") as ICredentialsByHost;
		smtpServer.EnableSsl = true;
		ServicePointManager.ServerCertificateValidationCallback = 
			delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors) 
		{ return true; };
		smtpServer.Send(mail);

and voila you’re sending emails from you game!

There is also some extension from Unity too, e.g.

[System.Serializable]

This lets your serialize Unity Lists, Vector3, Quats, lists of Vectors and Quats, etc.

DO NOT REINVENT THE WHEEL

Building stuff with Unity is great because there is so much in there already done, and if it isn’t included you can probably find the answer online. A few quick things I figured wouldn’t be there that are just hidden in the documentation:

  1. JSON read/write functionality, you can serialize a whole class to a cross platform and readable format,but wait there’s more.
  2. WWW, the WWW class is a treasure trove of functionality.
  3. DateTime is a datatype that comes from csharp but is certainly handy.

There is a lot of stuff that you might want to write your own though, for example a percentage based approximation function is pretty handy. Chances are there is one in there and I just haven’t found it.

 

Unity has a lot of gems in the engine that’ll make your life easier, unfortunately you might have to dig a bit to find them.

Group Project – Control

At the NCCA in second year, across all 3 animation courses, there is a group project. It is a chance for the technical people (like me!) and the artists to come together and make something that utilises our combined skills. I was part of a group of 6 that made a stealth action game called control, you can watch the extended trailer here:

(Please bear in mind that the capture method significantly reduced the quality and the fly throughs behind the credits are more indicative of final gameplay)

I am happy with what we made together, and proud that we managed to get what we have in basically 3 months.

For the project I was the lead programmer, that included the AI, Gameplay, Animations and also meant I did a lot of debugging/fixing the other smaller parts of the game. This was all done in Unreal Engine’s ‘Blueprints’ a method of visual scripting.

The blueprints did make some things very easy, it was a blast for example to quickly throw together a basic player controller in a day (move, jump, crouch etc.). However I found it to be limiting for some things, especially the AI. On balance I was happy to have used blueprints though. Especially as I hadn’t used UE4 at all in the past this was a great chance to learn a new skill.

While it is unlikely I will be able to upload the game source, please email me/comment on this post if you have any questions about how I achieved anything you see in the trailer, e.g. the climbing, AI perception, the ‘bombs or anything else!

QT GUI and Car Paint Shader

I have been working mainly on my group project of late in Unreal Engine and hopefully will have some stuff to post for that soon.

However my other ongoing degree assignment at the moment is to make a car paint shader in GLSL. So far I have been looking into BRDFs and PBR, and am still really in the early stages when it comes to shader code. However I have used this project as an opportunity to play around with the QT GUI system and have made a demo program for my shader. You can find the code on my Github, and see it in action in the video below:

VIDEO MIRROR