Mesh Combiner
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:
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
If no, I guess I'll just have to make it look like a feature
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:
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
If no, I guess I'll just have to make it look like a feature
Working on game: Marrbles (Currently stopped).
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:
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
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);
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).
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
GreatLonesome Ducky wrote:Well, I didn't actually put any license into it, so I guess technically it's fair game for anything
I'll try it and report you back asap.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.
Edit: antisotropic filtering helped a bit, though not much.
Working on game: Marrbles (Currently stopped).
It should do ok, as long as the trees are static meshes.polylux wrote:That would come in handy for rendering forrests and the like I assume.
Is it intended for such usage as well?
@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);
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).
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
What else could I do to remove those black lines?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.
Working on game: Marrbles (Currently stopped).
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 pm
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.serengeor wrote:It should do ok, as long as the trees are static meshes.polylux wrote:That would come in handy for rendering forrests and the like I assume.
Is it intended for such usage as well?
beer->setMotivationCallback(this);
Also you could use impostors.polylux wrote: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.serengeor wrote:It should do ok, as long as the trees are static meshes.polylux wrote:That would come in handy for rendering forrests and the like I assume.
Is it intended for such usage as well?
Working on game: Marrbles (Currently stopped).
Still not the same if the main idea is to reduce the scene node count.serengeor wrote:Also you could use impostors.polylux wrote: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.serengeor wrote: It should do ok, as long as the trees are static meshes.
beer->setMotivationCallback(this);
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 alreadyStill not the same if the main idea is to reduce the scene node count.
Working on game: Marrbles (Currently stopped).
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 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/ ... 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.
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/ ... 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.
-
- Competition winner
- Posts: 1123
- Joined: Sun Jun 10, 2007 11:14 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
http://dl.dropbox.com/u/4241114/NewMeshCombiner.zip