It is currently Sat Aug 22, 2020 4:26 am


All times are UTC




Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Using Polyvox with Unreal Engine 4
PostPosted: Mon Feb 09, 2015 3:53 am 

Joined: Wed Feb 04, 2015 4:26 pm
Posts: 7
Hi All,

I am working on a project where I need real time terrain deformation. I am trying to integrate Polyvox into Unreal engine 4. I did get the marching cubes algorithm to run and I divided my volume into smaller chunks of 16x16x16 units each. The mesh is being rendered on screen, However I am struggling with few issues here:

1) I can't quite seem to get the chunks to overlap, could some one help me in blending the chunks together.

2) For some reason, the mesh is visible only from one direction, I am not able to see the mesh from the bottom. Am I missing something here?

Could someone please help me with this?


Attachments:
UE4Mesh.png
UE4Mesh.png [ 187.44 KiB | Viewed 6623 times ]
Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Mon Feb 09, 2015 10:32 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
maheshvele wrote:
...I divided my volume into smaller chunks of 16x16x16 units each...


Do you mean you actually have multiple volumes? This is not a good approach - you should have a single larger volume but run the marching cubes algorithm multiple times (once on each region of it).

maheshvele wrote:
1) I can't quite seem to get the chunks to overlap, could some one help me in blending the chunks together.


You need to make sure that the regions touch when you call the surface extractor. So if the first region covers the range 0 to 16, the next should cover 16 to 32. Note that the number '16' then appears twice (it is in both regions). I expect that at the moment you are doing 0 to 16 and then 17 to 32?

maheshvele wrote:
2) For some reason, the mesh is visible only from one direction, I am not able to see the mesh from the bottom. Am I missing something here?


You mean back-face culling is enabled, or that certain triangles are not being generated? If back-face culling then this is something you will have to change inside UE4.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Mon Feb 09, 2015 1:26 pm 

Joined: Wed Feb 04, 2015 4:26 pm
Posts: 7
Hi David,

Thanks a lot for the reply. I am currently using multiple SimpleVolumes. When you say run marching cubes algorithm on each chunk, is it because there would be a huge performance impact on creating many SimpleVolumes? Should I be using a single LargeVolume ?

Currently I am using the resampling method for the LOD, is this the only way of changing the LOD? I am using a voxel unit of one and all my vertices are calculated based on this, is there a way of making the voxel units bigger before we run the Marching cubes algorithm?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Mon Feb 09, 2015 4:02 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
maheshvele wrote:
...is it because there would be a huge performance impact on creating many SimpleVolumes?


It mostly because marching cubes does not run in individual voxels but on sets of eight voxels forming cells. This means that access to a voxel's neighbours is required, which gets a little compelx on the edge of volumes. Have a read here:

http://www.volumesoffun.com/polyvox/doc ... aller-ones

maheshvele wrote:
Should I be using a single LargeVolume ?


Start with using a single SimpleVolume as it is easier/faster, and move to LargeVolume (now changed to PagedVolume) when everything is working. Even a SimpleVolume can hold hundreds of millions of voxels and you'll proably hit problems with the amount of mesh data first.

maheshvele wrote:
Currently I am using the resampling method for the LOD, is this the only way of changing the LOD?


Basically yes. PolyVox has no concept of LOD but it is possible to achieve it by resampling the volume data instead. Consider this a fairly advanced technique though - we're still researching it in Cubiquity.

You can also try applying traditional mesh decimation techniques to the mesh. We used to have something built into PolyVox for this but it's not present any more.

maheshvele wrote:
is there a way of making the voxel units bigger before we run the Marching cubes algorithm?


No, PolyVox has no concept of the size of a voxel. You can scale the resulting meshes in your engine though.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Mon Feb 09, 2015 4:37 pm 

Joined: Wed Feb 04, 2015 4:26 pm
Posts: 7
Hi David,

Thank you again. I will try do it the way you mentioned.

