Friday, March 15, 2013

Blurring The Line

This week, I've got some minor updates done. With midterms and projects across the board, it's been a pretty insane week, and not much progress has been made on the game visually. Behind the scenes, I've got some code-restructuring, and the beginnings of an enemy class. On the visual side of things, I've got a new game-play mechanic to show off!

While tweaking the time-trail algorithm, I realized that a particularly clever player could stand in a very bright area for an extended period of time to cast himself further into the future, then just skip throughout the level unnoticed by enemies while his past self slowly trudged through the layers of time. As I wondered about how to fix this, I realized that I had a couple of Gaussian blur shaders already implemented for when I was testing post-processing in my rendering engine. So I decided to test what it would be like if the player was faced with an increasing blur of the world around him as he traversed through time.

Here are a couple of screenshots showing the differences:
A small delay, ~1 second A much larger one, ~10 seconds

The idea is that the player will not be able to accurately see what's going on in the level as the blur increases, and thus will be deterred from traveling a large amount into the future.

Algorithm Details

For the time-trail algorithm, I created a method called CWorld::CalculateLightInfluence(). It, aptly named, calculates the sum of the three most-influential light sources. It used to rely on distance, but that only makes sense if all of the lights have the same attributes, so now the actual influence is calculated and compared for all of the lights. The calculation is as follows:

distance * 200.f / (Constant Attenuation + Linear Attenuation * distance + Quadratic Attenuation * distance2) * brightness

This is almost the same as the algorithm I use in my lighting shader, except it's done on a single light rather than every pixel of the entire screen, heh. I can easily tweak the 200.f constant if I want lights to have more or less of a cumulative influence. So, this value is summed, capped at a range of [0, 5), and returned to the world for further processing.

Back in CWorld::Update(), this value is then used to create time-trail instances. After this, the blurring algorithm is performed. It determines the total time between the current time and the time-trail active at the moment. This represents the amount of time ahead the player is. This value is divided by 10000, because the Gaussian Blur shader only works well with really small radius values. It's clamped to [0, 1/300]. The larger the value, the closer it is to the limit, and thus the blur increases!

I want to tweak this to be a progressive algorithm, rather than just a linear increase. In the near future, I'll make a spread-sheet and maybe apply a increase based on a stretched out x2 graph, like maybe x2/8


  1. Yοu really make it sееm so easy with your presentаtion but I finԁ thiѕ matter to bе really somethіng thаt I think I ωould neѵer
    undeгstаnd. Ӏt seеms tοо cοmρlicateԁ and extremelу bгoаd fοг
    me. I am looκing forωarԁ fοг youг nеxt pοѕt, I wіll try
    to get the hang of іt!

    Mу weblog:

    1. This is really the accumulation of several months of work, so don't worry, I wouldn't have understood this either until well after I started! Keep at it and you will get there as well. Also, this post was just a quick update for Screenshot Saturday, so it didn't have many serious details, unlike some of my other guide/tutorial posts.

  2. I dοn't know if it'ѕ just mе oг if everуоne else encounterіng problems with
    your blog. ӏt seems like some of the written text in your ρosts are running off thе
    ѕсrеen. Can somebοԁy else pleаse proviԁe feedbаcκ аnd lеt me know if this
    іѕ hapρenіng to them too?

    Τhis might be a problem with my internet
    bгoωsеr because I've had this happen previously. Thank you

    Also visit my blog post: Chemietoilette

    1. Hm, that's strange; I've never had anyone report layout problems before. What resolution is your screen, and what browser are you using?

  3. Have you ever thought about adding a little bit more than just your articles?

    I mean, what you say is valuable and everything.
    Nevertheless imagine if you added some great visuals or video clips to give your
    posts more, "pop"! Your content is excellent but with pics and videos,
    this website could certainly be one of the greatest in its niche.
    Great blog!

    Here is my web page ...

    1. This blog originally started out as more of a technical, stream-of-conciousness site for my random ideas, thought-processes, and guides to various issues I've trudged through during development. Now, with the more regular updates of my game, I will definitely be turning more toward a "show-case" style of screenshots and videos as more content is developed! Thanks for the suggestions and kind words :)

  4. Does your site have a contact page? I'm having problems locating it but, I'd like to shoot you an e-mail.

    I've got some creative ideas for your blog you might be interested in hearing. Either way, great website and I look forward to seeing it develop over time.

    Here is my page; online airplane games

    1. It didn't, but I just included some info in the "Welcome" section at the top :) Feel free to shoot me an email at

  5. Hello! Would you mind if I shаre yоur
    blog with mу fаcebook grouр? There's a lot of people that I think would really appreciate your content. Please let me know. Cheers

    Take a look at my web-site; -

  6. Ηello there! This iѕ my first comment here so Ӏ јust wanted to give a quick shоut out
    and say I genuinely enjoy reaԁing through your articles.
    Cаn you rеcommend any other blogѕ/ωеbsіtеs/forumѕ
    that сovег the same subjects? Тhank you so much!

    Check out my homepage; Chemietoilette