torbycly Posted March 9, 2021 Share Posted March 9, 2021 (edited) Hi all While working on my game I encountered some obstacles, of which I'm not sure how to solve them. 1: For my game I have created an animated tree with a particle container for leaves and a normal container for a tree trunk SimpleRope. The tree has some moving animation, as shaking and being chopped, and a simultaneous parallel copy of the tree containing normal map images. However, I cant just recreate the tree as it requires some performance. RenderTexture was a great solution to just create one tree and render it multiple times as texture, but obviously this way the animation will happen on all the trees. Now, for this I thought of a solution but I'm not sure if its good. I figured that when there is interaction with the tree, I could replace it with a new container of the tree, do the animation and erase it or keep it in a pool afterwards. This still could increase performance issues drastically, when multiple trees are interacted with. What do you think is a good solution? Or maybe I could extract the different frames and make an animation loop out of it at the start of the game. 2. I build a character system for the game, which builds a character out of different parts. with the legs, arms and torso as a SimpleRope. this works fine for one character, but I think that when there are more on the map, it will become laggy. Since these SimpleRopes are meshes, these body parts all have separate individual render calls I think, which would amount to a lot, if there are more characters. Would it be doable to create this code of the characters movement of the different body parts inside 1 mesh? if yes, how could I approach it? Thank you for thinking with me for an approach. If you think of something, let me know! Edited March 9, 2021 by torbycly Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 10, 2021 Share Posted March 10, 2021 (edited) Both your question are good but they are on a level where commercial solutions exist: http://ru.esotericsoftware.com/ If you think you are good with your own system, you can implement skinning on mesh shader, make a batcher for it and use instancing - that way you can draw all the trees in minimum commands. That's the usual way of skinning animation. There's no demo of it for pixijs, but if you know how 3d animations work - you can do it. Again, I emphasize- this is a serious task, dont expect people just share their solutions about it, because most of them are not documented. UPD. I dont remember whether https://www.kestrelmoon.com/creaturedocs/Game_Engine_Runtimes_And_Integration/PixiJS_Runtimes.html has instancing... EDIT2. Expect only general answers and help in case you provide a demo that isnt working and has to be fixed Edited March 10, 2021 by ivan.popelyshev Quote Link to comment Share on other sites More sharing options...
torbycly Posted March 12, 2021 Author Share Posted March 12, 2021 You really pointed me in the right direction I think, you are very helpfull. Thank you very much! Its still above my level, skinning and instancing are new to me. But I like to learn, so I will do research, read the code and try to figure something out. Just to get your point, for the characters and the tree should I then start with a mesh, put all the textures in it as geometries and and do all the movement within the shader? Quote Link to comment Share on other sites More sharing options...
torbycly Posted March 25, 2021 Author Share Posted March 25, 2021 @ivan.popelyshev Hi Ivan, I see in pixi that there is some default way of instancing attributes; this.attributes[id] = new Attribute(bufferIndex, size, normalized, type, stride, start, instance); // assuming that if there is instanced data then this will be drawn with instancing! this.instanced = this.instanced || instance; Could you maybe tell me how you can instance in pixi? Thank you Quote Link to comment Share on other sites More sharing options...
ivan.popelyshev Posted March 25, 2021 Share Posted March 25, 2021 This goes directly in "vertexattribdivisor" method: https://github.com/pixijs/pixi.js/blob/3d3f59df57b1701e519e68714510d03d806b72c9/packages/core/src/geometry/GeometrySystem.ts#L592-L597 You can learn more on https://webgl2fundamentals.org/ or other tutorials Quote Link to comment Share on other sites More sharing options...
torbycly Posted March 25, 2021 Author Share Posted March 25, 2021 Oke Thanks! 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.