Message Received And Understood
All my plans, I placed in a bag and tossed out the window for Tuesday. The feedback both internal and external was clear, which was to get those pesky shadows back in!
A sage thought, and the right one. I have plenty plans for more eye candy in our terrain but shadows are super critical to make the scene 'pop'. To that end, apart from dealing with delegation via emails, my focus today was all things shadowy.
More Than Normal
As you may know I have already maxed out my texture stage usage on the terrain shader, and I ain't using more than eight slots in this engine to ensure some level of backward compatibility with last years graphics cards. Mark, and now Rick are both insisting on normal maps for the terrain floor, and as they are technically shadow casters I decided to add them in. I achieve this by making the terrain a two pass process, or rather, a two render process. I can hear the intake of breath there, but there simply is no way to squeeze a veg map, five color textures, four cascade shadow map textures, multiple normal maps, one per texture style and who knows what else. The good news is that in theory the shader work simply gets split between the two passes, with only the geometry getting processed twice. This is where deferred steps in to improve performance, and this can still be an optimization for us, but I need to get it written first before I can start performance tests.
I used some placeholder normal maps, and the terrain has had it's nice textures and subtle colors replaced by a basic lighting system (used by Valve) which employs said normal maps. Once this was done, time for...
Shadow Games
I must have visited this shadow stuff about three times now, each time getting better and improving it. My finished shadow shader is now the best, with the ability to stretch all the way to the end of the terrain map and generate a convincing directional light.
The current prototype as I write this is in debug mode with each cascade tinted a specific color so I can see the quality step line and iron out any last minute artifacts like shadow edge bleeding and peter-panning. All looks good to be which means time to add it to the new terrain shader.
It's 2:40AM now so I could slink off to bed and restore a more normal working day for the remainder of the week, but who would integrate the shadows into the new terrain shader :)
Signing Off
I am going to fix myself a small J.D & Coke as a little reward for getting the super sized shadow issue sorted (finally), and then put another 25 minutes into the shadow integration, then see if I can rotate myself back onto the day shift. It's hard to say whether day or night shift produces more, and I've experienced plenty of both. I dare say it's 50/50 and entirely dependent on the devilishness of the code on that day.
Looks like my 25 minute stint, and my plans to reset for Wednesday just backfired. It's now 5:40AM and just finished. The good news is that I managed to get shadows integrated smoothly into the current 'dismantled' terrain shader and they're great fun. I created a few hundred rotating shapes hovering over the landscape and in response, hundreds of dynamic shadows cast their magic on the scene. Can't wait for Wednesday when I plan to blend the shadows into the lighting and see what I can do about the terrain casting dynamic shadows (expensive and redundant but I have to see what it looks like).
ReplyDeleteThat's the spirit Lee! :)
ReplyDeleteI hope your wages reflect your work rate,nice work lee.
ReplyDeleteThis is incredibly exciting! I really hope this is the grounding for a spotlight flashlight that can cast dynamic shadows from the scenery. Sounds like you've made an excellent start and I really appreciate your decision to focus on shadows rather than the other visual effects right now.
ReplyDeleteJust something to note that might be helpful, I read the other day that for dynamic shadow-casting from flashlights, Silent Hill 2 and 3 used a technique known as stencil shadows to allow such advanced graphics to even work on the limited PS2 hardware.