Lehooo Posted March 23, 2016 Share Posted March 23, 2016 Hi, first time poster here! I recently started using PIXI for a game project with a tile-based engine. I used the ParticleContainer for a while but had to switch to a regular Container because I need to support several different base textures. I got really excited when I found the post on the blog about multi-texture batching in v4, but soon noticed that the example used a regular Container and that the ParticleContainer is not even present in the latest v4 dev branch (at least PIXI.ParticleContainer is undefined for me). So I'm wondering if this is because you are working on supporting multi-texture batching for ParticleContainers right now, or if they will continue to require all sprites to use the same base texture in the final release of v4. Really hoping for an answer to this as I have to support several different base textures but could really use the performance boost that a ParticleContainer gives. Thanks for making an excellent engine! Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 23, 2016 Share Posted March 23, 2016 There's tile-based thing that can handle multiple textures: https://github.com/pixijs/pixi-tilemap Quote Link to comment Share on other sites More sharing options...
Lehooo Posted March 23, 2016 Author Share Posted March 23, 2016 Thanks for the tip, but I've already checked that out and it doesn't quite do what I need so I've developed my own solution. But this wasn't really the focus of my question, sorry if I was a bit unclear. What I was really wondering about is whether the multi-texture batching feature will work for ParticleContainers in v4 of PIXI. Maybe there is no clear answer to this yet, I could just wait and see what v4 brings once it gets closer to being done. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 24, 2016 Share Posted March 24, 2016 /me looking in the sources. No, but that's a good idea. What exactly do you need for your tiles? Quote Link to comment Share on other sites More sharing options...
Lehooo Posted March 24, 2016 Author Share Posted March 24, 2016 Yes it would be great to see, but I don't know much about the technical details of how PIXI works under the hood so maybe it would be hard to implement for some reason. Well, this might be getting a bit off-topic considering the title of this thread but I can try to explain it briefly. I'm working on the basics of a game with a 3d coordinate system but with old-school 2d graphics. The grid that holds the tiles is 3-dimensional and each cell is a cube which has a tile associated with it and can have different "tile variants" set for each of the cube's faces. When a cell is set, the tile sets the tile variants of the faces based on whether the tile is flat (then only the bottom face of the cube is set) or thick (then the top and front faces are set). The tile variants of the faces are also dependent on whether the neighboring cells contain the same type of tile or not. I don't know if my description is a bit confusing or not so I'm supplying a screenshot of what I have so far, maybe that will give you a general idea of what I'm trying to do. Maybe I could just use the data structures I have and generate tilemaps using pixi-tilemap but I decided to just use a regular Container and add sprites to that, it's working fine for me except I'd like to have the ability to use several different base textures in a ParticleContainer so I could use that instead of a regular Container. I can explain some more things about this if you want but I don't know how strict you are at this forum about keeping threads on topic so maybe I should post that somewhere else. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 24, 2016 Share Posted March 24, 2016 You can create issue so we wont forget that: https://github.com/pixijs/pixi.js/issues ParticleContainer will work just fine in your case. pixi-tilemap has different strategy, which is more effective both in memory (less objects) and performance: buffers dont change between clear() calls. Also, if your tiles are squares or at least half-squares, it will use gl.POINTS, and buffers will be smaller. Also, pixi-tilemap will have some optimizations for canvas2d mode, ported from rpgmaker and gameofbombs.com Quote Link to comment Share on other sites More sharing options...
Lehooo Posted March 24, 2016 Author Share Posted March 24, 2016 Okay, I'll create an issue for that, thanks for the tip! Actually, ParticleContainer won't work for me because I have to support several different base textures. I can get away with a single base texture for the tiles, but the player character you see there uses a different base texture and his sprite needs to be inserted between the tiles. I will add many moving characters and other moving sprites later on to my maps and they can't all use a single base texture, so ParticleContainer just won't work unless it supports several different base textures, which is currently not the case. I'll take a closer look at pixi-tilemap, maybe I can make it work for me, thanks again for the tip! Quote Link to comment Share on other sites More sharing options...
Lehooo Posted March 24, 2016 Author Share Posted March 24, 2016 Just one more question, I don't know exactly how to describe the issue. Right now when I'm using the latest dev version of PIXI v4, PIXI.ParticleContainer is undefined. I'm wondering if I should mention this, but I guess the reason it is undefined currently is just that it is being worked on in some way, so maybe I should leave that out and just describe how ParticleContainer should support multi-texture batching. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 24, 2016 Share Posted March 24, 2016 "inserted between the tiles" . Separate tiles into several layers, each of them must be a ParticleContainer. Add layer for characters somewhere between them. There's no point for a character to be in same container as small tiles. UPD. Its in PIXI.particles.ParticleContainer. Quote Link to comment Share on other sites More sharing options...
Lehooo Posted March 24, 2016 Author Share Posted March 24, 2016 Okay, I actually tried a similar approach previously with one ParticleContainer for each layer. The problem there is that I allow tiles to be placed in a 3d grid, anywhere between 0 and 48 for all coordinates (x, y and z). Thus, I get a maximum of 48 layers and I noticed a significant decrease in performance with 48 ParticleContainers. This is why I switched to just adding all tiles in a single Container and that's why the player sprite needs to be in that same container. Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 24, 2016 Share Posted March 24, 2016 Then performance will suffer because you'll have to sort all that stuff whenever player changes his position. You can also try 48 pixi.tilemap's , I use 22 for rpgmaker maps and they are working just fine. I'm working V4 will have a way to solve that thing, by sorting z-indices, Z-buffer and even 2.5d projections. Quote Link to comment Share on other sites More sharing options...
Lehooo Posted March 24, 2016 Author Share Posted March 24, 2016 Actually, sorting is not a problem. At first, I sorted the whole container every time the player moved and that did decrease performance. I then realized I only had to reinsert the player sprite at the appropriate position in the array and that works just fine. I'm not having performance problems now, this works much better than having 48 ParticleContainers did, I was just wondering about ParticleContainers and multi-texture batching because it's always nice to get an additional performance boost. I'll look into using 48 tilemaps though, maybe that will work better. Thanks for all the help and thanks for helping me find the ParticleContainer in v4, I was really wondering where it went... Quote Link to comment Share on other sites More sharing options...
Lehooo Posted March 24, 2016 Author Share Posted March 24, 2016 By the way, I added an issue about this now. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.