Mythruna

Development => Blog => Topic started by: pspeed on March 31, 2014, 06:37:02 PM



Title: March 2014 status...
Post by: pspeed on March 31, 2014, 06:37:02 PM
So, it's been a while since I've posted a status to the community so I felt one was overdue.

At the beginning of the month, my wife went out of town for her every other month "checkup from the neck-up".  The tumors are kind of still growing so they have put her on yet another medicine.  When she is out of town, I watch the kids and then we had the added benefit of her getting snowed in down there for an extra data.  Between that and all the stuff surrounding it, getting the house ready (on this new medicine it is even more important that she doesn't fall), dealing with the news, etc... there wasn't much time for Mythruna.  Between all of that and trying to keep up with "day job" work, I really didn't even want to sit in front of the computer anymore.

Back somewhere in 2003 or 2004, I did some work with what can loosely be called "isosurfaces".  A lot of the modern sandbox "voxel" games are using this approach to render their terrain.  Back then I was using it for data visualization.  We had lots of "fields" (think meta-balls http://en.wikipedia.org/wiki/Metaballs) and were drawing surfaces on those fields at some threshold.  Animated it looked kind of cool but we never did much with it other than skinning some data sets.

I've long had this sort of thing in the back of my mind as a potential way to deal with flowing water in Mythruna.  For the record, I'm pretty sure that it won't work but it's still been the top of my list for things to try.  Also, I have a directory where I keep design documents for "quick game ideas that might make me some money".  At least half of those could benefit from some kind of voxel/isosurface technique.

Many may remember that I played with doing photorealistic style terrain back in around 2006.  Actually that was my first playing around with jMonkeyEngine way back in its more primitive state.  Things were just frustrating and I ended up abandoning it... still, I do get a bit of "terrain envy" when I see all of these nice looking voxel terrain engines showing up.  I know a lot more about the subject now and was pretty sure I could throw something together quickly.

With Mythruna I made a conscious choice to make a block-world engine.  That's part of the whole aesthetic and I don't plan to change my mind on that but the theory was always that the "land is blocks" but everything else is more organic.  This is why trees are round, water wavy, animals and people will look regular, etc..  In my minds eye, I'd even like it if sand was smoother but I don't know that I will get there.  If I do, then isosurfaces are the way to achieve that.

Creative momentum is a funny thing.  When you are used to being obsessed with something and having that push you through it can be hard to stay motivated when you are "out of it".  If you swing the other way and have things actively pulling you away from the computer every day then it gets even harder.  If you add to that some aversion to sitting in front of the computer at all... you have a recipe for never getting anything done.  That's kind of where I was headed.  I needed a project to get the creative juices flowing.  Something to get back in the habit of coding like a banshee every time I say down at the computer.  Just nothing was really piquing my interest these days.

Anyway, two weeks ago or so I saw "yet another voxel terrain" engine show up, on the JME forums this time.  This kind of was the straw that broke the camel's back.  I thought "not only will I create a voxel terrain engine... but I will open source it making sure that the market gets flooded with them and block worlds are unique again..."  There may have even been a maniacal laugh in there somewhere. ;)  But seriously, I do plan to open source this piece... it's not directly related to the Mythruna engine but the improvements people contribute there will directly benefit my engine.

I'd read chapter one of GPU Gems about 10 times before: http://http.developer.nvidia.com/GPUGems3/gpugems3_ch01.html  It's got a nice compact technique (designed for GPUs actually) for generating terrain.  This has long been on my to-do list to try out so a day or so later I had something cobbled together.

First, the fractal implementation they were using needed to be adapted and I wanted to visualize it before going through the work of surfacing it... so I just plopped down a bunch of point sprites:
(http://i.imgur.com/cG5BP5x.png)

Then the initial mesh implementation: (easier to test with lines than triangles)
(http://i.imgur.com/clNJYCq.png)

Proper surface normal calculation: (little red lines are pointing in the surface normal direction)
(http://i.imgur.com/P10NcB9.png)

Proper triangles and lighting:
(http://i.imgur.com/zvRXjBm.png)

I wanted to see what it would look like with a glass material (water is still in the back of my mind after all):
(http://i.imgur.com/XresPfd.png)

Now the fun part, basic triplanar texture mapping from the GPU gems article:
(http://i.imgur.com/UZ7K7oA.png)

And finally, some of my own enhancements to give the grass more defined borders and also add multiresolution layering of the textures:
(http://i.imgur.com/rZlU6UX.png)

Adding in some JME post-processing filters and it really starts to look like something:
(http://i.imgur.com/YLVxII9.png)

...personally I think that pic is really beautiful even without grass or trees.  Never mind that there is grass growing underwater.  It's not important. :)

Here is a video.  Be sure to watch on HD:
https://www.youtube.com/watch?v=MabpkOVLF3c

I'll even do one better.  Here is a demo you can download:
http://mythruna.com/temp/IsoSurface/IsoSurfaceDemo-Windows.zip
http://mythruna.com/temp/IsoSurface/IsoSurfaceDemo-Linux.zip
http://mythruna.com/temp/IsoSurface/IsoSurfaceDemo-MacOSX.zip

Most likely... if you have trouble running Mythruna then this may give you issues.  With all options on, it hammers the snot out of my graphics card.

Controls:
-space bar toggles between camera and mouse cursor.  (ie: hit the space bar to be able to click on stuff, space again to go back to flying)
-WASD moves
-mouse looks
-left shift runs (10 m/sec)
-left shift + control runs really fast (20 m/sec)
-F3 toggles the HUD
-F5 toggles the stats display
-SysReq/Prt Scr takes a screen shot

On the HUD, if you click on the section titles it will collapse/expand the section.  The little orb on the right side of the section titles turns the effect on/off.  (See video.)

By default, I've turned many of the effects off because they seem to cause issue on some computers.  (Bugs in some JME code.)

I want to stress again that I will not be turning Mythruna into a voxel engine... but I do hope to use this technique for some things in the engine (perhaps crafting if nothing else).

Still, it's a fun little side project, may lead to some simple games I can throw onto a store somewhere, and it gets the creative juices flowing again.  I'm even kind of excited to get back to the more boring things I was working on deep in Mythruna.


Title: Re: March 2014 status...
Post by: pspeed on March 31, 2014, 06:38:16 PM
P.S.: I find it immensely fun to fly really close to the ground holding shift+ctrl... especially trying to stay in the valleys and go through open caves and overhangs.... without 'crashing'.

...which is good because one of the initial simple game ideas I had was some kind of speeder/hover bike racing game.  I just need lot so big trees. :)


Title: Re: March 2014 status...
Post by: Michael Musgrove on March 31, 2014, 07:58:31 PM
Lol, thanks for the progress update, and I saw this video a few days ago before you posted this. :)

I'm still praying for your wife, Paul.


Title: Re: March 2014 status...
Post by: pspeed on March 31, 2014, 08:16:51 PM
Lol, thanks for the progress update, and I saw this video a few days ago before you posted this. :)

I'm still praying for your wife, Paul.

Thanks.

And now you should be able to try the demo out for yourself instead of being forced just to watch. :)


Title: Re: March 2014 status...
Post by: belgariad87 on April 01, 2014, 01:38:50 PM
graphics stuff like this never cease to amaze me  :) its just so awesome how we can do that. Usually when i want a scenic game i play Just Cause 2 multiplayer mod. You can do the crazy stuff everyone does, or you can spawn a motorcycle and calmly ride through the mountains and by the coast. So breathtaking, that world on full graphics. Even not on full graphics its good.

(http://www.thelanbox.com.au/uploads/images/cbedb5_mountain_coast.jpg)


Title: Re: March 2014 status...
Post by: pspeed on April 01, 2014, 03:50:09 PM
graphics stuff like this never cease to amaze me  :) its just so awesome how we can do that. Usually when i want a scenic game i play Just Cause 2 multiplayer mod. You can do the crazy stuff everyone does, or you can spawn a motorcycle and calmly ride through the mountains and by the coast. So breathtaking, that world on full graphics. Even not on full graphics its good.

(http://www.thelanbox.com.au/uploads/images/cbedb5_mountain_coast.jpg)

Very pretty.  I would love to be able to get my little iso engine close to that... not the kind of thing I can easily do over a quick weekend here and there, though. :)

Still, fixing water to look better and adding some atmospherics would go a long way.


Title: Re: March 2014 status...
Post by: Moonkey on April 03, 2014, 03:20:09 AM
That looks beautiful. Metaballs are a good way to go :D


Title: Re: March 2014 status...
Post by: Teknonick on April 03, 2014, 07:10:49 PM
Wait... do I see Paul thinking about upgrading his engine!? He's probably going to have to, because every other Voxel game is. And what is this I hear about the water? I thought you weren't going to make water out of blocks....


Title: Re: March 2014 status...
Post by: pspeed on April 03, 2014, 08:58:17 PM
With Mythruna I made a conscious choice to make a block-world engine.  That's part of the whole aesthetic and I don't plan to change my mind on that but the theory was always that the "land is blocks" but everything else is more organic.  This is why trees are round, water wavy, animals and people will look regular, etc..  In my minds eye, I'd even like it if sand was smoother but I don't know that I will get there.  If I do, then isosurfaces are the way to achieve that.

And what about my post indicates that I'm doing water as blocks?  In fact, the entire point is to do something more organically shaped.

Water will still have to be voxel based on some level... even massive water simulations simulate water particles.


Title: Re: March 2014 status...
Post by: Michael Musgrove on April 04, 2014, 03:28:02 PM
I wonder, how are the texture applies across so many polygons? Does it take a single texture, and stretch it along making it fit nicely, and probably repeats?


Title: Re: March 2014 status...
Post by: Teknonick on April 04, 2014, 07:45:54 PM
I mean, Paul, by blocks I mean voxel-placed. If you've played Minecraft's Finite Liquid Mod, then that's kind of what I thought you decided you are heading for. I was originally thinking you were going to be making water more like 'entities' and such... but I wasn't quiet sure how that would work. Either way, as long as it's better than Minecraft (Or not), I'm in for it. ;)


Title: Re: March 2014 status...
Post by: pspeed on April 04, 2014, 11:26:45 PM
I wonder, how are the texture applies across so many polygons? Does it take a single texture, and stretch it along making it fit nicely, and probably repeats?

It's... complicated.

First, depending on the surface normal, three different textures are mixed together using different planar axes.  Basically, they use the world coordinates.  So up (x,z) is mixed with east/west (zy) is mixed with north/south (xy) depending on how much it points in any of those directions.

But each plane is double sampled.  So, given the x,y world location, for example, that coordinate is used on a larger scale texture and mixed with one at higher repeat.  But both of the coordinates are warped in a fractal so the repetition is less apparent (many cases you can't see repetition at all).  If you run the demo you can see that that textures get more detailed as you get closer.  The mixing of large scale to small scale is done based on distance.

There is also some funky stuff with normals pointing up where I threshold (and run that through fractal noise also) to get the hard edges around the grass.  That part was quite tricky... and I will need to modify it to handle beaches/silt at the water line at some point.

Trees and grass first, though.


Title: Re: March 2014 status...
Post by: pspeed on April 04, 2014, 11:28:50 PM
Incidentally... the dirt texture I used is Mythruna's dirt texture.  I use a different bump map and the fractal warping makes it less obvious that it is the same.


Title: Re: March 2014 status...
Post by: belgariad87 on April 06, 2014, 01:20:54 PM
i swear, one of these days when i'm trying to make a game, I'm just gonna comb through all the techinical knowledge you've handed out, Paul. you could write a book.


Title: Re: March 2014 status...
Post by: pspeed on April 06, 2014, 01:32:56 PM
i swear, one of these days when i'm trying to make a game, I'm just gonna comb through all the techinical knowledge you've handed out, Paul. you could write a book.

:)  Thanks.


Title: Re: March 2014 status...
Post by: pspeed on April 12, 2014, 03:26:22 AM
Just a heads up that I added grass to the demo mentioned above.  I haven't had much time for else but it's something.

(http://i.imgur.com/gwQLL0C.png)

I've updated the posted demo.  If I get time, I'll be adding trees next as that's really where I get to work out some interesting stuff that might help with water later.


Title: Re: March 2014 status...
Post by: belgariad87 on April 12, 2014, 12:21:22 PM
thats looks great! are you going to use this for mythruna??  :o


Title: Re: March 2014 status...
Post by: pspeed on April 12, 2014, 01:04:51 PM
thats looks great! are you going to use this for mythruna??  :o

Use which?  I feel like I already answered the most obvious questions.

If it's just the grass you are talking about, it has some limitations that will make it not work well for Mythruna.

I've tried the light scattering on Mythruna before but it would need a lot of work there.  Any time you are in a building and look up at the sky, your vision goes dark.


Title: Re: March 2014 status...
Post by: pspeed on April 12, 2014, 01:05:53 PM
As for the terrain, no.  That one was answered earlier.  Maybe for Mythruna 2.0.


Title: Re: March 2014 status...
Post by: FutureB on April 12, 2014, 04:41:08 PM
im curious if you are able to load a world with pre built structures, how do they look, is it just the terrain which you have altered or the way in which every block works.


Title: Re: March 2014 status...
Post by: pspeed on April 12, 2014, 04:51:06 PM
im curious if you are able to load a world with pre built structures, how do they look, is it just the terrain which you have altered or the way in which every block works.

It's terrain based on skinning a density field.  So, for example, you will almost never have sharp corners unless they happen to magically align with a grid cell just right (and even then they have a small bevel with a wasted set of nearly degenerate triangles).  For houses and block-like structures, this is a very wasteful approach.

Right now my biggest limit in Mythruna is memory.  I'm constantly looking for ways to reduce what I have to cache, shrink my mesh memory footprint, etc..  This demo is fairly stable with respect to memory but I'm also generating the data on demand instead of keeping it around... the pleasure of a non-modifiable world.  Also the demo above in Mythruna terms only has one block type.  Everything you see is a trick of that material.

Now... some of those multitexture tricks... 100% usable in Mythruna.  In fact, I've played with that a little already in older posts.  I may even explore this further because for the terrain there are no texture coordinates.  If I could do that for some of the block types in Mythruna (especially the more common ones) I'd see both a memory reduction and an increase in texture quality.  1) they would look good from far away and from up close, 2) they wouldn't obviously repeat.

If I were to use an engine like this for Mythruna then I would have to do both a block engine and a voxel engine... effectively doubling the memory required to hold a chunk.  They could share lighting info, though, at least... and the lighting could still be propagated based on the voxels. (There is a bitmask in the cell values that says how lighting can propagate now... that would just have to take both block cells and density voxels into account... but the lighting propagator and mem requirements for lighting would not change from what I do now in the unreleased engine.)

Partially, I've created this demo to show that I could have made nicer looking terrain but chose specifically not to... it's the kind of thing that consumes 100% of your life.  That's why I'm keeping the scope of this one very narrow to get the code released as open source.


Title: Re: March 2014 status...
Post by: belgariad87 on April 12, 2014, 04:51:32 PM
ah right u did. forgot.


Title: Re: March 2014 status...
Post by: pspeed on April 13, 2014, 12:41:33 AM
ah right u did. forgot.

I didn't mean to sound snippy or anything.  Between having kids and answering posts on the JME forum, I seem to have a sensitivity to repeating myself that borders on the irrational. :)