Jump to content

How do we avoid expensive glUseProgram calls internally?


BlackMojito
 Share

Recommended Posts

Yes, in BJS terminology, having scene.meshes in order by mesh.material has been mentioned before as desireable.  I am not sure how much this helps though.  To be honest, I think you can get all of this plus the JS overheard for each mesh calling BABYLON.Mesh.Merge() for meshes of the same material.  You also avoid the draw calls too!  This works as long as the individual meshes do not move rotate independently.

Link to comment
Share on other sites

6 hours ago, Deltakosh said:

You can provide your own sorting function for opaque meshes if you want: http://doc.babylonjs.com/classes/3.1/scene#setrenderingorder-renderinggroupid-opaquesortcomparefn-alphatestsortcomparefn-transparentsortcomparefn-rarr-void

This is not done by default as most of the time JS code is FAR slower than internal glUseProgram call

Is the sorting done only once then the new order will always be used from that moment,  or we need to execute sorting every frame ? As my meshes are mostly static. Is the sorting is done only once, it will be so cool for me :) 

Link to comment
Share on other sites

7 hours ago, JCPalmer said:

Yes, in BJS terminology, having scene.meshes in order by mesh.material has been mentioned before as desireable.  I am not sure how much this helps though.  To be honest, I think you can get all of this plus the JS overheard for each mesh calling BABYLON.Mesh.Merge() for meshes of the same material.  You also avoid the draw calls too!  This works as long as the individual meshes do not move rotate independently.

Yes sir but I need to handle highlighting and selection too. This meas I need to maintain two scene graphs ?  For big models I am not sure if the limited browser memory can allow it :)

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...