Planet Earth Shader

Unity - Earth.unity - ShaderLab - PC, Mac & Linux Standalone_2013-06-22_10-06-06

What’s up guys?!?! Did you enjoy playing BlackTie? Right now I’m working in another casino/dice game and in the meantime I’m studying shaders in Unity3D. By the way, there are some awesome tutorials from Mike of Prime31 and Kenneth Lammers from CreativeTD here and here. After watching it all, I decided to code on my own and make the “teapot” (hello world) of the shader universe: the Earth! Long time ago I made this shader using Strumpy Shader Editor but the code generated is not pretty, so I decided to do it 100% in code this time. What a good challenge to start with. The final shader is actually easy to understand but the thinking invested to get good results is far from trivial. The shader features:

  • Rim based atmosphere with 2 colors (inner and outer atmosphere);
  • Clouds with UV pan, ParallaxOffset;
  • Night lights using the Emission channel;
  • Gloss mask affected by the clouds;

I’m still planning to work more on this and make a custom lightning model so the night lights will only be visible at the dark side and I’m also thinking about making a real layer of atmosphere with another shader pass.

Update: The shader is now live on the Asset Store. You can get it here.

DicePlus DevKit – First Impressions

Here it is! The revolutionary electronic die DICE+. The die is a wireless controller meant to link physical world of board games with the digital one. It communicates via Bluetooth and it features:

  • Accelerometer with the magnetic field sensor that gives you a Full 3D orientation,
  • Bluetooth 2.1 and 4.0,
  • 6 independent touch sensitive faces,
  • 6 independent LEDs that can glow in any color,
  • a battery that gives you up to 20h of game play,
  • a microUSB for easy charing,
  • and a thermometer.

Ok.. enough marketing. Let’s see how to use it.

Unity3D

Game Technologies provides iOS and Android SDKs as well an Unity3D wrapper. Two demo projects available here. Let’s take a look at the Unity3D wrapper. There are two main prefabs there: the DicePlusConnector and the DicePlusHandler. The connector handles native calls and the Handler is just a demo prefab to show how the connection is done and it also offers a standard UI interface for connection.

There are two main interfaces you will have to implement to make the link with the die: IDicePlusConnectorListener and IDicePlusListener. Using the DicePlusConnector you can register a script to receive the events. The IDicePlusConnectorListener handles the connection itself. You will receive messages when the die is connected, disconnected and so on. When you get a connection, you can subscribe for one of the sensors in the die and IDicePlusListener have all the methods to read the sensors values. Further documentation is available here.

Once I started writing this post, the version was 1.0 and there’s a fresh 1.1 update already. In 1.0 there was a lot of reference errors in the .unitypackage. They are all gone now. I just had some trouble to add the DicePlus.framework to the project. The package sent is not structured in the way Xcode likes it. I had to move the Header folder and the DicePlus compiled file to the root of the .framework folder to get it to work.

The Bad

Well.. the battery is said to give 20h of gameplay and 3 months of standby. The die I got here won’t last a day on standby. To get a full charge, it takes a couple hours to do the job. I don’t know if this is a problem with the devkit or it’s just my die. The microUSB port used to recharge it is also an issue by itself. Lifting the face to reveal it is REALLY hard and can damage the die just trying to get it opened. I saw on Engadget that an induction charging version is also in the works. This would be great! Bluetooth is also another issue. The connection between the die and an iPad or iPhone is not that good. It takes quite a while to establish a connection and start using the DicePlus. Sometimes the connection is refused by the die and I have to wait for it to sleep to try again.

Waking up the die is also not an easy task. It’s said that you just have to shake to wake it up. It’s not said although that your shake have to almost break it. Sometimes I have to hit it hard on a table. Sometimes it won’t wake up at all. I have to plug the cable to bring it to life again.

Conclusion

Let’s not forget that this is a DevKit. The consumer version will be released at Gamescon in August. The DicePlus is an interesting controller to be used. Not just to be used as a die. Packed with accelerometer and magnetometer, it’s a “Wii MotionPlus” controller in the palm of your hand. A lot of game genres can benefit from that.

Testing Lightmapping Extended

