April 22, 2020

Why you should use GitHub

GitHub is one of many services where you can upload your code for version control. The basic idea behind version control is that code projects tend to become big and messy and version control makes the project less messy - especially if many people are working with the same project.
I think it was last year I really started to use GitHub for my code projects. I had several years earlier tried to start using GitHub but I stopped because I think I felt GitHub was confusing to use and I didn't really need it. But last year I found Sourcetree which is making GitHub less confusing to use (you don't have to memorize git commands). I also learned that GitHub has started to allow free private repositories - when I first started using GitHub all code had to be available free to everyone which is obviously not good if you are working on secret projects. So now I've put almost all my code on GitHub.

If you are working with a team then you almost always need to use GitHub or some similar service. But why should you, as an individual user, use GitHub?
  1. Backup. It's never fun when your computer crashes and your projects disappear into the darkness. To backup your projects you can copy-and-paste them into some backup software like Google Drive och Dropbox. This is working fine but can be a little annoying if you make many updates. With GitHub you can backup your projects with just a few clicks. You should still use another backup method because you can't trust GitHub - there's always a small probability that they will mess up and your code is gone forever, so it's always better to be safe than sorry. 
  2. Easier to experiment. Let's say you want to experiment with an idea you have and this idea involves deleting some code. Now deleting code for experimental purposes is never good because the experiment might fail and then you have to recreate the deleted code. With GitHub you can start different branches, which will split your code into branches and you can easily change between each branch to compare the experiment with the original code. If you are not happy with the experiment, just delete the branch.    
  3. You don't need to be tech support. What I've done lately is to publish some of my Unity tutorials on GitHub. I earlier had this pedagogical idea that people will learn more if they read the tutorial instead of copy-and-pasting from GitHub. But people will sometimes fail, so they will e-mail you and you have to spend time trying to solve their problems. It's also much easier to update code through GitHub than to update the code you earlier copy-and-pasted into html. So publishing your tutorial code on GitHub will save you time and energy.
  4. Free marketing. Something I realized after putting my code on GitHub is that people also found my code through GitHub's search function - they didn't come just from the original site. GitHub has a small, but still adequate, analytics page where you see from where people found your code. So if you want people to find you code you should put it on GitHub because it might be difficult to make people find your code by just making your original site rank higher in the search engines. And if you link your Twitter account from GitHub you will also get a few extra Twitter followers! 
  5. People will test the code for you. GitHub has this function where people can easily report issues with your code, which is really good because it might be difficult to test the code on your own.  

So how can you start learning GitHub with Unity if you have no idea where to begin? I think this tutorial is a good start: Using Git with Unity Tutorial [2019]. It will teach you how to use GitHub with Sourcetree. Atlassian, the creators of Sourcetree, has also created this online course: Version Control with Git, which you can go through in a few hours and it will teach you a little more than just the basics.

If you are interested in visiting my GitHub account you can find it here: github.com/Habrador

January 1, 2020

Books I read in 2019

