Mesh Combiner

Announce new projects or updates of Irrlicht Engine related tools, games, and applications.
Also check the Wiki

Postby serengeor » Sat Apr 23, 2011 8:33 am

What is the license(if any) of this code snippet?

I'd like to use it in my project, as it works really nice, and I don't really want to rewrite it from scratch.

Also I get this little weird 'bug', which I think was mentioned before:
Image

I tried the suggestion to make a bigger value of texture padding(4000), but it made it even more noticeable.

Maybe someones up to fixing this, because I suck at these kind of things :oops:

If no, I guess I'll just have to make it look like a feature :lol:
Working on game: Marrbles (Currently stopped).
User avatar
serengeor
 
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Postby serengeor » Mon Apr 25, 2011 6:32 pm

I've just fixed memory leaks that occurred when batching nodes, though the texture thing is still there. Also I only left only one combining function there:
Code: Select all
irr::scene::IMesh* combineMeshes(irr::scene::ISceneManager * smgr, irr::video::IVideoDriver* driver, irr::core::array<irr::scene::IMeshSceneNode*> nodes, bool clearNodesAfterUse = true, bool useHardwareMappingHint = true);


Heres zip'ed archive including .cpp and h files for CMeshCombiner:
http://www.multiupload.com/7T25FSHUCI

To use the updated CMeshCombiner, you can do it like this:
Code: Select all
CMeshCombiner * combiner = new CMeshCombiner(0.8,40,ETPT_TILE);
    irr::scene::IMesh* combinedMesh = combiner->combineMeshes(smgr,driver,nodes, "MYNEWMESH",false);
    delete combiner; ///clean up if needed
Working on game: Marrbles (Currently stopped).
User avatar
serengeor
 
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Postby Lonesome Ducky » Tue Apr 26, 2011 3:53 am

Well, I didn't actually put any license into it, so I guess technically it's fair game for anything :lol:

As for the texture problem you have, it's a very common problem with texture atlases. Try changing the filtering type or mipmap bias.
User avatar
Lonesome Ducky
Competition winner
 
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Postby serengeor » Tue Apr 26, 2011 7:55 am

Lonesome Ducky wrote:Well, I didn't actually put any license into it, so I guess technically it's fair game for anything :lol:

Great :)

Lonesome Ducky wrote:As for the texture problem you have, it's a very common problem with texture atlases. Try changing the filtering type or mipmap bias.

I'll try it and report you back asap.

Edit: antisotropic filtering helped a bit, though not much.
Working on game: Marrbles (Currently stopped).
User avatar
serengeor
 
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Postby polylux » Tue Apr 26, 2011 10:31 am

That would come in handy for rendering forrests and the like I assume.
Is it intended for such usage as well?
beer->setMotivationCallback(this);
User avatar
polylux
 
Posts: 251
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Postby serengeor » Tue Apr 26, 2011 12:14 pm

polylux wrote:That would come in handy for rendering forrests and the like I assume.
Is it intended for such usage as well?

It should do ok, as long as the trees are static meshes.

@Lonesome Ducky:
Code: Select all
CMeshCombiner * combiner = new CMeshCombiner(0.8,10000,ETPT_EXPAND);
    irr::scene::IMesh* combinedMesh = combiner->combineMeshes(smgr,driver,nodes, "MYNEWMESH",false);
    outnode = smgr->addMeshSceneNode(combinedMesh);

and setting to antisotropic filtering helps a bit(black lines get visible from further distance), though I would like to get rid of them.
Image
also I tried tweaking LODbias but it didn't help.

Oh, and why does it create a texture 1024x1024 while my models texture is 512x512? Is that because of padding/expanding?

The only thing that seems to give better effect is increasing the texture pading, but it reaches the limit where I can't increase it anymore, because it segfaults :(
Last edited by serengeor on Tue Apr 26, 2011 12:53 pm, edited 1 time in total.
Working on game: Marrbles (Currently stopped).
User avatar
serengeor
 
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Postby Lonesome Ducky » Tue Apr 26, 2011 12:52 pm