Today in the Unity 3D Developers group in Facebook(https://www.facebook.com/groups/482495201782206/) I heard about an extension to configure the Beast XML inside Unity called Lightmapping Extended (https://www.assetstore.unity3d.com/#/content/6071) so I decided to give it a try in a very simple scene. Within 3 minutes I’ve already achieved some pretty good results! This is before and after:

UnityLightmappingExtendedTest

Look at the glass! The carpet bounce in the dice looks better before although… so I need to tweak it a little bit.

Augmented reality in 3D Fun N’Goals

    After playing with augmented reality for flash, I acquired some experience with the technology. Back in January of 2012 I was asked if it was possible to run an augmented reality game on a mobile device. I was skeptical back then, since my experience in flash showed that the image processing was very CPU intensive and could be impossible with the current mobile chips. For my surprise, Qualcomm already had a Unity3D plugin for iOS, that later on became to be known as Vuforia. I did some tests and voilà! it was running really smooth on my iPhone 4. The project sudden became viable in a matter of hours! Kudos for Qualcomm! Amazing lib.

 

We already knew that the game was going to be soccer related, but everything else was undefined. The first challenge was: how the user is going to use augmented reality in a soccer game? We had two scenarios:

  1. The image marker would be parallel to the ground, the most common use for AR apps;
  2. The image marker would be perpendicular to the ground;

After a couple tests we decided to choose the latter approach since the game was focusing in a penalties-like interaction rather than a full-sized field game. The idea was to place the marker just behind the goal, so the user could easily position the camera in the best angle.

The first marker version was just a promo image of the game with logos and some game images. We then realized that was awkward to try adjust the camera when you have no idea where the marker is inside the virtual world shown by the iPhone.  A good idea rapidly emerged: We could use part of the stadium as the marker image itself. This idea allowed the marker to exist in both worlds, perfect!

After some iterations, the image marker became this:

Image marker for 3D Fun n'Goals

Image marker for 3D Fun n’Goals

As I said, it demanded some iterations to reach the “5-star augmentable” rating for the image. This rating is provided by the Target Manager system in the Vuforia Developer portal. This rating is based on the number of “features” of the image. A feature is defined as a sharp, spiked, chiseled detail in the image. More about features can be found here. The analyzed output of our image marker is this:

All the features in the marker.

All the features in the marker.

Pretty good amount of features. Those iterations proved to be really important for stability since lower rating images would cause some flickering in the virtual world.

The image marker inside the game:

Print screen directly from Unity3D

Print screen directly from Unity3D

I’ll write more about the other aspects of the game in future posts. Meanwhile, please try the game and tell me what you think, it’s free!

If you had experiences with augmented reality, please share in the comments 😉

AppStore Link

Super easy sprite sheet animation in Unity3D

I have created a simple script that takes a squared width/height sprite sheet and generates a material animation. The source is here

  • Add the sprite sheet texture to a new material;
  • Add the SpriteSheet script to the game object (an Animation component will be automatically added);
  • Configure the parameters of the script: You need to specify the amount of rows and columns of the sprite sheet texture;
  • If you have blank frames in the end, specify the amount in the Missing Frames parameter;
  • You can change the FPS of the animation or how the animation will be wrapped;
  • Right-click in the Sprite Sheet component and hit “Build”;

An animation will be created and bang… it’s done 😉

Carnaval

Super-duper ultra fast app project I developed to celebrate Brazilian Carnival in 2012.

App description:

“Feel the groove of the Brazilian Carnival in your iPhone. Gather some friends, pick your favorite instrument and go for it. It is really easy, and lots of fun. All you have to do is shake your iPhone or tap the screen to enjoy the rhythm of samba.

Pick from the authentic surdo, pandeiro, chocalho or agogo and go nuts! ”

Promo video:

The app is available at iOS at:

Official app page can be found here.

Crazy Bitsy Spider / Amazing Spider Attack

This project I started working in 2011 and finished in early 2012. I worked as lead programmer developing most core features of the game and all game mechanics.

The main challenge in this project was the dynamic path finding algorithm of the spider. It was developed before the Unity3D announce path find support so it took a while to get things working as expected.

The game is available for iOS and Android:

 

Amazing Spider Attack: