Pryme8 Posted May 21, 2018 Share Posted May 21, 2018 I need information on how to create a custom shader that can handle multiple mesh clones all playing different animations. Im not sure where to look or what the convention is. I was kinda under the impression that if a mesh needed a different animation or different timing it needs a different shader or some sort of VBO data to dictate a different mesh identifier/animation. Any clues or suggestions? NasimiAsl and royibernthal 2 Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 23, 2018 Share Posted May 23, 2018 @NasimiAsl NasimiAsl 1 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 23, 2018 Author Share Posted May 23, 2018 If anyone has any links or articles on this, anything at this point would be appreciated. I will be able to make it happen I just need the information on industry convention. Cause right now I am picturing having to have an array defined with the same index count as the number of cloned meshes sharing the shader. Then have the meshes have an extra VBO value that assigns the same ID as the index value for the array on the meshs vertices, then on the shader iterate through the array applying the assigned animations... Thats just a thought though and I doubt is the correct way. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 23, 2018 Share Posted May 23, 2018 https://www.babylonjs-playground.com/#CSZYEP#6 you can not set diffrent value to one Shader Effect so you can clone mesh but need make new Shader for each one again Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 23, 2018 Author Share Posted May 23, 2018 Thats what I thought, so I need to come up with a nifty trick to avoid that. Otherwise he is going to have 300+ shaders initialized. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 23, 2018 Share Posted May 23, 2018 a wired way is available but i don't know that is best solution any way the attribute channel is different for shader but you clone that so just world position is different https://www.babylonjs-playground.com/#CSZYEP#8 maybe that help https://www.babylonjs-playground.com/#CSZYEP#9 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 23, 2018 Author Share Posted May 23, 2018 that's what I figured... ouch that's some interesting logic. So I need to have a attribute that identifies it as a unique mesh and then use that array method I kinda brainstormed. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 23, 2018 Share Posted May 23, 2018 You saw this helped finally some one use wired solution Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 23, 2018 Share Posted May 23, 2018 and other way is available too let me think about that Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 23, 2018 Share Posted May 23, 2018 if you can make particle from your mesh you can manage them by one shader http://www.babylonjs-playground.com/#1QC9DP#99 Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 23, 2018 Author Share Posted May 23, 2018 I need it for skeletal weighted animations though, not position/vertex manipulation. I am waiting to see if its a single animation that needs different playback timings, if that is the case then I think I got it figured out. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 23, 2018 Share Posted May 23, 2018 1) Are bjs normal materials handled by shaders? If so, can that logic be imitated? How can a bjs normal material be shared with any number of meshes while supporting rendering different animation frames in all of them? 2) Would it substantially affect performance if there were 400 shader material clones if only 20 of them were actually rendered? (The rendered 20 are constantly replaced from a pool of 400) Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 23, 2018 Author Share Posted May 23, 2018 Yes all materials are handled by shaders. I already did. I do not believe it does I think it only has animation instancing and when you need a cloned mesh playing a different animation I think it needs whole new material. I am prolly be mistaken though. The second part I am not sure, I think as long as one 20 are being rendered out of the pool it should not effect draw performance (I dont think) but will require a substantial chunk of memory to hold the 400 entities. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 23, 2018 Share Posted May 23, 2018 I don't think so, unless cloning a mesh automatically clones its material as well under the hood. I have different clones of the same mesh showing different frames of different animations, I never cloned a material manually. 6 minutes ago, Pryme8 said: but will require a substantial chunk of memory to hold the 400 entities. How substantial? Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 23, 2018 Author Share Posted May 23, 2018 yea it clones the material as well, I am not sure if that means it creates a new draw call or not though. top of my head lets say (35*15clones) meshes plus 400 shaders ummm... 50-200 mb kinda hard to estimate that unless I knew the mesh sizes, the shaders should only be like 10mb at most I would guess.. but then again I am just tossing numbers out there I am not an expert on how the GPU/CPU caches resources. *DISCLAIMER* I am talking out my a** now... I have no clue about the ram equivalencies. Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 24, 2018 Share Posted May 24, 2018 can i ask what animation and what mesh you wanna do ? Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 24, 2018 Share Posted May 24, 2018 12 hours ago, Pryme8 said: yea it clones the material as well, I am not sure if that means it creates a new draw call or not though. Interesting, I wonder if it does. 12 hours ago, Pryme8 said: I am talking out my a** now... I have no clue about the ram equivalencies. lol, that's a great amount of ram for a web app so I do hope these numbers are far fetched. 8 hours ago, NasimiAsl said: can i ask what animation and what mesh you wanna do ? I have many low poly models exported in blender, each of them has 2 animations. I'm trying to apply an underwater effect to all of them - it's achieved by a shader material Andy created, but there's the problem of. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 24, 2018 Author Share Posted May 24, 2018 Basically we just need to find out how does anyone else handle 300 of the same mesh using different skeletal animations with the same material. Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 24, 2018 Share Posted May 24, 2018 yup Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 24, 2018 Share Posted May 24, 2018 what kind of animation show me a video or gif Quote Link to comment Share on other sites More sharing options...
royibernthal Posted May 24, 2018 Share Posted May 24, 2018 Sent you a PG in private, you can see there both the animations and the shader effect. Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 24, 2018 Author Share Posted May 24, 2018 Im about to just do my idea with the id attribute and an array to control animation offsets/type Quote Link to comment Share on other sites More sharing options...
Pryme8 Posted May 24, 2018 Author Share Posted May 24, 2018 ... I cant even find any online really on this ... smh Quote Link to comment Share on other sites More sharing options...
NasimiAsl Posted May 24, 2018 Share Posted May 24, 2018 attribute most be for each vertex ( check uv2 ) i don't think that help in clone time 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.