Kesshi Posted November 29, 2016 Share Posted November 29, 2016 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:http://www.babylonjs-playground.com/#MOO5O#1 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? Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 29, 2016 Share Posted November 29, 2016 Hello, the problem comes from the custom shader. You need to add support for instances in your shaders (https://github.com/BabylonJS/Babylon.js/blob/master/src/Shaders/default.vertex.fx#L98) For your other question: There is no need to include the master mesh Quote Link to comment Share on other sites More sharing options...
Kesshi Posted November 29, 2016 Author Share Posted November 29, 2016 I think i need a bit help. I tried to adjust the shader but it doesn't work. here the new PG: http://www.babylonjs-playground.com/#MOO5O#2 Quote Link to comment Share on other sites More sharing options...
Kesshi Posted November 29, 2016 Author Share Posted November 29, 2016 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 Quote Link to comment Share on other sites More sharing options...
Kesshi Posted November 30, 2016 Author Share Posted November 30, 2016 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. Quote Link to comment Share on other sites More sharing options...
GameMonetize Posted November 30, 2016 Share Posted November 30, 2016 I'll fix the ShaderMaterial thanks for pointing this:) 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.