This might be a complete noob question but I see a huge performance drop when the player comes closer to the generated mesh. I understand that this is because of the high poly mesh, but I have seen people using polyvox with seamless performance. Is it something the engine sprecific or is there some sort of optimization that I can do rendering wise?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Wed Feb 11, 2015 9:32 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
maheshvele wrote:
This might be a complete noob question but I see a huge performance drop when the player comes closer to the generated mesh. I understand that this is because of the high poly mesh, but I have seen people using polyvox with seamless performance. Is it something the engine sprecific or is there some sort of optimization that I can do rendering wise?


It's hard to imagine how this would be related to PolyVox unless you were calling some PolyVox functions every frame? Presumably you just run the extractor once and then pass the result to Unreal? How big are your meshes and how many do you have?

Also, it is strange that it only slows down as you get close to it. If the number of triangles is the problem then it should be slow even when in the distance.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Wed Feb 11, 2015 3:48 pm 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
What shaders do you use? Do you have overdraw issues? When you look straight down and single triangle fills your screen, do you have this lag? When you are near the mesh and look straight up, so no part of the mesh is visible, do you have this lag?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Wed Feb 11, 2015 6:58 pm 

Joined: Wed Feb 04, 2015 4:26 pm
Posts: 7
Quote:
It's hard to imagine how this would be related to PolyVox unless you were calling some PolyVox functions every frame? Presumably you just run the extractor once and then pass the result to Unreal? How big are your meshes and how many do you have?


I am sure its not a polyvox related isssue...I do run the extractor just once. I have 20x20x20 chunks with each chunk containing 16x16x16 voxels. This is another problem. When I try to increase the number of chunks, it takes forever to generate the meshes.

I do not see the lag when I do not look at the mesh. I am pretty sure the lag comes in when I move closer to the mesh.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Thu Feb 12, 2015 2:32 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
maheshvele wrote:
I am sure its not a polyvox related isssue...I do run the extractor just once. I have 20x20x20 chunks with each chunk containing 16x16x16 voxels. This is another problem. When I try to increase the number of chunks, it takes forever to generate the meshes.


You'll need to do some profiling and/or add some timers to really get a handle on performance issues, but I can give you some pointers:

  • 20x20x20 = 8000 meshes will be relatively slow because it is a lot of draw calls for the GPU, which would prefer to render a smaller number of larger meshes. You could consider using 32x32x32 voxel chunks instead.
  • If you do make the chunks larger then they take longer to extract, which makes runtime modification more tricky. 32x32x32 should be ok though, on my system that extracts in about 15ms per chunk.
  • Although my system extracts in about 15ms, it also takes time to upload the data. Working with Unity this is fairly slow, espesially if there are mesh colliders being generated.
  • The usual solution is to limit the view distance (e.g. Minecraft) so that you have a smaller number of mesh chunks. Then you just generate meshes as you get close to them. Other systems may implement LOD, though as mentioned this can be complex. Overall it's good to start small and get everything working properly before trying to scale it up.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Using Polyvox with Unreal Engine 4
PostPosted: Sun Feb 15, 2015 6:40 pm 

Joined: Wed Feb 04, 2015 4:26 pm
Posts: 7
Hi David, thanks a lot for the suggestions.

I made some optimizations and it turns out my scaling was the issue. When I scaled the generated meshes and aligned them correctly everything works fine with good frame rate.

I have a question about the volume chunks, I have seen in the cubiquity videos that the chunks are stored in an oct tree. What is the reason for this? Is it because it is a memory efficient data structure?

Also, when I am using the low pass filter that spans across many volume chunks, I get weird meshes like this
Attachment:
WithLowPassFilter.jpg
WithLowPassFilter.jpg [ 123.81 KiB | Viewed 6559 times ]
. I do not see this when I don't use the low pass filter
Attachment:
WithoutLowPassFilter.jpg
WithoutLowPassFilter.jpg [ 91.14 KiB | Viewed 6559 times ]
. I do not see this issue if the whole mesh is contained in the same volume chunk, I guess I only see these artifacts when the mesh extends across different volumes. I think the low pass filter is trying to put in some mesh data even when the volume is completely filled. Is there something I can do about this?

-Mahesh


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 16 posts ]  Go to page 1, 2  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