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