Jump to content

Detect that a mesh will render in a frame


Recommended Posts

AFAIK, before renders & after renders of every mesh always run, which is good.  It looks impossible to know in a before render to know if a mesh is going to render as they run very early.  After renders are another story.  There might be a small lag, but timing wise this has to be do-able.

question is how?  Mesh._activate() will run set renderId.  Can that be used, or does one need to override Mesh._activate() and do something more?

Link to comment
Share on other sites

Well, I guess if lagging one frame is ok, I could have a lastRenderId  property recorded in the before Render.  If the beginning of the before render had:

function beforeRender(){
    var justRendered = this.lastRenderId !== this.reenderId; 
    this.lastRenderId !== this.reenderId; 

then there would be no need to have an after render.

Link to comment
Share on other sites

in my beforeRender class, I put checking in against my TimelineControl system implemented with a scene level after render to see how many times it was called per frame..  Looks like callback is being called N_submeshes * N_cameras per Frame.  It is probably not called at all when the meshs does not evaluate as active.  If you do not have a scene level after render to control your time line,  it is going to be very hard for you to use a mesh with multi-materials and or multiple cameras.

Link to comment
Share on other sites

3 minutes ago, Deltakosh said:

Not sure of your intent but I recently added mesh.onDraw

Neither am I.:)  Have before render based morphing / skeleton animation.  It was important that it ran, even when mesh was not seen.  I also wondered if there a way to detect if a mesh just came into the frame for higher level stuff like initiating animations.

Finding that Mesh level probably do not run when not seen, and worse run multiple times, so all the cpu to change vertices transform bones is done over an over.

Thinking should switch to scene level before renders for always and once.  Use mesh level for high level new in frame detection.

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.

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.


  • Recently Browsing   0 members

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