Flammable Penguins Blog The internet home of Claire Blackshaw

15May/100

Distractions

So climbing into bed last night I got a great idea.

Debug the Light ViewProjection matrix by using a camera with the same matrix. Well you know how I managed to knock together that skybox so quickly. Well I dug into it…. YIKES.

I managed to get the sky shader down from 64 instructions to 27 instructions, and remove 4 branches. Sadly the sun doesn’t look great. On the bright side the Sky Sphere now respects it’s World Transform. Light amount now tied into horizon. Removed that horrible change line. Lost the tinting.

So this is what happened…

Oh wait I can clean up those 2 lines quickly… later… Hmm this could be improved… later… wasn’t I meant to be coding something?

Yeah so now after all that fiddling, I’m now working on the shadows again.

Tagged as: No Comments
14May/100

Almost

Full Screen shadows almost done. Had to run. Just caught last bus home. Some weird filming on the lot.

More tomorrow.

12May/100

Shadows and Reworks




Shadows and Reworks

So after a lot of thought and planning yesterday I set about implementing soft shadows using shaders tonight.

Sadly this meant I needed to re-haul the entire scene manager and packer to support texture swapping, and effect management. I also had to write a big ass shader to do several things, and optimise.

That’s done, now all I need to do is add the Shadow Render pass and it all should work. I’m going to miss the last bus home, so I gotta run.

11May/100

Shadows & Light

Lights Camera & Action

Well lighting & shadows are a complex bag of trickery and maths.

Basic Lighting is simple. Take a book outside into the sun now rotate the bugger around and throw it. You will notice the amount of light on a surface can be measure as an angle between the light direction (from the sun) and the facing direction of the surface. A very cheap and easy calculation we love, called dot product.

Now shadows are more complex. Light as a physics based thing in reality is a crazy thing which drove Einstein insane. For instance do you know light is affected by gravity so it actually bends around objects forming a very distinctive halo effect. So not only is it a ray cast but it’s a particle/wave which is affected by gravity fields. They also split up and bounce all over the place.

Now in games we fake it, cause those calculations are really expensive, and most times we care more about whether a bullet hit a guys head.

Bake It

A cheap and simply trick is to back the shadows. This works well if the lights & geometry don’t move much. Even in AAA games with more advanced systems, baked light maps do a lot of the heavy lifting.

To bake it we basically do the calculation before the game runs. The simplest form is a flat planar map, some bake a projection map and some cases even bake shadow volumes. We can animate the baked textures and get some awesome effects.

Fake It

Okay so we have this bad guy, race car or some other object in the world. Well we can forgive a lot with our suspension of disbelief. What if we glued a “blob” shadow to the feet of bad guys or race car.

You would be amazed how many games use this system to optimise thing and it looks great.

Flatten It

Well if we simplify light and ignore the bending, bouncing, and craziness of it, then we can treat it as a straight line from the light. Now we like planes, planes are really nice simple flat things.

Okay so now we have this thing called the projection matrix which is part of the matrix of projecting a 3D object into a 2D image. Well if we use the same trick we can clone an object, then squish it into a projection and render it all black. We have a shadow, Peter Pan Style.

Deferred Volume

Okay well know in reality we need to drop shadows onto complex geometries. Now we also have this wonderful shader pipeline. Before we render the scene we render the entire world from the perspective of the light (as we would the camera). We then grab the depth buffer and save it. 

This needs to be done once for each light.

Now this makes an image of how far the beam of light travels. Which we pass in to the next render pass, along with light matrix. Now if we take a point in space transform it by the Model-View-Projection as normal. Also Transform is by Model-Light-Projection. Then we compare the MLP read-out against the baked texture we can tell if the light reaches that point or not.

Another way of doing Volume Shadows is to use Stencil Buffers, this is the traditional way to do things and how most shadow volumes have been done in the last 10 years.

10May/100

Day & Night Cycle



Day & Night Cycle

Woot! Not only did I get a pretty awesome Sky-Sphere in place but I also managed to knock up a day/night cycle. I also cleaned up the shaders and have global lighting in place.

Found an awesome tut, and manage to knock the shader up from that.

Next thing is to look at shadows, but don’t you think that is preeety. :P

9May/100

Coupling Issue solved with Interface



Ye gods captain, PROGRESS.

