It is currently Sat Aug 22, 2020 2:03 pm


All times are UTC




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: Types of Volumes
PostPosted: Wed Mar 23, 2011 4:23 am 
User avatar

Joined: Tue Feb 22, 2011 8:04 am
Posts: 101
I am confused about the different types volumes can be, and what the differences are between each type.

In what situations would someone use each type?

How does the volume type affect the resulting mesh if at all?

I hope this doesn't come across as no0bish, the documentation is sparse on this detail.

Thank you for the help and responses. This forum is so helpful.

_________________
--Real Programmers use a magnetized needle and a steady hand.
--xkcd--


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Types of Volumes
PostPosted: Wed Mar 23, 2011 11:27 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
In a nutshell, the available voxel types are Material, Density, and MaterialDensityPair. All of these provide both a getDensity() and getMaterial() function. In the case of the Density class getMaterial() just returns a constant value. In the case of the Material class getDensity() depends on the material - a material of 0 means empty space and so a density of 0, while any other material means a solid space and so a density of some constant value.

During surface extraction the getDensity() is the only thing which controls the shape of the mesh. The getMaterial() is just passed along for rendering.

In general you should use Material for Minecraft style terrain and Density for smooth voxel terrain. You can use MaterialDensityPair if you want different types of surface on your smooth voxel terrain.

The numbers on the end (e.g Material8) are just the number of bits per voxel. In principle you could have Material16 if you wanted more materials available.

See also here: viewtopic.php?p=1261#p1261


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Types of Volumes
PostPosted: Thu Mar 24, 2011 1:26 am 
User avatar

Joined: Tue Feb 22, 2011 8:04 am
Posts: 101
It seems most of my understanding was correct.

My real confusion is over density then. Obviously it determines if a voxel is empty or solid, but why such a range of values?

What is the threshold density is compared to?

How does density affect the resulting mesh?
Is it a measure of how "full" a voxel is?

I'm partly asking these questions because I am having trouble getting my meshes to appear. I managed to get the demo voxels to appear, but now when I create my own volume I am only getting a flat square to appear at best.

I think I might be using density wrong, so hopefully these questions will help me nail down my problem.

Thanks for the help.

_________________
--Real Programmers use a magnetized needle and a steady hand.
--xkcd--


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Types of Volumes
PostPosted: Thu Mar 24, 2011 6:48 am 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
while you are still having troubles like this, you should only use densities of YOURTYPE::getMaxDensity() and YOURTYPE::getMinDensity() where maxDensity refers to solid material and MinDensity refers to air.

the reason for the range of values is best explained in 2d... so look in this post: viewtopic.php?p=318#p318

