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


All times are UTC




Post new topic Reply to topic  [ 128 posts ]  Go to page Previous  1, 2, 3, 4, 5, 6, 7 ... 13  Next
Author Message
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Tue Jan 24, 2012 5:55 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
David Williams wrote:
Try extracting a mesh which is smaller than the whole volume. It could be that the problem is coming from handling the edge cases, which are always more complex. Instead of:

Code:
PolyVox::SurfaceExtractor<SimpleVolume, Density8> suf(&volData, volData.getEnclosingRegion(), &mesh);


try (untested code):

Code:
Region reducedRegion = volData.getEnclosingRegion();
reducedRegion.shiftLowerCorner(Vector3DInt32(2,2,2));
reducedRegion.shiftUpperCorner(Vector3DInt32(-2,-2,-2));
PolyVox::SurfaceExtractor<SimpleVolume, Density8> suf(&volData, reducedRegion, &mesh);


and see if the assert goes away.


I tried your code and the assert goes away. But something strange I notice is that the size of the terrain is still about the same, but the faces are missing on the outside of the mesh and ok on the top of the mesh. What should I do now?


Last edited by drwbns on Tue Jan 24, 2012 6:43 pm, edited 1 time in total.

Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Tue Jan 24, 2012 6:08 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
David Williams wrote:
Also, you specifcally mention a size of 513x513... whereas a power of two would be more usual (e.g. 512x512). Perhaps there is some issue here.


I was following some ideas that image sizes should be power of 2 + 1 - plus the image I'm using came with Ogre. Maybe I should resize it to a power of 2 and see if it works correctly. I still have the problem also where I'm only getting 2 dimensions correct, the 3rd dimension is just repeated across the plane.
http://www.ogre3d.org/tikiwiki/Ogre+Terrain+Component+FAQ#So_if_I_have_a_height_map_of_size_512_x_1024_and_I_want_a_terrain_that_matches_it_in_world_units_512_wide_by_1024_deep_I_d_need_to_create_multiple_pages_and_put_them_together_pages_of_size_512_What_about_a_narrow_terrain_level_that_was_1000_x_300_


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Tue Jan 24, 2012 7:15 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
David Williams wrote:
Also, you specifcally mention a size of 513x513... whereas a power of two would be more usual (e.g. 512x512). Perhaps there is some issue here.


Switching to a terrain image of 512 x 512 still has the same assert in debug mode.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Wed Jan 25, 2012 9:56 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
drwbns wrote:
But something strange I notice is that the size of the terrain is still about the same, but the faces are missing on the outside of the mesh and ok on the top of the mesh.


Yes, this is what I would have expected. Triangles are only generated when the extractor finds solid voxels next to empty ones. In your case you have solid voxels inside the volume and empty voxels outside - that is, the change beteen solid and empty occurs at the edge of the volume. But because my suggested change stopped it processing these edge cases you no longer see those triangles.

However, having looked at the code I now realise what is really going on. Basically, the assert you are hitting is making sure that there are no more than 1000000 vertices in the generated mesh. This is a hardcoded value which should not be there, and I will change this assert for the next release of PolyVox.

In the mean time, I believe you can sefely just comment out the relevant asserts in SurfaceExtractor.inl

Code:
assert(ind0 < 1000000);
assert(ind1 < 1000000);
assert(ind2 < 1000000);


drwbns wrote:
I still have the problem also where I'm only getting 2 dimensions correct, the 3rd dimension is just repeated across the plane.


I think the problem is the way you are reading your heightmap:

Code:
int height = myTerrainHM.getColourAt(x,y,0);


In my original code I use x and z rather than x and y. Try:

Code:
int height = myTerrainHM.getColourAt(x,z,0);


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Wed Jan 25, 2012 1:56 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
Cool, that fixed everything so far - I haven't tested the decimation yet though. Here's a screenshot of the output -


Attachments:
screenshot01252012.gif
screenshot01252012.gif [ 224.34 KiB | Viewed 3397 times ]
Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Wed Jan 25, 2012 2:11 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
I tried to use a low pass filter like so -

Code:
   // Extract the surface
   PolyVox::SurfaceExtractor<SimpleVolume, Density8> suf(&volData, volData.getEnclosingRegion(), &mesh);
   suf.execute();

   // Smooth using a lowpassfilter
   Region fullRegion = volData.getEnclosingRegion();
   SimpleVolume<Density8> resultVolume(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(myTerrainHM.getWidth(),256,myTerrainHM.getHeight())));

   LowPassFilter<SimpleVolume, SimpleVolume, Density8> pass1(&volData, fullRegion, &resultVolume, fullRegion, 5);

   pass1.execute();


but got an access violation in LowPassFilter.inl @ line 84


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Wed Jan 25, 2012 2:49 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
And a side note - decimation seems to be working fine :)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Thu Jan 26, 2012 9:27 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I'm going to suggest reducing the size of the region again, to avoid the edge cases. Smoothing the volume data involves averaging each voxel with it's neighbours and the voxels on the edge don't actually have some neighbours. The code should handle this but probably doesn't at the moment. Try

Code:
Region fullRegion = volData.getEnclosingRegion();
fullRegion.shiftLowerCorner(Vector3DInt32(2,2,2));
fullRegion.shiftUpperCorner(Vector3DInt32(-2,-2,-2));


Also, your code snippet is smoothing the data after you have already extracted the mesh. This won't have the desired effect - you need to smooth and then extract.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Thu Jan 26, 2012 6:32 pm 

Joined: Wed Jan 11, 2012 7:33 pm
Posts: 109
Ok I tried changing the code, with no effect - same crash in LowPassFilter.inl

Code:
   Region fullRegion = volData.getEnclosingRegion();
   fullRegion.shiftLowerCorner(Vector3DInt32(2,2,2));
   fullRegion.shiftUpperCorner(Vector3DInt32(-2,-2,-2));

   SimpleVolume<Density8> resultVolume(PolyVox::Region(Vector3DInt32(0,0,0), Vector3DInt32(myTerrainHM.getWidth(),256,myTerrainHM.getHeight())));

   Region fullRegion2 = resultVolume.getEnclosingRegion();
   fullRegion2.shiftLowerCorner(Vector3DInt32(2,2,2));
   fullRegion2.shiftUpperCorner(Vector3DInt32(-2,-2,-2));

   LowPassFilter<SimpleVolume, SimpleVolume, Density8> pass1(&volData, fullRegion, &resultVolume, fullRegion2, 5);

   pass1.execute();


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Realtime Ogre 1.8 Terrain Component manipulation
PostPosted: Fri Jan 27, 2012 9:13 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
Notice that the region gets passed twice when creating the low pass filter and you've only changed one of them. I.e. you have:

Code:
LowPassFilter<SimpleVolume, SimpleVolume, Density8> pass1(&volData, fullRegion, &resultVolume, fullRegion2, 5);


You should try:

Code:
LowPassFilter<SimpleVolume, SimpleVolume, Density8> pass1(&volData, fullRegion2, &resultVolume, fullRegion2, 5);


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

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] 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