Mythruna
March 28, 2024, 11:32:39 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: Welcome to the new forums. See "Announcements" for a note for new users.
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Slow but steady...  (Read 8725 times)
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« on: February 25, 2013, 04:05:12 AM »

Here is my next weekly update.

Progress has been slow but steady but I finally started to shake this latest cold on Saturday.  I've been more productive in the last two days than I had been the entire previous week.  The down side is that I spent that time mostly fixing bugs that cropped up, real or imagined.

When you have an existing engine to compare to and are a little paranoid, sometimes differences will send you chasing down rabbit holes.  For example, Saturday night I chased down why the new engine was using almost twice the memory of the old one (native memory) only to find out that I was just caching more aggressively.  The plus side is that now I have better memory instrumentation in both engines and a _much_ easier way to tell when something changes.

Another example was today when I noticed that the caves were being generated differently... but not necessarily in a way that mattered.  First I noticed that trees were appearing in mid air above gorges... but only outside of the main starting "node", ie: 512 meters or more away from default spawn.  I tracked that bug down relatively quickly but in the process I took some screen shots of one engine as it compared to the other and noticed that there were variations in the gorge walls.

Generation is supposed to be identical.  It's random but I pull the same seeded random numbers each time.  If the sequence is the same then the results should be the same.  I did a couple hour deep dive into why this was happening... paranoid that it was the sign of something worse going on.  Lots of things have changed so I had to check each one.  I found one issue where the floating point location values of the caves were getting slightly off in the 5th or 6th decimal place when cached to disk.  I thought might be the cause and fixed that but still there were differences.  These kinds of things are notoriously difficult to debug because you have huge chunks of data to look at.  I ended up dumping the full cave generation output for a section of the world and running diffs.  The cleaner I got things the more different they got.

A quick word about how the caves work.

