Wednesday 12 June 2013

Wednesday In Shadow

Cloud Bound

I was planned a trip outside today but the clouds and rain conspired to keep me inside, and perhaps it was for the best.  I spent the morning reading up on various shadow mapping techniques as a refresher, then looked at some of the excellent world Evolved had done in DBP, and with a little rolling up of sleeves managed to create a prototype shader which employs cone based parallax rendering (thanks to Mark B) and shadow mapping (thanks to Evolved).  Here is an early video, which I sneaked past Rick, our QA guy:


As this is a first attempt there are some artefacts here and there, but I am happy that the technique is not too complicated to wrap my head around. I need my head clear for more challenges tasks that lie ahead.

Segment Art is hot on the heals of this coding work, so expect the video quality to jump up in the next few weeks :)

Evening Plan

It's late afternoon now and I'm quite buzzed at the prototype and just keep running it and wondering around. Once the buzz fades, my next task is to introduce an adaptation called Cascade Shadow Maps.  The premise is that instead of one all powerful texture holding the shadow for the entire world, I actually have four, with the first providing shadow for the entire world and the virtual camera sitting somewhere in orbit, while the forth shadow texture will be right up close to the centre of the player's head where we can produce much more detailed shadows that bears close scrutiny.  Of course all this produces a single global shadow, but it will be a great addition and absolutely necessary for outdoor scenes.

Brain Bursting Idea

In contemplating how best to handle point lights indoors, I hit upon a rather nice compromise which will allow hundreds of point lights but not drain the performance.  The performance drain comes from the fact that the typical omnidirectional shadow casting technique requires me to render outward from the light source in six different directions, every render cycle, to create dynamic shadows from a single point light. Multiply that by even a few lights and you are looking at screen shots, not refresh rates.

My plan is elegant in it's simplicity, which is to switch off the updates to these point light renders, but keep them in storage.  This way I can use the last known shadow render depth details when rendering the final lighting scene.  Only when an object passes by one side of the point light to I need to update, and only when the whole light moves do I need to update them all. Imagine them as real-time lightmapping textures that can instantly reflect changes in the scene, but when not updated are as fast as baked lights.  Neat or what!  Again, all theory, but will be a very cool way to solve the issue of many lights in a confined indoor scene that needs to cast many shadows.

For all the techniques I can research and dream up, it will always come down to performance and I am slowly coming to the concious conclusion that Reloaded should be targeted at next gen hardware. Gamers expect these advanced visual techniques, and who knows how long it will be before baked lights are a think of the past. Best to future proof Reloaded now while we're developing it, and leave that door open to lots of additional techniques that may rely on cube based shadow targets and deferred rendering methods.

Signing Off

It has been a day free of bugs, and much progress, so I could stop now and call today a roaring success.  Problem is, I am having too much fun, so with basic shadow mapping under my belt, time to try out a little cascading!

10 comments:

  1. As usual Lee you don't follow protocol. You are a Maverick! Nice work so far, don't you dare leave your chair until you havesomething better to show off. :-)

    ReplyDelete
  2. Question: Will we be limited to omnidirectional lighting for indoor scenes like in the current FPSC or will we also get the opportunity to use directional lighting for indoor scenes as well?

    ReplyDelete
  3. There are no plans for directional lights or spot lights as entities right now, but it's a good idea. Let's get more of the basics up and running and then we can look at this again. For now, just imagine point lights are like 'six' directional lights ;)

    ReplyDelete
  4. Spot lights are easy and fast, so they should be supported from the get-go.

    Even I, with my qualms about speed, am excited about the awesome new graphical prowess of FPSCR! And that idea you have is what Evolved uses to attempt to make his lights render quickly. The only problem is that his code has bugs in it and it doesn't actually work properly. So I am excited that you might write code yourself that works and makes all these lights render hyper-fast!

    Another thing....you said you would have to update ALL the lights when you move one....well you don't. You should (I think) only have to update lights that intersect the light you're moving: once where the light moved from and once where the light moved to.

    I am getting extremely excited about what I'll be able to achieve in FPSCR now! :D

    ReplyDelete
  5. This isn't just the best video we have seen for Reloaded so far but the best FPSC video we have seen period.

    If this is a small taste of what we can expect to see graphics wise in Reloaded then I will be dying to get my hands on a copy by December.

    Am also really glad that Lee is coming around to the idea of making the specifications required for Reloaded quite high. I will buy a new graphics card in a heartbeat if things continue like this.

    Finally we can start getting really excited about Reloaded and thats before the real artwork is even in place. This is awesome.

    More of this please...

    ReplyDelete
  6. Awesome work Lee. I know planning something as complex as Reloaded is difficult to accurately do, but I was wondering what target dates are there for this now. I know originally October was voiced, but with the new features and what not, my guess is this won't be really ready until March. Which is totally ok, but I just wondered what TGC's schedule says.

    ReplyDelete
  7. Hey Lee, great to see some progress on the visual side of things.
    As Clonkex already said, your idea how to render all the lights is exactly what Evolved tried to use in his Advanced Lighting. But I think with some planning involved and maybe written on a native level rather by using only DBP commands, the system might be a lot faster.

    What I wanted to say is, I'm looking forward to how things evolve in the next days. I hope you get the system running on a decent speed, but I have complete trust in this.
    Also a good idea to raise the hardware specs for reloaded, because we are still talking gaming and what most people are interested in, is great graphics combined with great story. So there is a big need for this.

    ReplyDelete
  8. You see Lee, it is all about flashy graphics! :-)

    ReplyDelete