ozRocker Posted July 21, 2016 Share Posted July 21, 2016 I've been running these commands every time a new object is added to the scene: var material = new BABYLON.StandardMaterial("material01", Assets.scene); material.diffuseTexture = new BABYLON.Texture("images/textures/wood.jpg", Assets.scene); So if 100 cubes are added to my scene this would get called 100 times. Am I doing this wrong? Would this end up loading the same image into memory 100 times? Should I be creating one wooden texture and pointing all cube textures to that one? Should I be doing the same with materials, assuming the diffuse colour doesn't change? Quote Link to comment Share on other sites More sharing options...
Kesshi Posted July 21, 2016 Share Posted July 21, 2016 The texture file itself will be loaded only once. The texture data is cached internally from the engine. But you should also try to reduce the amount of texture/material instances you create. It will save a bit of memory and for the materials it will also improve the performance a bit. Switching between different materials during the rendering process adds some overhead. ozRocker 1 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.