Monday, 20 October 2014

Automagical Exposure And Spherical Super Fudge

Today and tomorrow my schedule budgeted in the time to work on some kind of tone mapping and also the addition of skybox ambience. After some researches over the weekend and a little this morning, it turns out for true tone mapping I need implement a whole HDR system and for skybox ambience I might have to add an extra cube-map texture read to all pixels!  The upshot will be to improve the visuals still further by defeating the over-bright scenario we have been seeing and also to improve the general lighting of a scene full of differently textured objects.

A typical unlit scene - the starting point for all rendering

Alas I am not prepared to delay the project further by implementing a whole HDR system as it would require a lot of texture and shader updating, and adding texture referencing in my shaders is the last thing I want to do after making such good strides in performance. The solution was to achieve everything I wanted but without using the above techniques. As at 2:30PM I have achieved these goals, and am ahead of schedule by a day :)

The solution to the tone mapper was what I am calling my auto-magical exposure feature, which is very similar to adaptive bloom and acts on the post process shader to ensure a scene compensates for being over bright. Added some code to use the time delta from the engine and it now adjusts at the same speed as the human iris which creates a nice subtle effect.  Look at the sky and your eyes adjust, look at something dark and the eyes adjust again, look back at the sky quickly and notice how the eyes adjust over 1-2 seconds.  Very cool!


The second solution was to dump reading the skybox (even a small 1x1 per side version of it), and simply pre-scan the colour of the sky and the colour of the floor, and load those directly into the shader as a constant. I then use a spherical harmonics trick to work out the contributions based on the surface normal presto, the ambience now has the visual effect of receiving bounced light.  It's not sophisticated, but it's completely free and super fast!

Notice how the ambience is taken from the sky and terrain colour

When combined with the remaining pixel shader it blends with the scene

Next on my list is to read an avalanche of links Rick has sent me on spherical harmonics (as there might be a test tomorrow). Then I fix the Rocket-man, who has been doing very silly things with his rocket and needs sorting.  If I can do all that and have a build for 4PM then I think that would be a good first day of the week!  I am eager to get past the performance and visual stuff this week as there is a big chunk of third pillar functionality such as the material system I want to get my teeth into.

8 comments:

  1. This is all very exciting and good news, Lee! I am really anxious for the next release. :)

    I really enjoy reading these blogs.

    ReplyDelete
  2. Lee

    The graphics in the merged scene are a massive improvement so really good job on this. When combined with the pre baked shadows I think the overall visuals in Reloaded are going to be a huge step up in the next beta.

    I'm still a little worried about the lighting getting blown out on skyboxes and some surfaces but will wait to see how the tone mapping and improved adaptive bloom work out there.

    Great work. You have really improved a lot of things over the last few weeks.

    ReplyDelete
  3. I'm sceptical still. The floor is still fluorescent green. Do you have the norm and specs working in the scene?

    I will await the release but not sure what to expect

    ReplyDelete
  4. And what about a real sun position?

    ReplyDelete
  5. I was ever-so-slightly disappointed not to be getting full HDR (because I was fully aware it was necessary for tone mapping and assumed you were too), but I'm sure the adaptive bloom will be a good compromise and... FINALLY. The bounced lighting from the ground and the PARTICULARLY the skybox is AMAZING. This is what I've been saying for ages and ages, that the lighting in the scene MUST match the sky or it won't look realistic. Very happy with this addition!!

    ReplyDelete