It is currently Sat Aug 22, 2020 3:53 pm


All times are UTC




Post new topic Reply to topic  [ 67 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next
Author Message
 Post subject: Re: 3D surface reconstruction for volumetric voxel data
PostPosted: Tue Feb 24, 2009 5:31 pm 

Joined: Sun Feb 01, 2009 3:18 pm
Posts: 34
Quote:
It's true that PolyVox is pretty memory hungry but you should be able to do 256^3 without a problem. That is the size of the castle volume used in the Thermite demo. I assume that at this point the original 668x668x469 volume is no longer in memory? You only have the PolyVox volume and the resulting mesh in memory?


My problem is that I should load 256 ^ 3 voxel into memory for collision detection. Then I reduced it to some amount by not loading the voxel with 0 density. In addition to that I have to use polyvox for rendering the model plus one another model rendered using terrain.

Quote:
I will look at both of these as I get time...

Thanks for your concern. I will look forward to it.

Quote:
Yes, I believe you can use gemetry shaders. All PolyVox does is give you the mesh data, how you render it is up to you. I have no experience here though, so your on your own! Hopefully there are some tutorials around on using geometry shaders with OpenGL.


Yeah it is true that I can not expect you fix everything.. I started to work on it and I have found some resources. If I get more smoother surface > I will share the idea with you.
I also need to think about real time modification ... that is more important than smoothing further.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: 3D surface reconstruction for volumetric voxel data
PostPosted: Wed Feb 25, 2009 11:31 am 

Joined: Sun Feb 01, 2009 3:18 pm
Posts: 34
Further I tried to do real time modification of data > surface.

My problem is when I tried to call "extractReferenceSurface" for the regions modified ( may vary), graphics loop gets slow down terribly.

What I think of doing is to have
- Main thread
- Graphic Thread
- Worker Thread

Worker Thread can take the modified data information from Main thread and construct the surfaces for the modified regions and pass the vertex and normal information for the modified region to graphic loop.

But I lack idea in multi-threading in C++ . Do you know how I could do this?
Could you guide me how I can speed up the process so that I could see the real time modification to the surface?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: 3D surface reconstruction for volumetric voxel data
PostPosted: Wed Feb 25, 2009 9:04 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Gajananan wrote:
My problem is that I should load 256 ^ 3 voxel into memory for collision detection. Then I reduced it to some amount by not loading the voxel with 0 density. In addition to that I have to use polyvox for rendering the model plus one another model rendered using terrain.


Hmmm... I see. Is it not possible to use the PolyVox volume for collision detection as well? You have access to the individual voxels, but maybe you need more than that?

But actually I suspect the size of the meshes is as much of a problem as the volume. A quick check of the SurfaceVertex class indcates that it is 28 bytes, which is a lot when there are millions of them. I will try to improve on this.

Also, you should realise that the way I use OpenGL in the PolyVox demo is the most simple way, but not the most efficient. The meshes are being stored in main memory, and all the vertices are sent to the graphics card every frame via the calls to glVertex3f(...).

It would be much better to transfer the meshes into graphics memory. Then you wouldn't have to transfer them every frame, and you should also be able to free up the main memory you were using. I'm not sure how you do this in OpenGL, but I think you should look into 'Vertex Buffer Ojects'.

As for your problems with the modification, I don't think you should use threading yet as this will likely make things more complicated. The Thermite castle demo updates a 256^3 volume in real time with no problems, so your application should be able to do the same. There was no example of how do do the modification, so it's quite likely you not doing it in quite the right way. Can you describe the approach you are using?

One thing to remeber is that PolyVox breaks the volume down into regions, and you can generate the region for each mesh seperatly. When a single voxel changes you only need to update the mesh for that region. You can keep track of which regions changed, or you might find there is a class called VolumeChangeTracker which will help you or at least give ideas...

Also, as the OpenGL demo doesn't demonstrate modification, you might find it useful to look in the Thermite source code.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: 3D surface reconstruction for volumetric voxel data
PostPosted: Thu Feb 26, 2009 6:17 am 

Joined: Sun Feb 01, 2009 3:18 pm
Posts: 34
Quote:
Hmmm... I see. Is it not possible to use the PolyVox volume for collision detection as well? You have access to the individual voxels, but maybe you need more than that?


That is a nice idea..I have to access individual voxel (X,Y,Z position and density value). Nothing much.

Quote:
But actually I suspect the size of the meshes is as much of a problem as the volume. A quick check of the SurfaceVertex class indcates that it is 28 bytes, which is a lot when there are millions of them. I will try to improve on this

I will be glad to see the improvement in Polyvox memory usage since it will help me in my task. I will look forward to it.

Quote:
Also, you should realise that the way I use OpenGL in the PolyVox demo is the most simple way, but not the most efficient. The meshes are being stored in main memory, and all the vertices are sent to the graphics card every frame via the calls to glVertex3f(...).

I actually I am using the same technique :all the vertices are sent to the graphics card every frame via the calls to glVertex3f

Quote:
I think you should look into 'Vertex Buffer Objects'.

I did not know this before , I will look into this as well. Thanks for your guidance.

Quote:
I don't think you should use threading yet as this will likely make things more complicated.

I was able to try that idea. Modification is possible but ... damn slow :(

Quote:
. The Thermite castle demo updates a 256^3 volume in real time with no problems, so your application should be able to do the same. There was no example of how do do the modification, so it's quite likely you not doing it in quite the right way. Can you describe the approach you are using?

From this , I can really understand that I am not doing in the right way.. which I could possibly able to do.
In the Main loop.. I will be modifying the voxels (make density 0) , I keep track of these voxel (position info) in 'vector' in the main loop.The I transfer the vector (vector - thread safe). In the graphic loop, I access the vector and loop through it and check which voxels are modified then based on the position I can find which regions as modified. Then run Polyvox::extractReferenceSurface for each region.
Main problem is there may be multiple voxels in the same region. Currently I could not avoid calling extractReferenceSurface multiple times for each region.
Here I have a question:
If I use the PolyVox volume, then in the main loop I can simply use setVoxel() to make changes in PolyVox volume, Is it possible to set which regions are modified using VolumeChangeTracker?
since you wrote :
Quote:
You can keep track of which regions changed


I just noticed that you had a method 'void markRegionChanged(uint16 firstX, uint16 firstY, uint16 firstZ, uint16 lastX, uint16 lastY, uint16 lastZ);'
in VolumeChangeTracker.h But it is commented out. no implementation found.

Latest update : I have tried to use polyvox volume... but problem is still :
"calling extractReferenceSurface multiple times for each region." This cause very slow graphic loop. but memory consumption is lowered hugely.

I think if i can avoid it .. then graphic loop will improve... I can further improve it with Vertex Buffer Objects.


Quote:
Also, as the OpenGL demo doesn't demonstrate modification, you might find it useful to look in the Thermite source code.

I will look into it.

I have seen how volume modification is done in my case, but it is now slow.. it is really encouraging the way you answer my questions and provide enough information to look for and fixing problems in Polyvox. I am really thankful to you. I will really acknowledge your support in my final outcome and spread the message how Polyvox is useful.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: 3D surface reconstruction for volumetric voxel data
PostPosted: Thu Feb 26, 2009 10:45 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Gajananan wrote:
I actually I am using the same technique :all the vertices are sent to the graphics card every frame via the calls to glVertex3f


That will be ok for a small number of triangles (maybe from volumes of 128^3) but if you get much larger you will find it becomes very slow. Even if you you are not modifying the data, using this approach it will be sending all the triangles to the graphics card every frame.

Gajananan wrote:
In the graphic loop, I access the vector and loop through it and check which voxels are modified then based on the position I can find which regions as modified. Then run Polyvox::extractReferenceSurface for each region.
Main problem is there may be multiple voxels in the same region. Currently I could not avoid calling extractReferenceSurface multiple times for each region.


I'm pretty sure this is you main performance problem, but fortunately it is fairly simple to address. Consider you have a volume of 256^3, which is broken into regions of 32^3. In this case the number of regions is 8^3. You can create a simple array of bools to keep track of whether a region is up to date. Something like:

Code:
bool upToDate[8][8][8];


After you run extractReferenceSurface() on a particular region you can also set the value to 'true' in that array. After you modify a voxel you set the flag for it's corresponding region to false (and maybe it is already false, if you have already modified a voxel in that region but not regenerated the mesh yet). Does that make sense?

Gajananan wrote:
Here I have a question:
If I use the PolyVox volume, then in the main loop I can simply use setVoxel() to make changes in PolyVox volume, Is it possible to set which regions are modified using VolumeChangeTracker?


The VolumeChangeTracker is based on a similar principle to above. But instead of storing bools, it stores a integer representing the timestamp of the last time a region was modified. I also store a timestamp in meshes in Thermite, and I compare these each frame to see what needs updating. It's a little messy though as I never really decided exactly how it should work. So you might want to just use a simple array like I showed above.

Gajananan wrote:
I have seen how volume modification is done in my case, but it is now slow.. it is really encouraging the way you answer my questions and provide enough information to look for and fixing problems in Polyvox. I am really thankful to you. I will really acknowledge your support in my final outcome and spread the message how Polyvox is useful.


I'm happy to help :-) Your one of the first users of the library so it is good to get feedback and see how well it meets people's needs!


Top
Offline Profile  
Reply with quote  
 Post subject: Re: 3D surface reconstruction for volumetric voxel data
PostPosted: Fri Feb 27, 2009 12:54 am 

Joined: Sun Feb 01, 2009 3:18 pm
Posts: 34
Quote:
You can create a simple array of bools to keep track of whether a region is up to date.

Excellent idea :D ...... it works superbly even for 256 ^ 3.....I can not believe myself...I am almost done with it. this was only possible because of your help and continuous guidance

I will talk about this with my adviser and get back to you.

Apart from getting a good shape of 256 ^ 3 model ( that is my problem...)

Quote:
I'm happy to help :-) Your one of the first users of the library so it is good to get feedback and see how well it meets people's needs!

I really wonder how people have missed ;) a tool that does wonders ! as you say I am one of the first users :) .