After the dismal run around the pointlessness I have actually made some progress last night and today.

  • Coupling Issue solved with Interface
  • Island has day/night cycle
  • Shop Blimp interior & exterior modelled
  • Blimp added to world
  • Add a reliable help to translate between tile and world space
  • Started work on Sky Box

Coupling Issue

Okay so we don’t want the model (island & prop data) coupled to the view (scene graph, animations, models). Well the solution was to give every node in the scene graph a user data element which had an interface.

The core functions being, Update & Pre-Render. Further functions and event handles can be added to the interface to handle animations and the like. The interface is the façade which prevents tight coupling. Neat and clean, kicking myself for not seeing this solution weeks ago.

Sky Box

My reason for posting, indirectly. I waster the last hour or so trying to generate normal & height maps for clouds. Reading up on things I already knew how todo if I stopped and thought for a second. The moment I saw my folly I stopped to write this to break me out of it.

I will now grab some food then hopefully not be stupid.

Tagged as: No Comments
7May/100

Progress and Elections

So no progress yesterday as it took me forever to vote, and then I got lost in endless election cover and got no sleep, zombied through work today.

Anyway got back and looking mostly at setting up the menu and gui system for buying and setting up stuff. Some nice progress but no pretty pictures yet.

I was hoping to have pictures tonight but lost so much sleep need to catch an early night. Pretty UI tomorrow.

Tagged as: No Comments
5May/100

Island Scale



Island Scale

Staying late at work to do university work is REALLY awesome, and so works. My work setup is just so much better for coding.

  • Pro vs Express 
  • Two Screens desktop vs Laptop
  • Work vs Bedroom

Anyway, getting the island render stuff in. Sadly I need to catch a bus home but I’m hoping to crack on with purchase & place items.

Tagged as: No Comments
4May/100

Hack our way through the Jungle

Output Log

Created World[Game World]
Building Basic Prop [Template]
Frank.Island.WorldProp
Building Basic Prop [Building Template]
Frank.Island.Building
Building Container Prop [Container Template]
Frank.Island.Container
Building Inventory Prop [Inventory Template]
Frank.Island.Inventory
Building Ingediant Inventory Prop [Ingrediant Template]
Frank.Island.Ingrediant
Building Tool Inventory Prop [Tool Template]
Frank.Island.Tool
Building Food Inventory Prop [Food Template]
Frank.Island.Food
Added Obj[Island] to World[Game World]
Added Obj[Hand] to World[Game World]
Added Obj[HandCam] to World[Game World]

It might not look like much but that little but of text output proves the hacked type system works. It’s horrible, sadly I’ve wasted a weekend trying to do things the “correct way” and failing.

If I have time I want to investigate alternatives

// Horrible HORRIBLE System!!!
// Possibly replace if time permits, or else gourge out my eyes in shame
// Game Gems 1: Magic of Data-Driven Design by Steve Rabin
// Game Gems 2: A Game Entity Factory by F D Laramee
//
// Reflection and C# System.Activator.CreateInstance(…)
// See: http://forums.xna.com/forums/t/39891.aspx

Ah well it works and I have a meeting with my supervisor. Hopefully by tonight I will have that Tree & Oven in game.

Tagged as: No Comments
4May/100

Still not happy with my progress

Hitting a massive break trying to get Model-View-Controller to work with Data Driven model.

I’ve found out some nice stuff about C# activator but it gets messy.

Ultimately I think I’m going to have to through a few engineering scruples out the window and hack it if I want to stay on track. Which is IMMENSELY frustrating. Going to sleep on it and see how I feel in the morning.

Data Driven Objects

I’ve come up against this problem in MANY projects and to be honest never found a solution I’ve liked. The problem is you don’t want to hand-code each unit and ability ect… you want it to be data driven but this is quite a task.

Some of my biggest personal projects have ultimately died/failed due to this issue. Including my South African final uni project, my big Descent clone and my X-Com style game, oh and that hacking game. I REALLY need to find a good solution to this.

Sadly I’ve never attacked this problem in a work environment. All the articles I’ve read on it are vague or focus on a tiny part of the problem. I think I might need to look at the game gems books, and do some more research. I hate how much time I’ve lost on this issue which I’ve seen so many times before.

Tagged as: No Comments