Wednesday 24 July 2013

Wednesday Progress

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.

Signing Off

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 ;)

9 comments:

  1. Veg growth on textures... new water shader... this all sounds fantastic :)

    ReplyDelete
  2. I'd say, we should decide which objects should cast a dynamic shadow and which don't. This way we could turn on shadows on grass if the don't have much, or turn it off if we need to render more vegetation.

    Also please don't force rock textures on slopes! :) Maybe put a toggle on that, too?

    Other than that - very nice progress!

    ReplyDelete
  3. So the decisions Lee has made on the Reloaded renderer have turned out pretty well as far as I'm concerned and what we'll be able to do in the game with that.

    Dynamic shadows was a huge milestone for the project and that is going to set reloaded games apart from fpsc classic games from a graphics perspective.

    It would be useful to have some control over which objects cast and receive dynamic shadows. Also Lee still needs to confirm how this will be handled on indoor parts of the map. Am looking forward to seeing some nice dynamic shadows on entities and characters.

    The terrain is turning out really well and I can see this adding a lot of mileage to reloaded games. I never expected to see full on terrain editing tools in the editor.

    There is still a long ways to go with physics and AI but its really coming together at the moment. We also need a nice selection of post processing effects like bloom and depth of field.

    I hope Lee has a plan for AI because that will be a huge factor in the success of reloaded and will need to be very solid if not spectacular.

    ReplyDelete
  4. Although Rick does not agree, I believe AI is the most important aspect of the new engine (when you get over the 'sales picth eye candy' stuff). The AI pretty much defines what your players will be DOING for 97% of their time in your game.

    ReplyDelete
    Replies
    1. yes thats true. function& Grapic is important but gamelplay espesially AI is Important too.i agree alott :)

      Delete
  5. Great Post. i hope it slips true ;)
    i love to read the progress and it gives me currage to star dbpro and do stuff it alsoe gives im coding ides on hov to try a thing or two in a different aprotch(or what to call it)Norwegian+Dyselexia):)
    btw i do understand rick`s point of vew too. :)

    ReplyDelete
  6. Shitty AI and good graphics don't go well together. It also puts all the hard work on the artists to shame.

    When Dark AI came around it gave me new hope for FPSC as a game developer. I'd love to see us go further AI in the future.

    This really shouldn't be an engine for children. Considering the rating restriction is at 17+. Most people in this age-range don't mind getting their feet wet in a bit of code anyways.

    I feel you really understand us Lee, thanks for always being so open with us. Keep up the fantastic work! Cant wait to see... err I mean... cant wait to read what cool things you have for us next :D

    ReplyDelete
  7. I agree with everything said here so far.

    @sector49:

    I should think (well, at least I hope) the automatic terrain textures are optional and definable. That is, you should be able to easily create good-looking terrains quickly by allowing the textures to be added automatically, or, if you so desire, paint every splodge of grass by hand. Also, with the automatic texture-painting, it should be possible to define "Flat", "Slope", "Underwater" and "Random" textures (or something along those lines). So you could have it automatically add sky textures on slopes or pink rocks underwater if you wanted.

    ReplyDelete