It is currently Mon Dec 09, 2019 5:03 pm


All times are UTC




Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: Non-cubic shapes
PostPosted: Sun Jun 07, 2015 6:53 pm 

Joined: Wed May 20, 2015 9:27 pm
Posts: 7
Hi

Is there a way to implement non-cubic shapes. Like vertical/horizontal half cubes, pyramids. I want to smooth out the environment but still have the bulky style and more importantly I need to be able to control the shape so I don't think marching cubes will be suitable for that(?).

Thanks


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Non-cubic shapes
PostPosted: Mon Jun 08, 2015 8:33 am 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
You have to write your own Surface Extractor. And your own voxel type.

I am already doing something similar for Crafterria, but the task is not so trivial.
Welcome to the world of Meshing, Math and voxels.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Non-cubic shapes
PostPosted: Mon Jun 08, 2015 11:00 am 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
I am inclined to agree with petersvp, but I'd be curious if you have any screenshots or images of games with a similar style to what you are trying to create. Creating your own voxel type is pretty easy as PolyVox is templatised, while creating you own surface extractor is as difficult as your requirements :-)


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Non-cubic shapes
PostPosted: Mon Jun 08, 2015 11:59 am 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
Okay, more helpful now.

My approach that is under development, is based on shape extrusion and hidden face removal. I have basic shapes, like rect, triangle and so on, that I extrude, and then remove unneeded faces.

For perfect culled geometry a step that calculates unions and intersections in nessesary. Boost::geometry helps here but is 2D only, so this is complication on itself. also, in order to generate volume geometry like this, cashing intersrection geometry is a must, and the amount of memory may also become bottleneck.

You must also consider shape rotations, but this can be trivial - you just generate primitives for each needed rotated state.

Anyways, the topic is complicated and requires research. Probbly, there is not ready-made solution made public or at least i am unaware of such if it exists.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Non-cubic shapes
PostPosted: Mon Jun 08, 2015 12:20 pm 

Joined: Wed May 20, 2015 9:27 pm
Posts: 7
Something like this https://www.planets-cube.com/gallery/screenshots/

I was thinking of something like setting the type of the shape (half-cube right, half-cube left, pyramid, etc...) as voxel data, and since the cubes are axis aligned, in the vertex shader I would move the vertices at x+-0.5, y+-0.5,z+-0.5 according to the type or if I want to use the mesh in physics I would do that on the CPU.

But that will cause issues in visibility of the hidden cubes since the cubic mesh extractor already thinks that the cube is a full cube and already hidden the cube behind it. Also I think that Polyvox joins contiguous polygons(?).


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Non-cubic shapes
PostPosted: Mon Jun 08, 2015 12:24 pm 

Joined: Wed May 20, 2015 9:27 pm
Posts: 7
Thanks petersvp


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Non-cubic shapes
PostPosted: Mon Jun 08, 2015 1:16 pm 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
My voxel data have a color, material type and a geometry ID or a density value.
First pass uses marching cubes on voxels marked as earth terrain, and the second pass uses the shapes data mapped to the Geometry ID.

You basically have a int that corresponds to a lookup table with shapes.

The data structure is: In-square polygons that are always rendered, and the 6 faces only polygons, that can either be rendered or not rendered, bsed on surrounding blocks. And a map of two neighbouring geometry IDs and their intersection geometries. I only process blocks if at least one of its 6 neighbour blocks is air. For blocks that are sorrounded by other blocks,I don't render anything.

When this algorithm is ready, I may post portions of its source code that may be of use of everyone.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Non-cubic shapes
PostPosted: Mon Jun 08, 2015 9:14 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
kariem2k wrote:


To be honest it's not that different from what the Marching Cubes algorithm will give you if you apply flat shading and clamp the voxel values to always be the min/max. Marching cubes doesn't have to be smooth.

Here's the BasicExample from PolyVoc, adjusted to run Marching Cubes instead of the cubic surface extractor:

Image

kariem2k wrote:
Also I think that PolyVox joins contiguous polygons(?).


That's really a property of the surface extractor. The Marching Cubes implementation does indeed share vertices between triangles which makes flat shading slightly more tricky, but you can still do it by computing normals in the fragment shader.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Non-cubic shapes
PostPosted: Mon Jun 08, 2015 9:38 pm 

Joined: Wed May 20, 2015 9:27 pm
Posts: 7
David Williams wrote:
kariem2k wrote:


To be honest it's not that different from what the Marching Cubes algorithm will give you if you apply flat shading and clamp the voxel values to always be the min/max. Marching cubes doesn't have to be smooth.

Here's the BasicExample from PolyVoc, adjusted to run Marching Cubes instead of the cubic surface extractor:

Image

kariem2k wrote:
Also I think that PolyVox joins contiguous polygons(?).


That's really a property of the surface extractor. The Marching Cubes implementation does indeed share vertices between triangles which makes flat shading slightly more tricky, but you can still do it by computing normals in the fragment shader.

Great idea I did not think of flat shading.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: Non-cubic shapes
PostPosted: Tue Jun 09, 2015 10:59 am 

Joined: Tue Apr 08, 2014 5:10 pm
Posts: 124
However, Marching Cubes alone cannot give the exact geometry Planets3 uses, but still you can do interesting non-smooth stuff with it.


Top
Offline Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 11 posts ]  Go to page 1, 2  Next

All times are UTC


Who is online

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