Jump to content

instances not visible with rendertargets


Recommended Posts

I would like to use instances and render them with a RenderTargetTexture but somehow they are not visible.
In this PG i modified the custom render target example to use instances:
As you can see only the master sphere gets rendered. If you change from createInstance() to clone() in line 92 it is working.

And then i have a question. I have some use cases where i need to render only part of the scene with a render target. The master mesh may not be part of that, only some of the instances. Is it necessary that the master mesh is always included in the renderList of the render target?

Link to comment
Share on other sites

It seems my material is working but there is another problem, the skybox :)
Look at this PG: http://www.babylonjs-playground.com/#MOO5O#3
Only the master gets rendered. If you remove line 80, also the instances will be rendered.

I think the problem is that the skybox is rendered first and that means, that the depthMaterial is initialized/compiled for non-instance meshes.
Does that mean i have to create every material twice? one for non-instances and one for instances?
Is this also the case for the StandardMaterial?
That would make the material management very complicated in my case :(

Link to comment
Share on other sites

I tried some more things. The StandardMaterial doesn't have that problem. You can assign the same StandarMaterial to instances and non-instances.
The only downside is, that you can't freeze the material anymore. So you will lose some performance if you do this (usally i freeze all my materials).
For the ShaderMaterial it is not working because the StandardMaterial has some special cache handling in the isReady function which is missing in the ShaderMaterial ( https://github.com/BabylonJS/Babylon.js/blob/master/src/Materials/babylon.standardMaterial.ts#L294 ). Maybe this could be added to the ShaderMaterial also.
For the ShaderMaterial it works if you set the checkReadyOnEveryCall property to true.

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