P.S Currently I would say ... only thing still I consider as a limitation is that it supports the data in the power of 2...


Top
Offline Profile  
Reply with quote  
 Post subject: Re: 3D surface reconstruction for volumetric voxel data
PostPosted: Fri Feb 27, 2009 8:19 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Gajananan wrote:
Excellent idea :D ...... it works superbly even for 256 ^ 3.....I can not believe myself...I am almost done with it. this was only possible because of your help and continuous guidance

I will talk about this with my adviser and get back to you.

Apart from getting a good shape of 256 ^ 3 model ( that is my problem...)

Well it should be possible to smooth the normals even further by taking the average normals of several neighbouring voxels. But I'm worried that if it gets too smooth you might start to lose surface detail. At the moment you are on a 256^3 model - are you intending to go higher? I don't think the loss of details wouldn't be such a problem at higher resolutions.
Gajananan wrote:
P.S Currently I would say ... only thing still I consider as a limitation is that it supports the data in the power of 2...

That is a limitation, but I think it will stay for the time being. You see, having the regions and volumes be powers of two makes certain maths operations faster. For example, I guess you have already seen that you can calculate the region which a voxel is in by dividing the voxel position by the region width? Well because the numbers are integers, and the divisor is a power of two, you can actiually replace this by a faster bitshift. So instead of:
Code:
int currentRegionX = voxelX / 32;

