Jump to content

Questions about using Mesh and Rendertexture


torbycly
 Share

Recommended Posts

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 by torbycly
Link to comment
Share on other sites

  • torbycly changed the title to Questions about using Mesh and Rendertexture

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 by ivan.popelyshev
Link to comment
Share on other sites

 

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?
 

Link to comment
Share on other sites

  • 2 weeks later...

@ivan.popelyshev

Hi Ivan,

I see in pixi that there is some default way of instancing attributes;

          this.attributes[id] = new Attribute(bufferIndexsizenormalizedtypestridestartinstance);
          // 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

 

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...