The Medium is the Message 50¢ Contact
 

House of Shadows: Tech Demo 2

Adobe FlashA few months ago I posted a Flash movie demonstrating real-time interactive shadows in Flash. Quite a few people responded. Some offered suggestions for how to make it better. This summer I found some time to integrate some of their suggestions, along with finding other ways to improve the system. Today I’d like to show you the new, improved system. You can play with it below.

Get Adobe Flash player

The new system is far more capable than the old one. The main difference is a much improved approach to distance attenuation. In the first system, a light either lit a pixel or didn’t light it. Attenuation (the effect of a light fading to black with distance) was mimicked using a black glow effect that spread inward from the edges of the light. In the new system attenuation works correctly. This is the main reason for the visual improvement that you see.

Colored lights now work correctly too. In the old system, light color was achieved by adding a color value on top of the base texel color (the color of the fully lit floor textures). This led to a vague effect that washed out the underlying textures more and more as stronger light colors were added. In the new system, the light’s color is modulated into the texel color at each pixel. This is as “correct” as it gets short of an HDR system.

Lights now feature glow effects—not the “black glow” of the old system, but an additive glow that is tunable on a per-light basis. The lightning flashes that come in through the windows at the bottom of the screen have a lot of glow. You can see this better (and it looks pretty cool) by clicking the Flash movie then pressing Shift+3 (to grab one of the lightning sources), then ‘N’ (to stop the lightning from flashing). Now hit ‘G’ a few times to toggle the glow effect on and off. You’ll see it makes a big difference, approaching something like bloom.

Finally, the system now supports ambient lighting. You see this demonstrated as a general flash over the whole scene every time the lightning flashes. It’s actually the slowest part of everything the system is doing, because Flash has to redraw the whole scene whenever the ambient value changes (otherwise Flash caches unchanged parts of the scene).

I wish I had more time to work on House of Shadows (the game for which this lighting system is being developed) but it continues to progress at a snail’s pace. I just have too many other things to do. But I can’t complain—that’s a good problem to have.

share:
  • Twitter
  • Facebook
  • MySpace
  • Reddit
  • Digg
  • StumbleUpon
  • del.icio.us
  • Google Bookmarks
  • Slashdot
  • Technorati
  • Yahoo! Buzz
This entry was posted in games, programming, technology. Bookmark the permalink. Post a comment or leave a trackback: Trackback URL.

5 Comments

  1. Posted October 21, 2009 at 8:59 am | Permalink

    Wow, I’m very impressed. The improvements in the system are remarkable. I look forward to seeing other tech demos as you progress.

    • Posted October 21, 2009 at 9:51 am | Permalink

      Thanks, stringy! I’m still planning on adding “spotlight” capability, limiting the cone angle and focusing the direction of a source. I might have a look at soft shadow edges, though I’m not feeling the need for that particularly. Otherwise, the game’s tech is essentially done. It’s the game itself that needs lovin’ now.

  2. Posted October 27, 2009 at 3:04 am | Permalink

    The spotlight cone thing is a good plan – it’s something I am also placing into my engine (the prototype of which is at http://sidelinegame.blogspot.com/2009/10/behind-veil.html ). I don’t think your system needs soft shadows at all as the attenuation semi-provides that anyway. Besides which, after toying with the idea of soft shadows I’ve realised they would be a real system hog.

    After checking out your calculation phase I can see that our engines use vastly different techniques. It’s cool to see an alternate approach – and I think your system allows for many more lights affecting a single object (mine slows down with a lot of lights, but it is designed to mostly have at most 2 light sources per area as the game is a side-scrolling platformer.

    • Posted October 27, 2009 at 7:47 am | Permalink

      I went over to your site and saw your lighting demo—it looks great! Interesting about the calculation phases—I hadn’t noticed that the techniques were different. From a performance standpoint, my system is generally bottlenecked by the number of blocking verts per light, but there’s no additional cost for having more than one light in the same area. So basically the cost is per-light rather than per blocker or per combination of lights.

      • Posted October 28, 2009 at 9:43 am | Permalink

        I suppose it is similar then, to a degree, in regards to limitation (multiple lights can sit on top of each other with little effect to frame rate, but if one object with 5 vertices is within the radius of each light, each light will calculate shadows per vertex – 5 * number of lights). The calculation phase in yours just seems much more structured (going by its presentation in the prototype) than mine.

        Thanks for taking a look. I’ll open source the code for my shadow engine some time (hopefully soon) once a few kinks are worked out.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>