Sunday Experiment - Moving Color Correction from Image Effect to the Shader

If you've seen any recent screenshots of When Pigs Fly (it'd be hard not to if you've visited this site), you may have noticed the colors in the game changing.  I've been using Unity's color correction image effect to bump up the saturation and slightly modify the green channel.  I think it looks good enough that I was willing to take the 5-10 fps hit that the image effect caused.  This morning I realized that I wasn't really using much of the power of color correction, so I set out to get the same effect in a simpler and hopefully less expensive way.

Sunday Experiment - Ragdoll Crashes

This morning I set out to test ragdolling the pig on crashes, but my first test crash was so disturbing that I may not continue.

Maybe if I add some more spring force to the joint and tighten up the limits a bit it won't be quite so gruesome.

Sunday Experiment - Messing with the Visuals

I'm going to be traveling on Sunday, so I'm going to count this post as my Sunday Experiment of the week.  As When Pigs Fly has grown, the visual quality has not grown along with it.  I like the low-poly style, but there are a bunch of areas where the graphics could be improved (mostly lighting related).  This morning I tried several different things to quickly improve the look of the game.

Depth Perception Issues

One thing that has plagued flight sims forever is a sense of depth.  It can be very difficult to gauge your altitude as you approach for landing.  The easiest way to accurately judge the approach is to watch the shadow of your aircraft.  The problem is that, depending on the light direction and camera position, the shadow isn't always visible.  The problem is exacerbated in When Pigs Fly by the low poly terrain, with no detail or texture on the ground there.

I thought shading the edges of the polygons in the terrain might help.  With a visible wireframe of the ground, the player could gauge altitude by the shape of the triangles.  I wasn't sure how it would look though, so I didn't want to spend a ton of time writing an edge detection or wireframe shader.  But since the terrain is procedurally generated and vertex colored, I was able to cheat and get the same effect with just six lines of code.  I changed the terrain generation code to make the uvs of each triangle of the mesh to be (0,0), (1,0), and (0,1).  I then modified the shader to mix a texture with the uv colors.  With a simple black outline of a triangle for a texture, here was the result.

This turned out great for how little effort it required, and the edge lines do help with a sense of depth on landing, but I just don't like the way it looks.  I'll still have to come up with another solution to the depth problem.

Color Correction

I've been fighting with the lighting in When Pigs Fly from the beginning.  I never found a way to have everything lit like I wanted while maintaining the warmth of the colors.  Now that Unity 5 has made all engine features free, I can use the color correction post effect.  There's still some tweaking to do with the color curves, but its already way better.



Shading and Shadows

Unity's shadow system doesn't work particularly well on the planes in When Pigs Fly.  With several objects so close together and sometimes overlapping, the shadows generally look horrible.  So this morning I disabled shadows on the planes themselves (they still cast shadows on other objects).  In my opinion, no shadows looks way better than bad shadows.

I also experimented with toon shading.  The first experiments were great, and I was about ready to move on to the next task, but I had been looking at stationary objects.  When I took a plane up and saw the toon shading in motion, there was an immediate problem.  The low-poly look results in some pretty big faces in the model, and when they're moving a lot the lighting tends to "snap" from one light level to another.  Here's what I mean.

After playing with the lighting ramp for quite a while, I think I've mostly solved this problem.  The gradients from one "step" to the next have to be gradual, and its a pretty fine balance between light "snapping" and not really being toon shaded.

The last thing I did was add the crease shading post effect.  It helps objects stand out, which is important because many objects in When Pigs Fly share the same colors.  It also just looks cool.


I think I made some great improvements in just a couple hours time.  The color correction has made the most drastic change.  There is still a lot to improve though.  The pig model needs to be redone pretty badly.  It also really bothers me to see distant trees without shadows.  I have some ideas on how to fix that last one, but I'll leave those to another post.

Sunday Experiment - Generating Procedural Roads

I'm a bit sick this morning, so this week's Sunday Experiment is a quicky. One of the things I want to improve in When Pigs Fly is the feeling of a live world around you.  The first step in that direction is adding towns and roads.  Also, as I start distributing more things to do around the map, its important to have some sort of system to guide players to those activities.  I think roads are a nice, subtle method of directing players to new areas.  For today's Sunday Experiment, I started laying the foundation for a system that generates roads procedurally, while still allowing me to control where certain roads end up.

Screenshot Saturday - Explosion Effects

Recently there have been a lot of people asking me to add weapons to When Pigs Fly.  There have also been just as many people asking me to not add weapons.  WPF was never intended as a combat game, but if thats how people want to play it, I don't want to stop them.  With that in mind, my current plan is to not add weapons directly, but to enable people to build weapons if they desire.  The first step in that direction is adding explosion effects.  For this week's Screenshot Saturday, I've got a bunch of fiery gifs showing the new explosions.  Click the read more link to check them out.

My first 24 hours with Unity 5

I've been anticipating the release of Unity 5 since I attended the Unite '14 conference in Seattle, but not for the same reasons as many people.  The most talked about new features in Unity 5 are the new physically based shading and lighting systems.  While those look great (that Blacksmith demo was gorgeous), they don't really apply to what I'm doing.  The update to PhysX 3.3, though, is of great interest to me.  So yesterday, about 5 minutes into the release announcement, I started the download.  Here's the story of my first 24 hours of upgrading When Pigs Fly to Unity 5.