You can say:
Code:
int currentRegionX = voxelX >> 5;


Top
Offline Profile  
Reply with quote  
 Post subject: Re: 3D surface reconstruction for volumetric voxel data
PostPosted: Fri Feb 27, 2009 4:07 pm 
Developer
User avatar

Joined: Sun May 11, 2008 4:29 pm
Posts: 198
Location: UK
David Williams wrote:
Gajananan wrote:
P.S Currently I would say ... only thing still I consider as a limitation is that it supports the data in the power of 2...

That is a limitation, but I think it will stay for the time being. You see, having the regions and volumes be powers of two makes certain maths operations faster.

Would it not be possible to simply pad out the volume to make it equal to a power of two?

_________________
Matt Williams
Linux/CMake guy


Top
Offline Profile  
Reply with quote  
 Post subject: Re: 3D surface reconstruction for volumetric voxel data
PostPosted: Fri Feb 27, 2009 6:38 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
milliams wrote:
Would it not be possible to simply pad out the volume to make it equal to a power of two?


Yep, that is quite possible. At the moment it's probably a little wasteful of memory, but once I implement data compression for the volumes it will be a pretty small overhead. A large contiguous range of zero's should compress down very well indeed.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: 3D surface reconstruction for volumetric voxel data
PostPosted: Sat Feb 28, 2009 12:16 am 

Joined: Sun Feb 01, 2009 3:18 pm
Posts: 34
Mat Williams wrote:
Would it not be possible to simply pad out the volume to make it equal to a power of two?


let say I have a data of 180 ^ 220 ^ 200 size I am not sure how we can pad out the volume to make it equal to a power of two in a raw file? I will try to find a way!
I want to first have a the complete shape of the model. Then think about memory..

David Williams wrote:
Well it should be possible to smooth the normals even further by taking the average normals of several neighbouring voxels. But I'm worried that if it gets too smooth you might start to lose surface detail. At the moment you are on a 256^3 model - are you intending to go higher?

I would like to try and see how it behaves if I smooth... I have tried to render 128 ^ 3 for now..that works fine.. I will get 256 ^ 3 working first.

I could go for 512 ^ 3 since PolyVox support faster rendering and I am using Polyvox volume for CD as well and I have data 668 ^ 668 ^ 469 given that I have an idea of padding up.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 67 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7  Next

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 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