It is currently Sat Aug 22, 2020 1:35 pm


All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: CustomMeshExtractor idea
PostPosted: Sun Jul 22, 2012 3:15 pm 

Joined: Wed Apr 27, 2011 7:10 am
Posts: 43
I might be rehashing this idea, if so sorry.

CustomMeshExtractor
You create the CustomMeshExtractor, then register material ids with it. Each material id is registered with a corresponding voxel-sized mesh. Then the extractor will run through the volume and append the vertices and indices at the voxel locations. This seems like a simple useful feature to add on. I discussed this with Xelons on IRC a while back.


Full conversation.
Code:
<Xelons> I was trying to implement grass into my terrain, I spent some time experimenting
<Xelons> First method was to create a mesh with the grass material
<Xelons> then load that mesh into the terrain
<realzies> I suppose you can do it the minecraft way
<Xelons> the second method witch I think is better
<Xelons> is to make grass using voxels
<realzies> they'd have to be tiny voxels
<Xelons> hmm
<realzies> er
<Xelons> what about creating a new volume with a transparent material
<realzies> I assumed you meant to make tiny voxels and make grass outta them
<Xelons> And assign texture grass to it
<realzies> minecraft puts a criss-cross blade
<realzies> and you can texture it,
<realzies> so it uses a semi transparent picture of grass
<Xelons> that criss-cross thingy is it a mesh?
<realzies> basically
<realzies> its a custom rendering of a voxel
<realzies> not a box
<Xelons> oh
<realzies> I suppose PolyVox would benefit from such a thing
<realzies> a torch is similar too
<realzies> its a criss cross blade IIRC
<realzies> and semi transparent textures are used on them
<Xelons> My version of grass is a criss-cross as well
<Xelons> saved into a mesh
<realzies> right
<realzies> well it would be nice feature for polyvox to allow you to specify voxel-meshes
<realzies> for particular materials
<Xelons> yeah thats for sure
<realzies> so instead of default cube, you can customize voxels
<realzies> that wouldn't be too difficult a feature, I think
<Xelons> Im still scratching my head trying to find a simple way to implement meshes like object into my game easily
<realzies> hmm
<realzies> a post process
<realzies> after polyvox produces a mesh,
<realzies> run your own CustomMeshExtractor, which will just add to the vertex/index buffers
<realzies> it will find its custom materials (which polyvox will ignore), and use their assigned meshes
<realzies> this would be a good addition to polyvox too
<Xelons> Oh you mean directly draw it in real time?
<realzies> make sense?
<realzies> nono
<realzies> the CubicExtractor produces a vector of vertices and a vector of indices
<realzies> right?
<Xelons> right
<realzies> a SurfaceMesh or w/e
<realzies> so after running the CubicExtractor
<realzies> you run a "CustomMeshExtractor"
<realzies> which will add on to the SurfaceMesh
<realzies> you register materials => custom mini meshes
<realzies> and it will find each voxel with that material and append the mini meshes to SurfaceMesh
<realzies> does this make any sense ?
<Xelons> hmm wouldn't the new custommeshextractor be producing voxels as well?
<realzies> but not solid ones
<Xelons> but with different material
<realzies> not necessarily I should say
<realzies> er
<realzies> it wouldn't be "producing" voxels
<realzies> it will read voxels, and produce meshes
<realzies> just like CubicExtractor does
<Xelons> yeah
<Xelons> right
<Xelons> so instead of producing solid mesh it will be a transparent one depending on the new material
<realzies> no
<realzies> instead of producing a "cube", it will produce whatever you register with it
<realzies> it will be a material => mesh
<realzies> er
<Xelons> Oh yeah got it
<realzies> "voxel material" => mesh
<realzies> now transparency is just a matter of the texture
<realzies> and your shader
<Xelons> Now polyvox has 2 mesh extractors, I need to make a third one to extract custom meshes right?
<realzies> basically
<realzies> this is one way
<realzies> it would be a nice feature
<Xelons> Yes
<Xelons> It would also help with fluids
<realzies> yes, I suppose it would
<realzies> its a great all around custom solution
<realzies> though,
<realzies> with special purpose meshes, you could do some smarter handling, like decimation
<realzies> but that is an optimization
<realzies> some meshes can do decimation, some can't
<realzies> the CustomMeshExtractor would be a general, non-decimating extractor
<Xelons> Right
<realzies> it should be easy, straightforward, and useful
<realzies> I am half in the mood of doing it myself :P
<Xelons> Lol go for it
<realzies> hehe
<realzies> well, if you are willing to wait a few weeks ...
<realzies> I might
<Xelons> :D
<Xelons> Oh there is also one more thing, now let's say my extracted meshes using the cubic extractor have a scale of 1.0f, it wouldn't be possible to control individual voxel's scale without changing the whole mesh right?
<realzies> thats definitely possible
<realzies> in fact, you might define that the scale of the mesh should be [0,1]
<realzies> and adjust it as needed
<realzies> this is where a matrix can help
<realzies> a matrix4x4 defines scale/rotation/translation
<realzies> so you can have any scale mesh, + a matrix
<realzies> oh
<realzies> you mean individual voxel scale?
<realzies> I suppose that is possible too
<Xelons> yeah
<realzies> that would require more logic in the extractor
<realzies> to somehow determine each voxels scale
<Xelons> It would require a custom extractor right?
<realzies> well, a custom mesh requires a custom extractor
<realzies> so you would just need to put in some scaling logic
<Xelons> I think that would be easier for the grass idea
<realzies> how so?
<Xelons> smaller voxels resolution to draw a precise grass and then the rest of the mesh(terrain) is in normal voxels scale
<realzies> eww
<realzies> thats what you mean
<realzies> thats gonna be a lotta work
<Xelons> :(
<realzies> best to predefine a buncha "grass meshes" beforehand
<realzies> you can make those meshes by extracting *them* from their own "mini volume" worlds
<Xelons> Oh you mean the drawing process?
<realzies> no drawing
<realzies> I am talking of SurfaceMeshes only
<Xelons> oh
<Xelons> i see
<realzies> ie. a Custom Mesh for the CustomSurfaceExtractor we were talking about before
<realzies> if you want them to look like voxels, you can pre-extract them from another volume beforhand
<Xelons> Yeah if I want them to look like voxels
<Xelons> wouldn't it be easier work
<Xelons> All I need to do is create a custom extractor to control every voxel scale alone
<Xelons> So i can mix different voxels scales in the same mesh
<realzies> dunno, that hurts my head
<realzies> would be mighty hard IMO
<Xelons> Lol
<Xelons> Take a look at this pic http://twitter.com/wol_lay/status/182110678881013762/photo/1/large
<Xelons> He use different voxels scales into the same mesh, the bigger voxels are used for the terrain etc, while the smaller voxels are using to grass, flowers...
<realzies> its prolly extracted in different volumes
<realzies> voxels are a grid
<realzies> its impossible to have multi resolutions in the same grid
<realzies> they just don't fit
<Xelons> hmm
<realzies> a lot of the grass looks the same
<realzies> he prolly did exactly what I suggested
<realzies> pre-extracted a bunch of grass shapes
<realzies> then used that in a "custom mesh extractor"
<Xelons> yeah probably
<Xelons> That custom mesh extractor is a must have
<Xelons> Its probably the most efficient way to have so many meshes loaded easily
<realzies> ofc, its all in one batch
<realzies> the only more efficient way might be instancing
<realzies> I dunno
<realzies> never used instancing
<Xelons> I tried using it but it wasn't whats I expected
<Xelons> It doesn't work with randomly placed meshes


_________________
irc://irc.freenode.net/#polyvox


Top
Offline Profile  
Reply with quote  
 Post subject: Re: CustomMeshExtractor idea
PostPosted: Mon Jul 23, 2012 6:56 pm 
Developer
User avatar

Joined: Sun May 04, 2008 6:35 pm
Posts: 1827
This sounds interesting, and quite straightforward to implement. However, I think it probably has some overlap with the work Freakazo is doing at the moment. The 'CubicSurfacePointExtractor' (we can change the name if need be) basically iterates over the volume and adds a single vertex for each voxel which lies between solid material and empty space. The idea is that you can then use some instancing technique to place a mesh at each position.

This isn't the same as what you are describing, but I think it could be generalised. Instead of adding a vertex for each relevant voxel it could instead call a callback. The default callback could just output the single vertex (which is what Freakazo is doing at the moment) but the user could override this with some custom behaviour. Would that let you achive what you are describing?


Top
Offline Profile  
Reply with quote  
 Post subject: Re: CustomMeshExtractor idea
PostPosted: Tue Jul 24, 2012 3:09 am 

Joined: Sat Dec 18, 2010 2:58 am
Posts: 41
Yes this sounds very similar to what I'm doing. I am still currently working on it but it's very close to being completed.

I still need to have it output a SurfaceMesh with both vertex and material information and implement callbacks so that transparent objects can be used.

I did not originally intend for the point extractor to be used like that, but it will definitely work for instancing grass for example. However with things like torch lights, orientation will be very important, so my point extractor and instancing won't work in that case.

[edit] Although you could use a different material for each different orientation.


Top
Offline Profile  
Reply with quote  
 Post subject: Re: CustomMeshExtractor idea
PostPosted: Fri Jul 27, 2012 1:04 am 

Joined: Tue Mar 08, 2011 3:57 am
Posts: 46
Hrm. I'm attempting a similar thing whereby I'm using prefab models/meshes to create the volume shell. However the way I'm doing it right now is that I iterate over the volume and for any voxel that will be shown I generate an 'index' based on its neighbors. I look up that index value in an XML file that contains information on what models to load, their rotation, etc. Then I paint the model based on masks and what material its neighbors are to successfully blend between for example a grass patch and a dirt patch.


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

All times are UTC


Who is online

Users browsing this forum: No registered users and 1 guest


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