if the density of a voxel is below the threshhold (or equal to, I'm not sure on that matter), it is considered empty and will cause a border to be drawn here.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Types of Volumes
PostPosted: Thu Mar 24, 2011 3:06 pm 
User avatar

Joined: Tue Feb 22, 2011 8:04 am
Posts: 101
Ok so the density is similar to greyscale or antialiasing then? That makes sense.

That is strange though. I was setting half my voxels to MAX density, but when I can see them it only looks like a flat square. This is how I was filling my volume. I wanted to simulate one chunk of my landscape. I was testing a chunk size of 32x256x32.

Code:
   
for(uint16_t x = 0; x < 32; x++)
      for(uint16_t y = 0; y < 128; y++)
         for(uint16_t z = 0; z < 32; z++)
         {
            mWorldVoxels[0][0]->setVoxelAt(x,y,z,MaterialDensityPair44(0,MaterialDensityPair44::getMaxDensity()));
         }
   generateChunkMeshes(mWorldVoxels[0][0]);


This seems to be consistent with what I have heard, but it doesn't render well. I wonder if this could be a problem with my ogre manual object. Its confusing to me, because my code worked fine when using it with the demo cubes. Perhaps the problem just wasn't noticeable in the demo.

One last question. Can you use any combination of bits in PolyVox when declaring a MaterialDensityPair? I am using the demo 44 pair, but could you do 71, 53, 62, etc? Is there a limited set of implemented combinations?

Thanks for the help.

_________________
--Real Programmers use a magnetized needle and a steady hand.
--xkcd--


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Types of Volumes
PostPosted: Thu Mar 24, 2011 4:04 pm 
User avatar

Joined: Wed Jan 26, 2011 3:20 pm
Posts: 203
Location: Germany
GM_Riscvul wrote:
Ok so the density is similar to greyscale or antialiasing then? That makes sense.

That is strange though. I was setting half my voxels to MAX density, but when I can see them it only looks like a flat square. This is how I was filling my volume. I wanted to simulate one chunk of my landscape. I was testing a chunk size of 32x256x32.

well I'm not sure how you handle your chunk borders. it looks like you have a volume for every chunk, so you should see more than that, can you post the code for the generateChunkMeshes function?

Quote:
This seems to be consistent with what I have heard, but it doesn't render well. I wonder if this could be a problem with my ogre manual object. Its confusing to me, because my code worked fine when using it with the demo cubes. Perhaps the problem just wasn't noticeable in the demo.

"doesn't render well" is not really descriptive :D do you have screenshots?

Quote:
One last question. Can you use any combination of bits in PolyVox when declaring a MaterialDensityPair? I am using the demo 44 pair, but could you do 71, 53, 62, etc? Is there a limited set of implemented combinations?

of course. anything adding up to 8 works. the way the source looks, anything adding up to 16 should work, too, but I've never tried it.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Types of Volumes
PostPosted: Thu Mar 24, 2011 9:47 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
GM_Riscvul wrote:
I was setting half my voxels to MAX density, but when I can see them it only looks like a flat square.

That's probably what I'd expect... switch to wireframe an you should find that square is actually the top surfaces of a large number of cubes. You don't see the side of these cubes because eventually they will be hidden by the next chunk of terrain.

If you do want to see the sides, then set it up so that your data does not go right to the edge of the volume.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Types of Volumes
PostPosted: Thu Mar 24, 2011 9:51 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
GM_Riscvul wrote:
One last question. Can you use any combination of bits in PolyVox when declaring a MaterialDensityPair? I am using the demo 44 pair, but could you do 71, 53, 62, etc? Is there a limited set of implemented combinations?

Yes, search for this line:
Code:
typedef MaterialDensityPair<uint8_t, 4, 4> MaterialDensityPair44;

You could also add:
Code:
typedef MaterialDensityPair<uint8_t, 7, 1> MaterialDensityPair71;
typedef MaterialDensityPair<uint8_t, 5, 3> MaterialDensityPair53;
typedef MaterialDensityPair<uint8_t, 6, 2> MaterialDensityPair62;


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Types of Volumes
PostPosted: Fri Mar 25, 2011 12:49 am 
User avatar

Joined: Tue Feb 22, 2011 8:04 am
Posts: 101
Quote:
That's probably what I'd expect... switch to wireframe an you should find that square is actually the top surfaces of a large number of cubes. You don't see the side of these cubes because eventually they will be hidden by the next chunk of terrain.

If you do want to see the sides, then set it up so that your data does not go right to the edge of the volume.


Wow... all this time, I thought I was mentally challenged, and couldn't follow the example correctly, but in the end the library is just one step ahead of me. Now all I have to do is to scale it to the right size.

That's exciting! It is also good to know that custom materialDensity pairs are so easy to add.

This brings up another question. Is it possible to store more than one byte of data in a voxel?

Thank you so much for your help.

_________________
--Real Programmers use a magnetized needle and a steady hand.
--xkcd--


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Types of Volumes
PostPosted: Fri Mar 25, 2011 1:47 am 

Joined: Sun Jan 23, 2011 6:06 am
Posts: 92
Well, since it's templated, couldn't you just use something ... ?

Code:
typedef MaterialDensityPair<uint16_t, 15, 1> MaterialDensityPair15_1;


Or, you could just create your own custom voxel type and store pretty much any data you like.

One thing I like about PolyVox (especially with the new RLE/streaming) is that it is a convenient way to sparsely store any kind of data in a huge array. I could imagine all kinds of uses that aren't related to mesh extraction / voxel rendering.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Theme created StylerBB.net