It’s been over 2 years since I posted about a method to recalculate normals in Unity that fixes on some of the issues of Unity’s default RecalculateNormals() method. I’ve used this algorithm (and similar variations) myself in non-Unity projects and I’ve since made minor adjustments, but I never bothered to update the Unity version of the code. Someone recently reported to me that it fails when working with meshes with multiple materials, so I decided to go ahead and update it.
Swizzle operators are convenient syntactic sugar for creating new vectors based on the combination of elements of other vectors. They are used in shading languages quite a lot.
vec4 a = vec4(0.1, 0.1, 0.2, 0.4);
vec3 b = a.xyz * a.w;
This is equal to:
vec4 a = vec4(0.1, 0.1, 0.2, 0.4);
vec3 b = vec3(a.x, a.y, a.z) * a.w;
They make more sense if you want to do some composition like so:
vec4 redColor = vec4(1, 0, 0, 0.5);
vec4 redNoAlpha = vec4(redColor.xyz, 1);
GLSL allows you to supply any amount of vectors or scalars in a vector constructor, as long as the count of all elements matches the dimension of the created vector.
However, swizzling isn’t allowed in most non-shading vector libraries. So, why not write simple extension methods that give that functionality to Unity?
I have been trying to start working a new game, but I’ve just not had enough free time since I started working for Mcor Technologies. Each time I sit down to think about the design of a game, it eventually turns out to be very ambitious in every department. I have planned out a couple of games with promising ideas, and I intend to work on them… eventually. But, that probably won’t happen while I work solo, especially due to the fact I’m mostly a programmer and not an artist.
There’s also another problem I was not expecting: I don’t have enough motivation to work on 3D games (which all my good ideas are based on), because I work with 3D programming every day at work for a non-gaming application. Not enough 3D juice left in me, I suppose.
For this reason, I thought it’d be a good idea to go back to the basics and work on a very simple, sprite-based puzzle game. I’ve laid out the basic design, did some of the programming and drew a few of the sprites. There is a title, but I won’t mention it until I have something more substantial to show.
For now, here is a walking Troll. This is the controllable character in the game:
I see the topic of choosing the “right language” when it comes to games brought up too many times in discussions all over the internet. The argument is usually between C++, C#, and Java. People do get religious about their favourite languages. At its heart this is an inherently flawed question, because the real decision should be on what framework or engine is best suited for a particular game, and that choice will usually dictate what language to use. Of course, the languages supported by a specific framework or engine can definitely be an important factor that may affect your decision.
And the truth is, assuming you have a choice, Java comes short in the race. When this is pointed out, some people erroneously claim that it’s a matter of “opinion”. That’d be true if it wasn’t so easy to prove that Java is ill-suited for games development. “You’d use the right tool for the right job” is very noble statement, and one that applies a lot in any kind of software development. But it’s also very abused and it gives the false impression that Java is sometimes the right tool.
I finally had some time to release a more complete version of Qute Configurer. This is a simple but extremely useful utility for anyone who wishes to develop in Unreal Engine using Qt Creator as their IDE.
The GitHub link can be found here, complete with source-code and binaries: https://github.com/Zoodinger/QuteConfigurer/releases/tag/v0.2.2
This application is based on the guide that can be found here: https://wiki.unrealengine.com/Using_QtCreator_With_UnrealEngine4
A full tutorial is embedded in the executable which explains how to set up Qt Creator, complete with both text and pictures. After this is finished, the user can simply choose to generate the appropriate Qt project files required for editing, building, and running their projects.
The project is open-source, and I would be delighted if other people contributed. Unfortunately, the current version only supports Windows. I don’t know if it’d be possible to make it work in Mac.
After a long time of silence, I decided to try out Unreal Engine. This experiment was long overdue, but I was happy using Unity so far. See, I do own the pro version of Unity 4.x and 5.x without paying (it was legally given to me to develop HandyMD), so not using it instead just seemed plain wrong. However, I wasn’t using it anyway. After HandyMD, the only Unity project I was involved with was not a game and is currently put on hold until further notice.
I know that I haven’t created a single new post in ages here. Not only that, but my website has not been working since late December and I’ve only realized that today – exactly a month later. What happened was that my current custom theme references its parent theme. WordPress had updated itself and deleted that theme for some reason. I couldn’t even login to wordpress to fix it. The solution was to go to my actual files and rename the folder of my theme. WordPress then allowed me to log-in, so I re-installed the missing theme and re-activated my custom theme. Props to my friend at http://www.patricktisdel.com/ for this very simple solution.
Thing is, I’ve been very busy with my new job and settling in a new city. A lot of my daily programming struggles involve very specific code related to work, so I didn’t have much to write about anyway.
For now, here is a word of wisdom:
If you want to make games, stay away from Java.
Not that Java isn’t okay for most things, but it is especially bad for 3d graphics programming. It’s not even a matter of preference. I will write a proper post about this soon.
I have been offered the position of Software Engineer at Mcor Technologies. This is truly great news, and I’m very excited and looking forward to start working there. They are the manufacturers of amazing 3d printing technology that can print highly detailed coloured models. See it for yourself:
After finishing my MSc, I had been actively looking for employment. Finding something that is both viable and interesting enough is not easy for any computer scientist. This job offers both of those things, and for that I am truly blessed.
It also looks like game design will remain a hobby for me, but I am not at all complaining. In fact, this recent development is in all likelihood far better than starting out at a crappy game studio that makes copycats of copycat games in an effort to cash in through ads and in-app purchases.
Delegates are one of the nicer features of C#. They’re essentially high-level and type-safe references to methods. But, like pretty much every fancy C# feature, delegate values are not serializable by default. If you hold a reference to a delegate, it will be lost during code hot-reload. I will show you a way to serialize them and explain how they work.
Note: This solution is inspired by the uFAction tool in Unity, which I am not affiliated with. Go check it out here.
Starting from Unity 4.5, any class can be made to inherit from ISerializationCallbackReceiver. This allows us to write methods that can be used to control seialization and deserialization, and it demands from the class to implement two public methods: OnBeforeSerialize() and OnAfterDeserialize(). These methods are automatically called when that class inherits from UnityEngine.Object or is marked with the [Serializable] attribute.
The idea behind this concept is both simple and powerful, but there are certain things you need to have in mind. Not only I will show you how to use this interface, I will also provide some information on things you should avoid or on things that won’t work as expected.