It has a safe area of 10 pixels bigger than the textures, so it expands to the highest power of two after 522, just to be safe.
User avatar
Lonesome Ducky
Competition winner
 
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Postby serengeor » Tue Apr 26, 2011 12:53 pm

Lonesome Ducky wrote:It has a safe area of 10 pixels bigger than the textures, so it expands to the highest power of two after 522, just to be safe.

What else could I do to remove those black lines?
Working on game: Marrbles (Currently stopped).
User avatar
serengeor
 
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Postby Lonesome Ducky » Tue Apr 26, 2011 1:00 pm

The last option now is to manually create the mipmaps, and stop the edges of the texture rects from blending. I'll try getting into the mipmap creation to see if I can do that, but it may take a while.
User avatar
Lonesome Ducky
Competition winner
 
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Postby polylux » Tue Apr 26, 2011 1:23 pm

serengeor wrote:
polylux wrote:That would come in handy for rendering forrests and the like I assume.
Is it intended for such usage as well?

It should do ok, as long as the trees are static meshes.


Perfect, can't wait to try this at home. I was getting myself into hardware instancing to implement something similar but apparently I can use your combiner right away.
beer->setMotivationCallback(this);
User avatar
polylux
 
Posts: 251
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Postby serengeor » Tue Apr 26, 2011 2:09 pm

polylux wrote:
serengeor wrote:
polylux wrote:That would come in handy for rendering forrests and the like I assume.
Is it intended for such usage as well?

It should do ok, as long as the trees are static meshes.


Perfect, can't wait to try this at home. I was getting myself into hardware instancing to implement something similar but apparently I can use your combiner right away.


Also you could use impostors.
Working on game: Marrbles (Currently stopped).
User avatar
serengeor
 
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Postby polylux » Tue Apr 26, 2011 3:06 pm

serengeor wrote:
polylux wrote:
serengeor wrote:
polylux wrote:That would come in handy for rendering forrests and the like I assume.
Is it intended for such usage as well?

It should do ok, as long as the trees are static meshes.


Perfect, can't wait to try this at home. I was getting myself into hardware instancing to implement something similar but apparently I can use your combiner right away.


Also you could use impostors.


Still not the same if the main idea is to reduce the scene node count.
beer->setMotivationCallback(this);
User avatar
polylux
 
Posts: 251
Joined: Thu Aug 27, 2009 12:39 pm
Location: EU

Postby serengeor » Tue Apr 26, 2011 3:17 pm

Still not the same if the main idea is to reduce the scene node count.

The main idea is to increase frame rate, so you could use this and impostors at the same time to increase the performance a bit more. Though this might be enough of performance boost already :)
Working on game: Marrbles (Currently stopped).
User avatar
serengeor
 
Posts: 1712
Joined: Tue Jan 13, 2009 7:34 pm
Location: Lithuania

Postby Lonesome Ducky » Tue Apr 26, 2011 5:02 pm

It would be a good idea to combine the trees into a few batches (Use a few combined meshes), then cull some of the batches when you can. This will probably be the best balance.

EDIT: I've added intelligent mipmaps, auto padding calculation, committed some fixes to it (thanks to Kostya and serengeor), and it looks somewhat better. Fixing mipmaps didn't have quite the effect I wanted it to, but it achieves its goal I think. An image for comparison: http://i117.photobucket.com/albums/o73/Azail/comp.png?t=1303860673

Top image is the previous method,
middle is the new mipmap method,
bottom is new mipmap method with anisotropic filter and a lodbias.

I'll release the update code soon.
User avatar
Lonesome Ducky
Competition winner
 
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

Postby Lonesome Ducky » Wed Apr 27, 2011 1:00 pm

Ok, here's the updated code. It doesn't completely get rid of black lines, but it makes them far less noticeable. I think the black lines are inevitable with a texture atlas.

http://dl.dropbox.com/u/4241114/NewMeshCombiner.zip
User avatar
Lonesome Ducky
Competition winner
 
Posts: 1123
Joined: Sun Jun 10, 2007 11:14 pm

PreviousNext

Return to Project Announcements

Who is online

Users browsing this forum: No registered users and 1 guest