Basically, there is an algorithm that generates different kinds of "influencers".  There are points, lines, etc..  If you think of these like they are broadcasting a radio signal from their entire "shape" at some strength, that's kind of how it works.  At any given point, I can sum up the signals from all of the influences and if it's strong enough, I say "that's an empty block".  Tada, nicely rounded caves and stuff.  Anyway familiar with meta-balls, this is the reverse. (http://en.wikipedia.org/wiki/Metaballs)

If you plop a big "point" influence in the middle of the land and give it some strong strength and radius then you get a nice big crater.  I showed an example of this once before... because plug-ins can manually add these influencers wherever they want to make all kinds of cool caves and stuff.

All of that is predetermined when a 1024x1024 area is first encountered.  It's only the actual strength calculations that are done when a tile is needed.

If you've followed along so far, here is the random part... during tile generation each block is checked for "caveness".  ie: summing all of the strength at that point.  The block ends up with a value that is either 0 (completely outside of caveness), 1 (completely cave), or in between 0 and 1 (somewhere on the border).  To give caves a rough appearance, I throw some randomness in where the value is between 0 and 1 relative to how close to 1 it is.

So, in summary, the algorithm goes like this:
-go through each block in the tile
-sum the strengths of all influences
-if it's between 0 and 1 kick in some random

And as long as I ask for the random numbers in the same order, the caves should turn out the same for a given seed. (And yes, I already verified the seed was the same).

Now, keep in mind that we are talking about the variation of one block at the edges of caves and gorges.  Materially, this does not matter at all.  You will never notice this if one half of a cave is generated using the new engine right next to an old one.  The main parts of the cave will still line up and the walls were random anyway.  Random next to random... it's fine.

...but what if it's a sign of something more serious?

Fortunately, the deep dive into actual data didn't take long.  The first column of blocks generated in the "bad case", showed the problem.  In the old engine, the column was 60 blocks high from bedrock.  In the new engine, the same column was 61 blocks high from bedrock and the top block just happened to have a partial strength... ie: it grabbed a random value from the sequence that the old engine didn't and so that throws all of the next ones off.

Remember how the whole world was off by one block in each direction in the old engine?  Yes, that's right.  That was the difference.

Total waste of time?  No, not really.  I found at least two legitimate bugs (though minor) and have renewed confidence in the algorithms.

Current Short Term Goals

Right now I'm concentrating on finishing things up so that I can release a test build for the "Friends of Mythruna" to try... with a later release for the donators.  Don't feel too disappointed if you aren't in one of the groups.  The engine does virtually nothing in the state I will release it.  You can't even modify blocks.  You can just fly over the land super fast and verify that things generate correctly and my new shaders work... maybe I can also get some performance stats on machines other than my own.

Things I need to get working before I can do that:
-loading screen with progress reporting (Right now it just stares at you looking broken... especially for new worlds)
-finish up some terrain generation stuff (I still have to add back the strata generation for the mineral layer... minor thing)
-an in-game menu (right now, escape closes the app.)  I want to add some options for toggling far terrain off, changing its resolution, etc. to an in-game menu.

All of those things were going to prevent me from releasing anything anyway.  So they need to get done and I might as well bite the bullet.

Once I get that buttoned up, I'm back on track for physics... which will probably roll up a few other things.  On the current plan, I can't even add proper player movement until I get physics properly integrated since in the new engine, the player will be a physics object right from the start.

...then we'll see how it goes.  I've been working on the physics engine off and on for a year and a half now (more or less).  I'm not going to put out another pre-alpha release until it's in in some form.  Too much is waiting on it.
« Last Edit: February 25, 2013, 04:07:55 AM by pspeed » Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #1 on: February 25, 2013, 04:13:31 AM »

Here is the image from facebook of the crater I talked about.  It kind of illustrates the metaballs idea.  One big ball subtracts and a smaller one adds back in (for the floating island).  Only from the cave's perspective, it's actually the opposite of that.  The crater is strength 1 or more and the island is strength 0 (subtracted 1 or more).  Anything 1 or above removes a block from the existing terrain.
Logged
Sean
Donators
Hero Member
***
Posts: 598



View Profile
« Reply #2 on: February 25, 2013, 12:55:52 PM »

I very much appreciate that you take the time to keep us posted.
p.s. Mid air islands are awesome.  Tongue
Logged

"People willing to trade their freedom for temporary security deserve neither and will lose both." - Benjamin Franklin
Moonkey
Hero Member
*****
Posts: 1587

This is probably a picture.


View Profile
« Reply #3 on: February 25, 2013, 01:48:14 PM »

As long as it's steady!
Logged

Mythruna: Don't you dare read any posts I made before 2014.
Teknonick
Sr. Member
****
Posts: 438


View Profile
« Reply #4 on: February 25, 2013, 06:58:35 PM »

Paul. I hate you. You have completely ruined Minecraft for one once again and very soon I will stop playing it all together.

THANK YOU PAUL!!!! Also, that floating island looks neat.... one question, why is the crater bigger than the island?
Logged
pspeed
Administrator
Hero Member
*****
Posts: 5612



View Profile
« Reply #5 on: February 25, 2013, 07:08:44 PM »

Paul. I hate you. You have completely ruined Minecraft for one once again and very soon I will stop playing it all together.

THANK YOU PAUL!!!! Also, that floating island looks neat.... one question, why is the crater bigger than the island?

One big cave meta-ball with a larger radius and positive strength with a little negative meta-ball inside it.
Logged
Michael
Donators
Hero Member
***
Posts: 2166



View Profile
« Reply #6 on: February 25, 2013, 09:19:52 PM »

Paul. I hate you. You have completely ruined Minecraft for one once again and very soon I will stop playing it all together.

THANK YOU PAUL!!!! Also, that floating island looks neat.... one question, why is the crater bigger than the island?

One big cave meta-ball with a larger radius and positive strength with a little negative meta-ball inside it.
For once.. I understand Cheesy
Logged
belgariad87
Donators
Hero Member
***
Posts: 507


RPG player for life


View Profile
« Reply #7 on: February 26, 2013, 05:09:47 AM »

neato. hope you make a special edition physical copy of this game when its released cuz im gettin it!  Grin
Logged

Specs for future reference:
Windows 7 64bit ; Intel Quad Core ; 8GB RAM ; AMD Radeon HD 6800 ; TB HD
Moonkey
Hero Member
*****
Posts: 1587

This is probably a picture.


View Profile
« Reply #8 on: February 26, 2013, 04:59:48 PM »

Yea, I'd like a physical release too, so I could get it sooner.
Logged

Mythruna: Don't you dare read any posts I made before 2014.
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.20 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!