Terrain Takes A True Shape
An amazingly good day today, so much that it's one of those days you forgot what you had 24 hours prior to the very moment you think back. I started a new prototype to collect together the terrain painter and the terrain shader, so that I could have a relatively blank canvas to try my new technique ideas.
Thanks to the Blitzwerks Terrain upgrade, vertex normals now provide some great data to my newly concocted terrain shader which applied nicely without a fuss to the terrain geometry. I also got some super terrain textures from Mark and my shader experiments started right away. The trick is to get it looking good from the distance and from up close, which meant choosing the right textures, applying the right amount of scale, selecting a good detail map, balancing the effect of various lighting calculations and a good deal of trial and error. Finally I got something that looked pretty cool.
Being able to paint land and see it rise out of the water was a real treat, and I even applied a nice trick which automatically map rocky texture to the upward slopes of the terrain and sand on the flat bits. Coupled with the normal shading, the whole thing was quite addictive during testing and I found myself drawing all manner of terrain islands :)
Bringing Forth Mr Vegetable
I was going to add some really nice reflective/refractive water which I realised that my schedule did not call for water, but DID call for vegetation effects. I already have a water shader waiting in FPSC engine so the smart move was to avoid the easy eye fest and opt to solve the veg issue.
Thankfully I already had some preliminary desert vegetation and a rather nice shader from Mark, so was able to get started adding veg into the prototype quickly. For those who don't know, veg is my way of describing the grasses that rise out of the terrain to soften the hard surface of the floor and provide some nice decoration in what might be a rather barren landscape. Mark's shader also provided some soft movement and colour offsetting as the wind blows through the grass, very nice!
All well and good rendering some veg, but I needed enough to cover an area 50,000 x 50,000 units. What I needed was a routine to create rolling vegetation based on the players position. After a few hours, this was created by allocating 500x500 grid squares a single batch of veg polygons, calculated in real-time to be placed on the terrain. By spacing out when these objects are created, I can keep performance even. By fading them out at the far distance, I can introduce them slowly into the scene to make some great veg LOD. I then had the neat idea of creating a new texture 4096x4096 (the biggest I dare support for Reloaded) which stores what I call a 'veg shadow map' which uses the separate R,G,B channels for information to both the terrain and the veg shader.
Right now I have RED control the paint which is placed on the terrain where any veg is to be located. This is cool in that when the veg fades out, this colour remains to fool the user that distant patches of grass colour is grass, when in fact it's just painted to the terrain.
The GREEN is being used as a shadow mask, which allows me to darken any area of the terrain as a separate process. My hope is that I can coax the cascade shadow map to draw into this channel and provide a 'sort of baked' full universe shadow to apply to the terrain. I can also use the exact same texture and channel to shadow the grass in the exact same way and position, creating unity between the two shaders.
In developing the veg, I realised that the cascade shadow mapping would be too performance intensive to apply to everything, so the 'painted veg shadow map' will be my very nice looking fall-back. I also realised that terrain normals maps get lost in everything I am rendering to the floor right now, and also the fact I needed the texture slot for something else. Now I have removed the need for cascade shadow maps on the terrain, I have freed up four texture stages which means I could bring back normals, but I think I might opt for something better like more texture paint choices and use the extra channels of the veg shadow map to control which texture gets selected for terrain painting. Before these experiments can begin, I still need to add some 'editing' controls so I can paint the veg and shadows as part of the terrain modification system.
The Question Of Art
Looks like my Tuesday blog got quite a few comments there ;) Don't be too hard on Rick, he's doing the job he's been assigned for this project, and if my horrid screenshots are going to disrupt the marketing job he has to do later then a cease and desist order is probably the wisest course. It will be hard as I do like to gabble on as you know, but perhaps it will force me to insert better art in my prototypes just in case a screenshot happens to escape :)
Some good news is that I have a meeting on Monday morning, showing off the progress of the last two weeks terrain work. If the feedback from that meeting are positive, I will post some screenshots and maybe a video of the demo. It's internal name is called 'awesome demo', but that might be a tall order as I don't have the final graphics, no post process shaders, no real scene content and only a few days left to code it all.
A happy day all told. Even a 3PM appointment with the Dentist today did not dampen my spirits, and apart from the infernal heat, flies, moths and other creatures which insist on tupping me all evening, it's a day that deserves a tick. At some point I want to get the whole shabang into the IDE, but I think before this I need to complete the whole range of 'painting controls', find out how to burn the cascade shadow into the veg shadow map and orient and align the prototype and code so that it can drop smoothly into the main FPSC Reloaded engine without too many compiles.
More good news is that my weekend looks free of social engagements which means I can dedicate those days to more terrain work, which means I might find time to add some of that 'oh so tasty' eye candy you can only get from a lovely water shader ;)