Each year I write a list of books I read during the year. This is the 2019 list:
  1. Predator: The Secret Origins of the Drone Revolution. Tells the history of the most famous military drone: The Predator.
  2. Fighter Wing: A Guided Tour of an Air Force Combat Wing. A combat wing is a collection of different military aircraft organized to complete a specific mission. This book tells you about the different aircraft, the weapons, and the organization.
  3. Bomb Hunters: Life and Death Stories with Britain's Elite Bomb Disposal Unit in Afghanistan.  
  4. A Dawn Like Thunder: The True Story of Torpedo Squadron Eight. Tells the story of a carrier based squadron of torpedo bombers during the battle of Midway and Guadalcanal. 
  5. Designing Games: A Guide to Engineering Experiences. There are many books on how to make games, but this book is written by the game developer who made RimWorld. That game sold more than one million copies, so you better study the book. He wrote it before he made RimWorld. 
  6. Dust Off - Army Aeromedical Evacuation in Vietnam. Tells the story of medical helicopters in the Vietnam War. Is available for free!
  7. The Grid: Electrical Infrastructure for a New Era. One often forgotten achievement of humanity is that we have electricity in our homes. But this system is crumbling because the system is old and will also change to be more environmentally friendly, so if you want to learn about the feature of how to deliver electricity, you should read this book. 
  8. Logistic Support. Much has been said about the battles of the Vietnam War - but not what happened behind the scenes. To fight a battle you need ammunition, food, etc. How can you transport it from US to Vietnam in the best way? This book will give you an overview of the logistics behind the Vietnam War. Is available for free!
  9. Wind, Sand and Stars. Is a memoir written by a french pilot who in the 1930s was flying mail across the french empire. 
  10. Topgun: An American Story. Is written by one of the founders of Topgun (and yes it is "Topgun" and not "Top gun" as in the movie). Despite the name, the book is not only about Topgun - it's a biography of the authors career in the US Navy.  It starts with the Vietnam war, some Topgun in the middle, and ends when he commands an aircraft carrier. His basic idea is that the pilot is more important than the aircraft, so it includes some criticism of the latest aircraft in the US Navy: the F-35, arguing that a cheaper aircraft with a more skilled pilot would have been a better solution.
  11. Why Did the Chicken Cross the World? Tells the history of the chicken. 
  12. Last Stand at Khe Sanh: The U.S. Marines' Finest Hour in Vietnam. Khe Sanh was a military airfield in Vietnam and this book tells the story of when it was under siege for more than two months.  
  13. The Colosseum. Tells the history of the famous Roman amphitheater. The most interesting part is how little we know of what actually happened in the Colosseum. Not many sources exists, so movies have taken a lot of creative freedom. 
  14. Babylon's Ark: The Incredible Wartime Rescue of the Baghdad Zoo. Tells the story of what happened to the Zoo in central Baghdad after the 2003 Iraq war. 
  15. When Thunder Rolled: An F-105 Pilot over North Vietnam
  16. Worm: The First Digital World War. Tells the story of the Conficker computer worm which was a virus people thought would cause the end of Internet.
  17. We Bought a Zoo: The Amazing True Story of a Young Family, a Broken Down Zoo, and the 200 Wild Animals That Change Their Lives Forever. With the longest sub-title ever there's no need for further descriptions.
  18. Circle the wagons - The history of US Army convoy security. Is available for free. 
  19. Nine Lives: My time as the MI6's top spy inside al-Qaeda
  20. Humble Pi: A Comedy of Maths Errors. Consists of several examples of where minor mathematical errors have resulted in big consequences. For example, ground crew confused the units of measurement when they put fuel in an aircraft, so the aircraft ran out of fuel and almost crashed (the fuel gauges were also broken). 
  21. Surely You're Joking, Mr. Feynman!: Adventures of a Curious Character. A book about the Nobel Prize winner Richard Feynman (spoiler: he didn't want the prize). 
  22. Permanent Record. Biography on Edward Snowden.
  23. Unity 2017 Game Optimization - Second Edition: Optimize all aspects of Unity performance

Books in Swedish
  1. Det bevingade verket. Tells the history of the Swedish Air Force. 
  2. Med invasionen i sikte. Tells the history of the Swedish Air Force 1958-1966, and how a war with the Soviet Union would have happened. 
  3. ÖB:s klubba - Flygvapnets attackeskader under kalla kriget. Tells the story of the ground attack part of the Swedish Air Force during the Cold War. 
  4. System 37 Viggen. Consists of shorter stories written by people who were involved with the Viggen project, which was a Swedish military aircraft. 
  5. Svenska hackare. Gives you an overview of who has been hacking what with a focus on Sweden.
  6. Poltava. Tells the story of a famous battle between Sweden and Russia in the 18th century. 
  7. På spaning efter det okända - Bilder från kalla krigets ubåtsjakt. Each chapter is written by someone who was involved in the 80's anti-submarine hunts in Sweden. 
  8. Ubåtsfrågan 1981-1994. The Swedish government set up a total of three groups with the task of analyzing the assumed underwater violations of Swedish waters that have been going on mainly in the 80's. This is the second group's report. 

October 21, 2019

Adventures making stylized vehicles

