About | Rules and Guide | Sign In/Create Account | Write a Post
Construction1990’s Internet Montage? No!
Please excuse the site weirdness. Mike is fixing and making things.
Ludum Dare 31 — Coming December 5th-8th 2014!

  • ??? Begins: in 9 days, 11 hours, 53 minutes, 10 seconds
  • October Ends: in 10 days, 12 hours, 5 minutes, 10 seconds
  • Ludum Dare 31 begins: in 45 days, 12 hours, 53 minutes, 10 seconds
  • (FYI: Clock might be off) | Ludum Dare 31: Real World Gatherings (Now Open!)

    [ October Challenge 2014 | Resources | Submit/Edit | View All ]

    Lighting Asteroids

    Posted by (twitter: @PrePixel_)
    October 22nd, 2012 10:00 am

    I’m sure this sort of thing has been done in the past but I thought it was pretty cool. Matt suggested early on that we could add some atmosphere to the game by casting light from the ship onto the asteroids. In addition to adding some graphical flair, it could be used to make the game more challenging as distant obstacles would be harder to spot.

    I must admit I was initially resistant the idea. Given our limited time I wasn’t sure the extra work was worth the subtle effect it would have on the core game. Also – as any of you that have worked with Android surfaceview will know – there’s only so many pixels you can push to the screen before the framerate starts to take a nosedive. I’ll talk more on that in another post.

    After thinking about it for a bit, I decided to spend a little time developing a technique I was using for Badlands (working title!) that screened translucent bitmaps over a sprite to simulate light. Each sprite would be made up of a base layer with no obvious light source, plus four ‘light’ layers, each lit from a different side. Depending on the angle of the light source in relation to the sprite (this is a bit tricky as sprites can rotate), I overlay up to two of these layers on top of the base image – each faded depending on their relative angle. The gif below gives a rough idea of how it looks, it’s actually a lot smoother in-game.

    Admittedly, this technique wouldn’t always work (anything with large protrusions would probably look odd), but it works pretty well for our asteroids. It did lower the fps a bit, but I think the effect is worth the hit. I’m still looking into ways of doing this more efficiently – any ideas welcome!

    5 Responses to “Lighting Asteroids”

    1. Puzzlem00n says:

      Nice idea, probably a lot better for fps than real time light simulations and normal maps!

    2. 31eee384 says:

      Neat! Could we get a screenshot from in-game to see it in action? Interesting idea.

    3. Jedi says:

      Freakin’ brilliant! Thanks for sharing :)

    4. prepixel says:

      Thanks guys! We’re hoping to post a gameplay video soon, just need to sit down and film the thing. :P If not, there will probably be a trailer released near the end of the month. It’s hard to appreciate the effect in a static screenshot, but you can sort of see it in this one:


    5. nosfer says:

      this is brilliant, just think about possible uses in html5/canvas!

    Leave a Reply

    You must be logged in to post a comment.

    All posts, images, and comments are owned by their creators.

    [cache: storing page]