Jump to content

Mesh stays in shadowGenerator renderList after dispose()


Babylonian
 Share

Recommended Posts

I'm working on a project where a large number of objects get created, then are destroyed (with .dispose()), on an ongoing basis. I'm seeing memory use gradually increasing,  and FPS gradually degrading. Have checked to ensure the Scene.meshes[] array is not getting longer and longer. But I noticed that the shadow generator renderlist, which gets added to with :

shadowGenerator.getShadowMap().renderList.push(mesh);

...is getting longer and longer. The dispose() of the meshes does not seem to trigger removal from the list, although the shadows do disappear.

Is there something I should be doing to remove them from the shadow render list? Or should this be happening automatically?

BTW there is no heading for ShadowGenerator on http://doc.babylonjs.com/classes/2.4

 

Link to comment
Share on other sites

Hi @Babylonian, welcome to the forum.  I am no expert... but I can tell you what I think I know.  :o

The .shadowMap for a shadowGenerator... is type RenderTargetTextureAt line 20 of the RTT, there is an interesting comment, regarding dynamically updating the renderList.

This could possibly indicate that RTT's don't have a constantly-updating .renderList... by nature/default.

If you know how to use this... renderListPredicate  and assorted stuff from lines 20-34, I think you can activate a continuously-updating renderList.   No promises.  Smarter helpers than I... will comment soon, I'm sure.  But meantime, you have some things you can experiment-with, if you wish. 

Here is another forum thread that talks about this issue, but it is older.  I was predominantly useless in that thread, too.  :)

Sorry I could not be more helpful.  Stay tuned.

Link to comment
Share on other sites

Hi, @Babylonian 

" large number of objects ", what kind of objects are we speaking of?
are they all the same?, are some of them?

if they are, you could re-use them, instead of disposing,
so a basic setup;

at start you create/clone the all the objects you need, 

when you need to "dispose" them, set mesh.setEnabled( false ); instead

when you need to re-use them, move into position, rescale, etc etc, set mesh.setEnabled( true ); 


Just a thought :), i don't know anything about the shadow generator, sorry.

 

Edit
here's a very simple example with just one mesh, click anywhere on the canvas to show/hide :)

http://www.babylonjs-playground.com/#JUEYV#1

Link to comment
Share on other sites

Thanks all for the quick replies!

@Deltakosh, looks like you are right, it should work, and I have confirmed this works in a simple case with a quick experiment in the Playground: http://playground.babylonjs.com/#QHIIR#0

I'll have to debug my more complex case further. I *had* checked that the meshes were in fact getting disposed of, as scene.meshes.length is getting reduced.

Link to comment
Share on other sites

Found the cause: the removal from the shadow generator must have been recent and is not in the 2.4 version I'm using from the CDN (which is the newest on the release page, although I see the Playground has 2.6-alpha).

Can't remember where I found the link to the CDN to be honest. By typing the URL in I found there was a 2.5 CDN.  This has the fix. So I'm happy :-)

Suggestion: the website could add CDN, or a more minimal download option under the getting started and Release sections.

Link to comment
Share on other sites

Thanks - have downloaded a plain 2-5 and it is also fine on the shadows.

For the newcomer, it would be good with a link from the Downloads page to the http://doc.babylonjs.com/whats-new , and also an indication that the many option under Components are in fact not necessary until at least Tutorial #N (if N can be identified). I was a bit baffled at first ("help, do I need the OBJ or the gITF loader??"). Anyway, I selected nothing, and everything I've tried so far is still working.

Also noted that the file I got when selecting "2.6 preview" was bit-identical to the one I got when selecting 2.5?

NOT complaining, just trying to make it easier for others to follow in my footsteps :-) Fantastic thing you have built here.

Link to comment
Share on other sites

I love your caring, B!  Good to have you with us.  Keep those suggestions coming, and contribute in any way you wish, always.  We have an un-pinned forum thread called Tutorial Talk.  It's a great place to talk about everything docs-related (discussions about documentation "theories", too).  Feel free to say anything in there... lots of us participate in it... slowly.  :)

Sorry to hear that you were confused, and sorry for my mistake about the .renderList thing.  (And darned good issue-solving on your part, too.  Good investigative work!  You bravely went "diving for knowledge", and that is a trait held in high-esteem, 'round these parts.  Excellent!)

I forgot that DK made some changes for this issue, even though he said so... at the bottom of KevinBLT's thread.  Dummy me.  I should have thought about a potential versioning issue... but my brain was clogged for some reason.  :) 

Thanks to all thread participants, for helping to fix my "wild goose chase".  :)  Babylonian, after you learn more about me, you will see that saying wrong things... is quite common for me.  I'm working on it.  But I do a good job at "keeping us talking" about an issue, and that's something, too.  Wait until we start talking about mesh instances and their shadows.  I'm sure that I have 10-20 more wrong things to say about that, as well.  heh.

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