After making three stylized characters in Blender I needed to do something else. So why not learn hard-surface modelling and texture painting while making some stylized vehicles? The first vehicle is a US coast guard helicopter model MH-60:

The reason I decided to make this exact helicopter was that I had an old non-stylized model of it collecting dust in a folder, so I might as well use it and improve it. What I also wanted to learn was to add decals to a model. Decals are those logotypes and text and there are several ways to add them. When making games I think the best way is to paint them on top of the base texture by using Blender's stencil function. What you do is you have the texture with a transparent background and then you just paint it where it should be and Blender is figuring out how to add it on top of the base texture. The problem I discovered is that the texture resolution has to be high or the logo and text will become pixelated meaning that you can see the pixels and can't read the text. The helicopter's texture is 2048x2048, but because I realized this was a problem after painting the base texture, and I didn't want to redo it all, I had to cheat by using a 4096x4096 texture on top of the base texture or the logotypes would be visible. This is something I wanted to improve when making the next model.

I also decided to experiment with low-polygon characters with lower polygons than I had previously used. The stylized characters I experimented with before are still low-polygon but they take several days to make because you have to make a high-polygon version and then a low-polygon version, which is a process I talked about in a previous article: How to make a stylized game character in Blender. A single of these lower-low-polygon characters takes less than a day and I think the result is still good if you are not looking at them very close:

Next vehicle I made was a Visby corvette belonging to the Swedish navy:

As said before I wanted to fit everything into a 2048x2048 texture and the easiest way to do that is to have as few UV islands as possible. This is the texture and you can see I managed to paint the logotypes and text on top of the base colors. The result is still kinda pixelated if you look really close, so I might have to experiment more to get a better result:

I wanted to put the Visby corvette in a scene, so I also made the underwater robot rov called "Double Eagle." It belongs to the Visby corvette and they lift it out with a crane to look for underwater objects such as mines:

The final scene is a half below water and half above water. To make the light shining through the water volume I had to experiment with volumetrics, which is really slow to experiment with. The reason is that volumetrics is really slow to render so if you make a small change you have to wait really long before you can see the result of that change. But after a few hours I think the result is good:

If you want to see more images, I've uploaded them to my Artstation account:

September 3, 2019

Book review: Babylon's Ark

I clearly remember the 2003 Iraq War. The reason is that I did my military service at the same time as when US invaded Iraq and there was chatter that the Swedish army would extend the length of our military service because of a higher security risk. Now Sweden is far away from Iraq, so perhaps someone thought that Russia would use the opportunity when many US forces were in Iraq to cause trouble in Europe. Luckily, that didn't happen and the invasion of Iraq ended after a few weeks. But people would for many years still be dying in Iraq because not everyone thought the war had ended.

Fast forward a few years to when I was listening to a radio show where Malik Bendjelloul, a Swedish documentary maker, talked about his life. You can read a translation of it in English here. In it, he talked about how he wanted to make a documentary about Lawrence Anthony, a South African who was working with elephants.
"Lawrence had for the past few years tried to help a group of ferocious elephants, elephants that had destroyed surrounding villages and would now be put to death if no one embraced them. So for the past few years, he had for months hanged out with these elephants. And it led to that his entire way of looking at life on our planet had changed. The more time he spent with the elephants, the more he experienced his own inferiority. The human brain may be developed, but all of our other senses are embarrassingly undeveloped: our hearing, our sight, our touch. Researchers have still not understood how, but everything indicates that elephant senses function in a way that sounds like science fiction. For example, one has begun to understand that elephants can communicate with each other over incomprehensible large distances. Maybe over entire continents. Lawrence argued that he occasionally felt this communication. It had felt like the elephants had tried to communicate with him. He didn't want to talk much about it - in part because it was difficult to put it into words, in part because he understood it sounded a bit too much new age fuzzy. I returned to Sweden and thought it existed material for a good story."
But Malik Bendjelloul was also talking about one of Lawrence Anthony's other adventure: when he, just a few days after the 2003 invasion of Iraq had ended, traveled to the capital of Iraq, Baghdad, to help the animals at the zoo. I was really happy when I realized that he had written a book about it before he passed away in 2012. It's called Babylon's Ark: The Incredible Wartime Rescue of the Baghdad Zoo, and it's the best book I've read so far this year. There are some clips available on YouTube, but you should also read the book.

