A Long Day
So long in fact I think my body napped for 30 minutes at the keyboard between deep coding thoughts. Mostly a meeting day today, and it was a long one too, which means I talked a lot which means I was tired at the end of it. Once I got my second wind I returned to the world of physics coding. It's now 2:30AM which means this has been an 18 hour day give or take a meal or two, and I'm ready to turn in and post a quick blog.
A Meeting In A Pub
Mostly confidential stuff but some good ideas, initiatives and action plans came out of it, which will help strengthen the Reloaded project still further and provide some very exciting features for Christmas and beyond. The big result of course is that everyone liked the terrain module demo, and aside from some extra tweaks the potential of this new component was realized almost immediately. I will make some videos for Friday's blog so you can see what we saw today, and hopefully you will approve.
We also had an opportunity to play with the Oculus Rift device, and aside from certain members getting dizzy and almost throwing up in my office, the potential of this device was clear. Fear not, we are entirely focused on the essential features of Reloaded and will not be distracted too much with these amazing new toys!
The Physics
I was ready to call it an early day when I thought I would do half an hour of physics to make today count in the development arena. Well that was five hours ago. I now have the terrain collision working, nice and fast, and also have the character controller running around the terrain. I also threw in a few barrels at the top of the mountain and had fun following them down as they cascaded and bashed off each other, winding the way of least resistance down the slopes. Great fun!
I did have some hurdles, the main one being I could not use the built-in Bullet height map collision shape because Blitzwerks uses alternating quad edge patterns which means the physics does not respect the polygon arrangments. Although the objects follow the heights, they sink into the terrain in places which was not really what we wanted.
I solved it by using the static mesh shape, converting the terrain to a low LOD mesh and providing that. It remains to be seen whether I need to use the high resolution mesh for the physics mesh collision, but I am hoping I can get away with the lower resolution one for the collision map.
I am quickly running out of physics toys to add now, with DBP now having Bullet commands for spheres, boxes, cylinders and meshes both static and dynamic, full kinetic character controller and a very nice fast experience which is super solid (no small objects falling through the floor any more). I dare say the comments section will mention stuff like ragdoll, but I only need to do that when my character falls off something high, and we need to get him running before he can walk (off a cliff). I might invest some time in water buoyancy, certainly experiment will piling up crates to see how stable a simulation it is, and a scope test to create physics objects ALL OVER the 500x500 area and see if they are still there when I come back. I have a whole week to work on these bits so I am happy to report that Lee is on schedule (for once).
Signing Off
Just one more blog to wait and then you get some eye candy. Sorry for the delay but I hope you like what you see on Friday, and see the potential in the terrain editor and the kind of environments you can hope to see in your own games later this year.
All ideas expressed in this blog are temporal and any resemblance to manifested reality are purely co-incidental. The forgoing is a casual musing from a fellow coder, not an iron clad promise of features and products - The Law
Thursday, 1 August 2013
Wednesday, 31 July 2013
Wednesday When The Art Attacked
There I Was
Yes indeed, there I was, minding my own business when Mark submits an email of intense significance to the Reloaded project. He only went and re-wrote my shaders, and replaced my textures for the Terrain Demo. Music to my ears it was, and upon running the video he prepared and the new prototype in dropbox, I was not disappointed.
In the space of a few hours, Mark transformed my prototype into a drab unlit world into a scorching explosion of sharp contrast and infinite detail. He rescued a texture stage from my terrain shader and made the result look even better than it did before. Now that's talent ladies and gentlemen!
And Now A Visual
Oh, that's right, we're on a visual ban aren't we? :) Ah well, patience is a virtue, or so they say. That is, if you believe 'them', whoever they are.
Anyhoo, I can confirm it looks darn good and I have a video and a screenshot for the newsletter so all is well. Sorry for the visual black-out. I will try to convince Rick at the meeting on Thursday that SOME visuals would be okay for the blog, just not horrible ones that squarely belong in the programmers cassette box.
The Trouble With Physics
In fact, there is no trouble, whatsoever. The bullet physics wrapping is going very well, and resembles ODE in many ways in the way everything is set up, created, released, e.t.c.
I am currently toying with getting static terrain into a simple DBP prototype. I already have static and dynamic cubes and spheres, and thanks to a reminder from the blog comments section, I even have a dynamic cylinder! We never managed to get good cylinder physics in FPSC Classic, so their introduction in Reloaded will be a great plus. Always wanted to roll a barrel down some stairs, then strafe bullets at it half way down and have it explode amongst my enemies, who just that moment started up the stairs. It's the little things that make you smile!
No doubt, largely thanks to precious little examples on the subject, I will be working on static terrain for a while, but once I've overcome that I am onto Character Controllers and that's where it gets interesting for me. More on this later in the week, as I hope to cram some work in Thursday evening when the meeting is over.
Signing Off
It makes sense to make this one an early night which makes a shorter day than usual, but I can make up for it Friday I think. Hopefully Friday's blog will reveal something you can use, and push the boundaries of what we've been used to so far with FPSC.
A few more notes before I resume terrain physics fun, our AGK V2 Kickstarter is starting i's last 10 days run-down to get to that mythic 1000 pledger's. It's a good wholesome number to get to, and we're tantalizingly close. I recommend everyone pledge another £3 (or get their friend to do it) so we can push it over the edge and watch the wonderful splash when it hits the sea (sorry, my mind is still in terrain mode).
I also wanted to provide a link to a great write-up of the AGK V2 effort, in the form of a review of our Kickstarter from Gadget Girl. Great to see such enthusiasm, and a real kick to see the photos of the old products and the stack of TGC inspired books! Here is the link for your delectation: http://www.gadg etgirlreviews.c om/2013/07/app- game-kit-v2-cal ling-all-buddin g.html
Oh, and before I forget, the current AGK V2 total (with TGC Paypal pledges) comes to a rocketing £27,918 and an amazing 770 backers. Good luck to that project, and wish me luck with terrain physics. It should be straight-forward, but I don't have sufficient documentation for half of the required parameters, but that's life for a developer, right? ;)
Yes indeed, there I was, minding my own business when Mark submits an email of intense significance to the Reloaded project. He only went and re-wrote my shaders, and replaced my textures for the Terrain Demo. Music to my ears it was, and upon running the video he prepared and the new prototype in dropbox, I was not disappointed.
In the space of a few hours, Mark transformed my prototype into a drab unlit world into a scorching explosion of sharp contrast and infinite detail. He rescued a texture stage from my terrain shader and made the result look even better than it did before. Now that's talent ladies and gentlemen!
And Now A Visual
Oh, that's right, we're on a visual ban aren't we? :) Ah well, patience is a virtue, or so they say. That is, if you believe 'them', whoever they are.
Anyhoo, I can confirm it looks darn good and I have a video and a screenshot for the newsletter so all is well. Sorry for the visual black-out. I will try to convince Rick at the meeting on Thursday that SOME visuals would be okay for the blog, just not horrible ones that squarely belong in the programmers cassette box.
The Trouble With Physics
In fact, there is no trouble, whatsoever. The bullet physics wrapping is going very well, and resembles ODE in many ways in the way everything is set up, created, released, e.t.c.
I am currently toying with getting static terrain into a simple DBP prototype. I already have static and dynamic cubes and spheres, and thanks to a reminder from the blog comments section, I even have a dynamic cylinder! We never managed to get good cylinder physics in FPSC Classic, so their introduction in Reloaded will be a great plus. Always wanted to roll a barrel down some stairs, then strafe bullets at it half way down and have it explode amongst my enemies, who just that moment started up the stairs. It's the little things that make you smile!
No doubt, largely thanks to precious little examples on the subject, I will be working on static terrain for a while, but once I've overcome that I am onto Character Controllers and that's where it gets interesting for me. More on this later in the week, as I hope to cram some work in Thursday evening when the meeting is over.
Signing Off
It makes sense to make this one an early night which makes a shorter day than usual, but I can make up for it Friday I think. Hopefully Friday's blog will reveal something you can use, and push the boundaries of what we've been used to so far with FPSC.
A few more notes before I resume terrain physics fun, our AGK V2 Kickstarter is starting i's last 10 days run-down to get to that mythic 1000 pledger's. It's a good wholesome number to get to, and we're tantalizingly close. I recommend everyone pledge another £3 (or get their friend to do it) so we can push it over the edge and watch the wonderful splash when it hits the sea (sorry, my mind is still in terrain mode).
I also wanted to provide a link to a great write-up of the AGK V2 effort, in the form of a review of our Kickstarter from Gadget Girl. Great to see such enthusiasm, and a real kick to see the photos of the old products and the stack of TGC inspired books! Here is the link for your delectation: http://www.gadg
Oh, and before I forget, the current AGK V2 total (with TGC Paypal pledges) comes to a rocketing £27,918 and an amazing 770 backers. Good luck to that project, and wish me luck with terrain physics. It should be straight-forward, but I don't have sufficient documentation for half of the required parameters, but that's life for a developer, right? ;)
Tuesday, 30 July 2013
Tuesday Got Physical
Box, Meet Sphere
I have a sphere which falls to a static box and slowly rolls away. I know it was not the most ground breaking start to my physics system masterpiece but it's a start :) Most of the day in fact was spent re factoring the terrain prototype so it would integrate much more easily with the engine, which in real terms means an almost complete rewrite.
The data structures and subroutines had to be separated out, cleaned up and commented, the resources such as objects, images, shaders and cameras had to be accounted for and externally controllable (as it would integrate with an engine which already uses many DBP resource indices) and finally I had to move the files around and remove old ones, and place new ones in clever places for future proofing. Test the whole thing to make sure nothing got broke in the conversion too!
Finally, I moved the media files and the newly created source files to the main engine, in such a way that I can still load and compile the terrain prototype as a standalone, but the types and main module can now be used in the main engine compile as well.
I stopped short of integrating the IDE (that is, seeing the terrain in the map editor window and linking in the controls) as I had an appointment with physics I did not want to delay.
Integration Delay
It might be a mistake postponing integration in favor of starting the physics module but there are many more integration modules to come and it might make sense to do them all at once. The task is also quite involved and I should really treat it as a project in itself and give it the proper amount of time, not squeeze it in between modules.
I have done my re-factoring correctly, which is the main thing, and I can still compile and run the terrain module proto as a standalone which means the new art which Mark is burning overtime on can be tested and dropped in when they are ready.
Signing Off
As you may have read from yesterday's blog comments, it appears Rick discovered a secret version of the terrain module on dropbox I was using to work with Mark on the final terrain texture sets. Seems he liked it. You might think that means you get a screen shot but I rather like the idea of a big reveal through the newsletter and the Friday blog. Something to start your weekend with a little bang.
Who knows, maybe it will get better in the next few days and you do want some WOW factor out of this project right? I just hope I've not built the suspense too much, worst thing you can do that!
Wednesday's plan is a bit scatter gun, with some art integration's, more physics module work, new FPSC animated sprite pack to create an installer around, get rid of some office clutter so I can see the chairs again, create some GITHUB repositories and see if they all compile for me, prepare presentation notes for Thursday AM and who knows what else. All in all, pretty happy with today's run of work.
I have a sphere which falls to a static box and slowly rolls away. I know it was not the most ground breaking start to my physics system masterpiece but it's a start :) Most of the day in fact was spent re factoring the terrain prototype so it would integrate much more easily with the engine, which in real terms means an almost complete rewrite.
The data structures and subroutines had to be separated out, cleaned up and commented, the resources such as objects, images, shaders and cameras had to be accounted for and externally controllable (as it would integrate with an engine which already uses many DBP resource indices) and finally I had to move the files around and remove old ones, and place new ones in clever places for future proofing. Test the whole thing to make sure nothing got broke in the conversion too!
Finally, I moved the media files and the newly created source files to the main engine, in such a way that I can still load and compile the terrain prototype as a standalone, but the types and main module can now be used in the main engine compile as well.
I stopped short of integrating the IDE (that is, seeing the terrain in the map editor window and linking in the controls) as I had an appointment with physics I did not want to delay.
Integration Delay
It might be a mistake postponing integration in favor of starting the physics module but there are many more integration modules to come and it might make sense to do them all at once. The task is also quite involved and I should really treat it as a project in itself and give it the proper amount of time, not squeeze it in between modules.
I have done my re-factoring correctly, which is the main thing, and I can still compile and run the terrain module proto as a standalone which means the new art which Mark is burning overtime on can be tested and dropped in when they are ready.
Signing Off
As you may have read from yesterday's blog comments, it appears Rick discovered a secret version of the terrain module on dropbox I was using to work with Mark on the final terrain texture sets. Seems he liked it. You might think that means you get a screen shot but I rather like the idea of a big reveal through the newsletter and the Friday blog. Something to start your weekend with a little bang.
Who knows, maybe it will get better in the next few days and you do want some WOW factor out of this project right? I just hope I've not built the suspense too much, worst thing you can do that!
Wednesday's plan is a bit scatter gun, with some art integration's, more physics module work, new FPSC animated sprite pack to create an installer around, get rid of some office clutter so I can see the chairs again, create some GITHUB repositories and see if they all compile for me, prepare presentation notes for Thursday AM and who knows what else. All in all, pretty happy with today's run of work.
Monday, 29 July 2013
Monday Extra Time
More Terrain Time
Today I get a few more days terrain time thanks to a postponed meeting, which was really supposed to be day one of my Physics work. I just could not resist continuing to add the eye candy and get the demo 'just so' before moving too far off my present mark.
Monday I finished the water shader, water effects code and added a better sky box texture to give a high definition feel to the whole scene. I then must have spent two hours just moping about making terrain, cutting out little rivers, playing with my height and paint editing tools to see what kind of landscapes I could come up with. During my 'fun' my mind raced about more editing tools I could implement, more refinements to the shaders, optimizations that fit the way I did some things and a general need for more plants, rocks and bits of scenery detail.
I think the screen shot I have not is pretty darn good, but I am going to stick to Rick's guns and refrain from putting any 'suspicious' art out there :) Only a few more days to wait, and I think we will be using a 'terrain shot' for the next TGC newsletter so there will be no doubt you will see all this soon enough.
Details Details
It might seem adding water and new sky was a relatively trivial affair, but the very subtle code I added attempted to best some of the tricks done in high rolling games. Little things like a subtle fog effect, not to cull distant objects but to provide a misty sense of distance (and I mean VERY subtle).
Another trick. courtesy of Evolved, is to use a water mask texture to describe the edges of a lake or body of water. This ensures the water does not look strange when bumping up against solid geometry and is a great substitute for a depth read. I also had a few ideas where I could hijack the other channels of the water mask to describe depth, and use a nifty pixel shader calculation to shade the refraction map darker as the water gets deeper, like you would see in the real world. Alas these are all what I call 'nice to have' B list items and should not get in the way of my goals on this occasion.
No Blooming
I was tempted to make the 'maybe awesome' demo use post processing effects such as bloom, depth of field and haze effects (for the desert heat) but again for the above reason refrained. These can be added later, and are not what we all agree are 'essential features' of the engine. Hopefully my terrain demo now stands on it's own without the smudging effects of post processing.
Next Things
Now I feel the demo stands alone for a presentation, I can move onto more serious matters such as re-coding and cleaning the prototype to use a data structure and resource numbering set that can drop right into the main engine and map editor IDE. A terrain editor is no use as a prototype! Hopefully this task won't take too long, and the subsequent introduction to the IDE will go smoothly if I do this preliminary step correctly.
Once the above is done, I will be free to resurrect the Bullet Physics prototype I very quickly knocked up before my holiday. It attempts to operate a 'character controller' walking over a 'height map', which is actually quite ideal as I could drop it into the present terrain module. From there, which is no small trick to get all that set up and running properly, is to then add a few dynamic and static objects to test performance and stability of the floor.
We don't want a repeat of FPSC Classic with enemy characters suddenly disappearing through the floor and into infinity! I am hopeful the new Bullet physics system will provide many wonderful toys to Reloaded in time, and if I can get the basics working great, the rest will follow smoothly.
Signing Off
My schedule puts this week down as pure Physics coding, so the sooner I can get off terrain and onto physics, the sooner I can get them both integrated and start the inevitable tweaks to ensure they all play nicely.
I am quite looking forward to creating a sphere and rolling it down a terrain hill and watch it hit the water and start bobbing about, then cast some wind around and see it subtly shift position as it islands it's way around the pond.
Today I get a few more days terrain time thanks to a postponed meeting, which was really supposed to be day one of my Physics work. I just could not resist continuing to add the eye candy and get the demo 'just so' before moving too far off my present mark.
Monday I finished the water shader, water effects code and added a better sky box texture to give a high definition feel to the whole scene. I then must have spent two hours just moping about making terrain, cutting out little rivers, playing with my height and paint editing tools to see what kind of landscapes I could come up with. During my 'fun' my mind raced about more editing tools I could implement, more refinements to the shaders, optimizations that fit the way I did some things and a general need for more plants, rocks and bits of scenery detail.
I think the screen shot I have not is pretty darn good, but I am going to stick to Rick's guns and refrain from putting any 'suspicious' art out there :) Only a few more days to wait, and I think we will be using a 'terrain shot' for the next TGC newsletter so there will be no doubt you will see all this soon enough.
Details Details
It might seem adding water and new sky was a relatively trivial affair, but the very subtle code I added attempted to best some of the tricks done in high rolling games. Little things like a subtle fog effect, not to cull distant objects but to provide a misty sense of distance (and I mean VERY subtle).
Another trick. courtesy of Evolved, is to use a water mask texture to describe the edges of a lake or body of water. This ensures the water does not look strange when bumping up against solid geometry and is a great substitute for a depth read. I also had a few ideas where I could hijack the other channels of the water mask to describe depth, and use a nifty pixel shader calculation to shade the refraction map darker as the water gets deeper, like you would see in the real world. Alas these are all what I call 'nice to have' B list items and should not get in the way of my goals on this occasion.
No Blooming
I was tempted to make the 'maybe awesome' demo use post processing effects such as bloom, depth of field and haze effects (for the desert heat) but again for the above reason refrained. These can be added later, and are not what we all agree are 'essential features' of the engine. Hopefully my terrain demo now stands on it's own without the smudging effects of post processing.
Next Things
Now I feel the demo stands alone for a presentation, I can move onto more serious matters such as re-coding and cleaning the prototype to use a data structure and resource numbering set that can drop right into the main engine and map editor IDE. A terrain editor is no use as a prototype! Hopefully this task won't take too long, and the subsequent introduction to the IDE will go smoothly if I do this preliminary step correctly.
Once the above is done, I will be free to resurrect the Bullet Physics prototype I very quickly knocked up before my holiday. It attempts to operate a 'character controller' walking over a 'height map', which is actually quite ideal as I could drop it into the present terrain module. From there, which is no small trick to get all that set up and running properly, is to then add a few dynamic and static objects to test performance and stability of the floor.
We don't want a repeat of FPSC Classic with enemy characters suddenly disappearing through the floor and into infinity! I am hopeful the new Bullet physics system will provide many wonderful toys to Reloaded in time, and if I can get the basics working great, the rest will follow smoothly.
Signing Off
My schedule puts this week down as pure Physics coding, so the sooner I can get off terrain and onto physics, the sooner I can get them both integrated and start the inevitable tweaks to ensure they all play nicely.
I am quite looking forward to creating a sphere and rolling it down a terrain hill and watch it hit the water and start bobbing about, then cast some wind around and see it subtly shift position as it islands it's way around the pond.
Friday, 26 July 2013
Friday And The Randoms
Terrain Save, Load and Random Generate
Another good (but hot) night in the coders dungeon. At night I have to switch off the blessed air-con as the open window lets all the moths in. After 10PM the office gets hotter and hotter and hotter this time of year!
It's now 3AM and I'm practically in a sauna, sweating like a coder without a compiler and hoping this blog entry is nice and succinct so I can go to bed. Some good news in that the Monday meeting has been pushed to Thursday which gives me much more time to add some polish and even start the Physics prototype next week! The downside of course is that without a demo for management to approve, there will be no pictures or videos now until next Friday. If you want this policy to change, you know Rick's email ;)
Terrain Saver and Loader
It was key to be able to save all edits performed and reload the terrain in the exact same state to resume editing and of course to load in when the level requires it. A few hitches though. One bug one is that when I construct the height data manually in the terrain module, I drop from 200 fps down to 30 fps for some unfathomable reason. I have yet to dive into the source code of the module and might just be something silly, but it has me a little vexed.
I also found that converting the terrain height data to a height map image, and then feeding that back through the loader created import distortion of some kind which would slowly (but subtly) change the terrain heights each time you saved and loaded. Not a good idea as your terrain would have washed away after the 100th save :) I am instead directly storing the heights in a Dark Basic Pro memblock file so I can keep a very accurate eye on this most valuable data. I also save the veg shadow map too, this time as a simple image and map it back to the system when I restart the prototype. It works just great.
Holy Random Terrains Batman!
A tickbox on my schedule was the successful generation of a believable 'random' terrain as part of the Reloaded terrain editing suite. I was certain many users would not want to define every hill, dip, lake, bump, slope and mountain over a 50,000 x 50,000 area. They would want a single button to make one up, and then allow some editing in the part of interest.
To that end I borrowed inspiration from our friendly Dark Basic Pro forum, and an entry into our 20 line challenge which is a bit of fun which tasks any programmer to write something useful in under 20 lines of code. It's great to see the amazing things coders can do in such a small space and in this case, someone produced a terrain generator in 20 lines!
The name of this DBP star is Lewis999 who adapted a Diamond-Square algorithm to populate a matrix with realistic height data. Using the same technique, I generated pure height data using the same idea and applied it to the terrain constructor. I then painted textures based on distance from the water level, and used smoothing to create a nice transition. I also painted a band of grass at the point I felt grass would ideally grow (not too high in the mountains, not underwater or on the shore). You can still paint all this manually, but the terrain generator starts off as an automated process.
Finally I played with the grass sizes to create a more dynamic and rich veg experience, and concluded that a few more grass and vegetation models and textures would really lift my terrain visual. Something to add to Mark's list when he's not looking!
Is Something Missing?
Running around my newly generated terrain for a while, as good as it was, there was something missing. Naturally there is no game, so no enemies, no buildings, no game objects, no nout of course. Still, you can have a convincing terrain without all the above, right? As I am making a deliberate effort not to add trees (as that is for another pack and another day), I wondered what else I could add. Perhaps a few cactus plants models when/if they are created, sure, but I need something more substantial!
Is it a bird, is it a plane, no it's a Rock!
Sure enough, what my bleak terrain level needed was rocks, and lots of them! Not the little pebbles that can be baked into the floor texture but large ugly rocks left after the last glacier strolled through the land. From my extensive terrain editing (playing) I knew how to create a rock by making a sharp raised land, then squashing the top bit, then adding a rock texture and surrounding it with grass.
Given that knowledge, I proceeded to add a system which would strategically add a rock, and not just a single rock but what I term a rock clump. These clumps comprise of about 15 rocks in close proximity and they really do look natural when sprawled over the floor. The system then moves somewhere else in the land and makes another clump, and so on until there are enough.
The terrain generator is pretty good for a V1 now, but it does take a while (30 seconds for 150 rocks) and the final level would probably need a few thousand of them. The good news is that once the rocks are in the land, you can save and load the whole terrain within seconds :)
Signing Off
So that's the week, and apart from IDE integration, all my terrain objectives have been met on schedule which I am pleased about. Still needs spit and polish of course, but we're well on the way now. It also occurs to me that our AI system will need to know about height map terrain so enemies can work out a path through cliffs, valleys, slopes, work out line of sight, know what height advantage means, e.t.c. I have already started a list :)
I plan to use the weekend to quickly add shadow generation to the prototype, experimenting with things like burning the normals as shadows in the texture to improve LOD transitions, calculating when a large hill or rock casts a shadow onto the terrain and the big one, rendering the entire 'outdoor' scene of a level such that I can burn the resulting shadows into the veg shadow map too. This of course means we cannot have a moving sun for day and night cycles, but adding cascade shadow mapping to the terrain proved too costly and unless there is a performance friendly solution out there I have decided to aim for quality visuals rather than a day / night cycle in V1. I should have plenty of time to work on my shaders, and it won't be long before a solution pops into my head which allows us to have our cake and eat it.
As is my custom, no blog entries this weekend so I can be free to do nothing, or burn the candle at both ends. I was going to sneak out a screenshot of the latest progress, but I resisted (Rick will be proud). See ya Monday!
Another good (but hot) night in the coders dungeon. At night I have to switch off the blessed air-con as the open window lets all the moths in. After 10PM the office gets hotter and hotter and hotter this time of year!
It's now 3AM and I'm practically in a sauna, sweating like a coder without a compiler and hoping this blog entry is nice and succinct so I can go to bed. Some good news in that the Monday meeting has been pushed to Thursday which gives me much more time to add some polish and even start the Physics prototype next week! The downside of course is that without a demo for management to approve, there will be no pictures or videos now until next Friday. If you want this policy to change, you know Rick's email ;)
Terrain Saver and Loader
It was key to be able to save all edits performed and reload the terrain in the exact same state to resume editing and of course to load in when the level requires it. A few hitches though. One bug one is that when I construct the height data manually in the terrain module, I drop from 200 fps down to 30 fps for some unfathomable reason. I have yet to dive into the source code of the module and might just be something silly, but it has me a little vexed.
I also found that converting the terrain height data to a height map image, and then feeding that back through the loader created import distortion of some kind which would slowly (but subtly) change the terrain heights each time you saved and loaded. Not a good idea as your terrain would have washed away after the 100th save :) I am instead directly storing the heights in a Dark Basic Pro memblock file so I can keep a very accurate eye on this most valuable data. I also save the veg shadow map too, this time as a simple image and map it back to the system when I restart the prototype. It works just great.
Holy Random Terrains Batman!
A tickbox on my schedule was the successful generation of a believable 'random' terrain as part of the Reloaded terrain editing suite. I was certain many users would not want to define every hill, dip, lake, bump, slope and mountain over a 50,000 x 50,000 area. They would want a single button to make one up, and then allow some editing in the part of interest.
To that end I borrowed inspiration from our friendly Dark Basic Pro forum, and an entry into our 20 line challenge which is a bit of fun which tasks any programmer to write something useful in under 20 lines of code. It's great to see the amazing things coders can do in such a small space and in this case, someone produced a terrain generator in 20 lines!
The name of this DBP star is Lewis999 who adapted a Diamond-Square algorithm to populate a matrix with realistic height data. Using the same technique, I generated pure height data using the same idea and applied it to the terrain constructor. I then painted textures based on distance from the water level, and used smoothing to create a nice transition. I also painted a band of grass at the point I felt grass would ideally grow (not too high in the mountains, not underwater or on the shore). You can still paint all this manually, but the terrain generator starts off as an automated process.
Finally I played with the grass sizes to create a more dynamic and rich veg experience, and concluded that a few more grass and vegetation models and textures would really lift my terrain visual. Something to add to Mark's list when he's not looking!
Is Something Missing?
Running around my newly generated terrain for a while, as good as it was, there was something missing. Naturally there is no game, so no enemies, no buildings, no game objects, no nout of course. Still, you can have a convincing terrain without all the above, right? As I am making a deliberate effort not to add trees (as that is for another pack and another day), I wondered what else I could add. Perhaps a few cactus plants models when/if they are created, sure, but I need something more substantial!
Is it a bird, is it a plane, no it's a Rock!
Sure enough, what my bleak terrain level needed was rocks, and lots of them! Not the little pebbles that can be baked into the floor texture but large ugly rocks left after the last glacier strolled through the land. From my extensive terrain editing (playing) I knew how to create a rock by making a sharp raised land, then squashing the top bit, then adding a rock texture and surrounding it with grass.
Given that knowledge, I proceeded to add a system which would strategically add a rock, and not just a single rock but what I term a rock clump. These clumps comprise of about 15 rocks in close proximity and they really do look natural when sprawled over the floor. The system then moves somewhere else in the land and makes another clump, and so on until there are enough.
The terrain generator is pretty good for a V1 now, but it does take a while (30 seconds for 150 rocks) and the final level would probably need a few thousand of them. The good news is that once the rocks are in the land, you can save and load the whole terrain within seconds :)
Signing Off
So that's the week, and apart from IDE integration, all my terrain objectives have been met on schedule which I am pleased about. Still needs spit and polish of course, but we're well on the way now. It also occurs to me that our AI system will need to know about height map terrain so enemies can work out a path through cliffs, valleys, slopes, work out line of sight, know what height advantage means, e.t.c. I have already started a list :)
I plan to use the weekend to quickly add shadow generation to the prototype, experimenting with things like burning the normals as shadows in the texture to improve LOD transitions, calculating when a large hill or rock casts a shadow onto the terrain and the big one, rendering the entire 'outdoor' scene of a level such that I can burn the resulting shadows into the veg shadow map too. This of course means we cannot have a moving sun for day and night cycles, but adding cascade shadow mapping to the terrain proved too costly and unless there is a performance friendly solution out there I have decided to aim for quality visuals rather than a day / night cycle in V1. I should have plenty of time to work on my shaders, and it won't be long before a solution pops into my head which allows us to have our cake and eat it.
As is my custom, no blog entries this weekend so I can be free to do nothing, or burn the candle at both ends. I was going to sneak out a screenshot of the latest progress, but I resisted (Rick will be proud). See ya Monday!
Thursday, 25 July 2013
Thursday Has Better Veg
Veg Improvements
Thanks to an urgent rush on a veg model, some tinkering and tweaking, the terrain module how has a better vegetation system which looks better, does not overhang cliffs, fits better on the ground and is faster for performance too.
Terrain Edit Cursor Highlighter
Thanks to the fact I am using a shader for my terrain, and I no longer need to save four texture stages for cascade shadow mapping, I have added three more diffuse texture options and a cursor highlighter texture as the last texture stage. Using some pokery, I am able to have the cursor render at the mouse coordinate during editing, and also reflect the radius of the brush which is now under shortcut control. It looks pretty snazzy too, as though a glowing light of creation spawns terrain from it's terrible orb of power :)
More Shader Fun
To combine the different textures coming into the terrain, I am using a control map (the veg shader map I mentioned in previous blogs) and rather that gobble up my useful channels, I can specify which of the five diffuse textures from a single Blue channel of the control map. Here some code which does it:
float texselectorV = tex2D(NormalSampler,IN.TexCoord/500.0f).b;
float texselectorcol1 = max(0,0.25f-abs(texselectorV-0.00))*4.0f;
float texselectorcol2 = max(0,0.25f-abs(texselectorV-0.25))*4.0f;
float texselectorcol3 = max(0,0.25f-abs(texselectorV-0.50))*4.0f;
float texselectorcol4 = max(0,0.25f-abs(texselectorV-0.75))*4.0f;
float texselectorcol5 = max(0,0.25f-abs(texselectorV-1.00))*4.0f;
float3 textpart1 = tex2D(DiffuseSampler1,IN.TexCoord).xyz*texselectorcol1;
float3 textpart2 = tex2D(DiffuseSampler2,IN.TexCoord).xyz*texselectorcol2;
float3 textpart3 = tex2D(DiffuseSampler3,IN.TexCoord).xyz*texselectorcol3;
float3 textpart4 = tex2D(DiffuseSampler4,IN.TexCoord).xyz*texselectorcol4;
float3 textpart5 = tex2D(DiffuseSampler5,IN.TexCoord).xyz*texselectorcol5;
finalcolor.xyz = textpart1+textpart2+textpart3+textpart4+textpart5;
Neat I know, but when you have limited resources you need to get creative with what you have. Old school 8 bit experience that one! I've also been impressed with the raw power of the GPU when running shaders. Almost all my bottlenecks have come from poor coding or some intense CPU activity, which is very encouraging for all the wonderful ideas one can perform through a shader!
Signing Off
The plan is to carry on and get the prototype so I can paint to the 'veg shader control map' by writing the texture directly from my program (performance alert) which can then reflect in the textures used by the terrain in real-time. This will lead onto being able to paint the veg color and at the same time the actual veg data which the vegetation system will use to populate the terrain. Right now the veg is being used for the entire terrain, which works fine and fast, but I dare say not everyone will want veg everywhere!
After that, I will add some quick 'randomize terrain' functionality and perhaps some 'save what I have done' code to make sure this edit can be reloaded and continued. The final step will then be to add it to the main FPSC IDE which is what I hope will occupy my Friday and have the weekend as an overflow buffer before the meeting on Monday. I still have to play S.T.A.L.K.E.R (deferred renderer) which is still in it's shrink wrap :)
Thanks to an urgent rush on a veg model, some tinkering and tweaking, the terrain module how has a better vegetation system which looks better, does not overhang cliffs, fits better on the ground and is faster for performance too.
Terrain Edit Cursor Highlighter
Thanks to the fact I am using a shader for my terrain, and I no longer need to save four texture stages for cascade shadow mapping, I have added three more diffuse texture options and a cursor highlighter texture as the last texture stage. Using some pokery, I am able to have the cursor render at the mouse coordinate during editing, and also reflect the radius of the brush which is now under shortcut control. It looks pretty snazzy too, as though a glowing light of creation spawns terrain from it's terrible orb of power :)
More Shader Fun
To combine the different textures coming into the terrain, I am using a control map (the veg shader map I mentioned in previous blogs) and rather that gobble up my useful channels, I can specify which of the five diffuse textures from a single Blue channel of the control map. Here some code which does it:
float texselectorV = tex2D(NormalSampler,IN.TexCoord/500.0f).b;
float texselectorcol1 = max(0,0.25f-abs(texselectorV-0.00))*4.0f;
float texselectorcol2 = max(0,0.25f-abs(texselectorV-0.25))*4.0f;
float texselectorcol3 = max(0,0.25f-abs(texselectorV-0.50))*4.0f;
float texselectorcol4 = max(0,0.25f-abs(texselectorV-0.75))*4.0f;
float texselectorcol5 = max(0,0.25f-abs(texselectorV-1.00))*4.0f;
float3 textpart1 = tex2D(DiffuseSampler1,IN.TexCoord).xyz*texselectorcol1;
float3 textpart2 = tex2D(DiffuseSampler2,IN.TexCoord).xyz*texselectorcol2;
float3 textpart3 = tex2D(DiffuseSampler3,IN.TexCoord).xyz*texselectorcol3;
float3 textpart4 = tex2D(DiffuseSampler4,IN.TexCoord).xyz*texselectorcol4;
float3 textpart5 = tex2D(DiffuseSampler5,IN.TexCoord).xyz*texselectorcol5;
finalcolor.xyz = textpart1+textpart2+textpart3+textpart4+textpart5;
Signing Off
The plan is to carry on and get the prototype so I can paint to the 'veg shader control map' by writing the texture directly from my program (performance alert) which can then reflect in the textures used by the terrain in real-time. This will lead onto being able to paint the veg color and at the same time the actual veg data which the vegetation system will use to populate the terrain. Right now the veg is being used for the entire terrain, which works fine and fast, but I dare say not everyone will want veg everywhere!
After that, I will add some quick 'randomize terrain' functionality and perhaps some 'save what I have done' code to make sure this edit can be reloaded and continued. The final step will then be to add it to the main FPSC IDE which is what I hope will occupy my Friday and have the weekend as an overflow buffer before the meeting on Monday. I still have to play S.T.A.L.K.E.R (deferred renderer) which is still in it's shrink wrap :)
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 ;)
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 ;)
Subscribe to:
Posts (Atom)