Not only did he rescue many of the animals at the Baghdad Zoo, but also other animals across Baghdad. Lawrence Anthony realized that another zoo existed in Baghdad, and it was called Luna Park. It was in terrible shape, so he decided to move the animals to the main Baghdad Zoo:

Saddam Hussein, the former leader of Iraq, collected horses, and they also needed to be rescued. During the war, the horses disappeared because they were very valuable, but Lawrence Anthony and his team managed to find them and bring some of them to the zoo:

So if you want to read a feel-good book that I rated 5/5 stars on Goodreads you should read Babylon's Ark.

August 15, 2019

Disco Elf Corel - or how to make a stylized character

I finished my second ever character for games: a disco elf called Corel. Like my last character, butterfly woman Madeliefje, I made it to participate in a draw-this-in-your-style challenge organized by Poopikat, and I also wanted to learn Blender 2.8. This is the original concept by Poopikat:

According to Poopikat's description, Corel "has darker skin, Glow tattoos and white-ish blue hair with two big bows. I'd like to think of her as a water/snow elf if that makes any sense." I thought it would be cool to make them glowing tattoos, so I decided to make a 3d version of her in Blender. I also wanted to improve what I thought wasn't good about my last character.

Improvement 1: Face. So I started with the old character. Most 3d artists use a basic character and change it to make it look more like the character they want to make because most human-looking characters have similar body shapes. Step one was to improve the face. I first changed her jaw bone to make a sharper jaw and I also changed her eyes. What I learned was that very small changes can change the look of a face. If you look in a mirror and then open your eyes slightly and stare at yourself, you only have to raise your eye-brows a few millimeters to go from just a "looking" face to a "staring" face. To improve this character I made the distance between the eye-lids and the eye-brows smaller to make a more concerned face like in the original concept. I also remade the size of the lips and I gave her an open mouth where you can see her teeth. The teeth are just a flat white surface because they are almost not visible anyway.

Improvement 2: Body. Madeliefje's body looked like a human body, but I wanted Corel's body to be more stylized. One artist I get inspiration from is Carlos Ortega Elizalde, who's making characters with a slim body and large head. I think they look really cool. So I changed Corel's body to be smaller while increasing her head size.

Improvement 3: Rig. To make a 3d character move around you need to "rig" it by adding bones like a human has. Some people have this as a job, so it's not something you learn in an afternoon. I'm using Blender and a free add-on to Blender is Rigify which will generate a rig for you. I used a simple rig to animate Madeliefje and I realized I couldn't pose her the way I wanted because I couldn't rotate her hands. It takes some time to learn Rigify and you have to tweak the generated rig to make it fit your character, but because all human-looking characters move in the same way, Rigify will help you a lot once you learned it.

What I want to improve when making the next character.
  • Hair. Making hair for game characters is not easy - there's a reason most game characters have short hair or a ponytail. The reason is that big hair will demand many triangles, making the game slower and it's also difficult to animate a big hair. Corel's hair consists of many hair pieces you have to add one-by-one and the result is that you end up with a "stripy" hair and many triangles belonging to the hair pieces are hidden, so it's a waste of triangles. I've seen some characters where the hair is just one big mesh, so I might try to make that type of hair next time. 
  • Cloth creases. Corel is wearing a body-suit and to make it look more like cloth you have to sculpt creases. I think they were too small and you can't barely see them in the final model, so I will make them bigger next time.
  • Normal map. To make smaller details on a less detailed mesh, you need a normal map. The normal map belonging to Madeliefje was so bad I had to remove it, but Corel has a normal map. This normal map generated some weird edges and I think the reason is that Corel is too low-poly, so next time I will add a few more triangles, especially around the legs.      

These are the final poses, with some inspiration from a disco movie with John Travolta. I added the smoke as a post-processing effect in Krita:

If you want to vote for her you can find her on Artstation.