Jump to content

Passing textures to CubeTexture


royibernthal
 Share

Recommended Posts

Of course, but we will be able to track the loading progress properly and avoid loading the texture twice. The raw data can be uploaded to the GPU on the first load.

At the moment what's happening at the first load is, when all the assets are loaded, the CubeTexture is not really ready, so you have no true indication when you can start the game/app.

The texture is being re-downloaded upon the creation of the CubeTexture instance in order to fetch the raw data which was previously ignored and upload it to the GPU.

Link to comment
Share on other sites

  • 1 year later...
On 8/8/2016 at 12:59 PM, Deltakosh said:

Actually Babylon.js keeps a cache of loaded texture. So if you already loaded the textures then bjs will no try to load them again as they are already in the cache.

If this is not what you have please create a repro in the playground and I promise to fix it :D

Hey DK, I seem to be running into this problem.  In one scene my player must choose a texture then it needs to be present in the next scene.

 So what I want to happen is: I load the first scene with the textures, then my player chooses, then I load the textures in the second scene where It shows the texture again.

But what actually happens is:  I load the first scene with the textures, then my player chooses, then I load the textures in the second scene but the textures do not show.

I believe that Babylon.js is not loading the textures for the second scene however I need the textures in that scene.  Is there a way I could get around this?

 

Note: neither of my scenes are up permanently so I cannot just leave the textures in one scene then reference them from the other scenes, since when I dispose of the scene it should dispose of the texture.

Im stumped ? 

Maybe assetManager is what I need, I will look into that in the mean time :) 

Link to comment
Share on other sites

On 9/7/2018 at 6:59 PM, Deltakosh said:

Well, how do you load the textures in the second scene? Can you share a repro in the PG (ideally) or at least share some code?

Hey DK, sorry for the late response.

well i use the same class in both scenes for the code, i just use:

 this.Textures = [];
 this.Textures.push(new BABYLON.Texture("Textures/yellow.png",this.scene));
 this.Textures.push(new BABYLON.Texture("Textures/red.png",this.scene));
 this.Textures.push(new BABYLON.Texture("Textures/orange.png",this.scene));

maybe a few more into that array but that is the general idea.

 

To explain more, this is in the constructor of a class which i call at the start of each scenes creation function.  Scene 1 is created and shown then in the background i have scene two being created, which includes having this class be instantiated.  So when i have these textures already instantiated i try to access them again to load into a different scene.  But they don't seem to load in that scene at all.

 

The only work around i can think of is putting these textures in my sceneManager class then just changing the scene variable in them, then passing them through the class constructor, but i'm not sure that will work, i am going to try that now.

Any other ideas?

Thanks, DD

edit: age old problem of many scripts and it confidential

Link to comment
Share on other sites

6 minutes ago, Deltakosh said:

Well this should work :(

Can you repro something similar in the PG?

Hey i just finished up trying to put all of the textures in my sceneManager class but i still get the problem of i cant switch the scene of the texture.

 

You say it should work though eh? Maybe im doing something else wrong.

Could it be that they are both trying to access the files at the same time and the second one cannot access it becuase the first one is currently accessing it(therefor it just doesnt load it at all)?

 

Also i can try to make a PG but im not sure i have the time to create it.  Gotta go to school soon :( 

Link to comment
Share on other sites

On 9/11/2018 at 2:12 PM, Deltakosh said:

This could not be a race condition issue (Or really hard to believe :))

Please create the repo when you can, that will be the easier way to help you

Hey not sure if this helps you guys understand the problem, but what is really strange is that this only happens on the first go.  Let me explain

 

So i have a customization menu and they choose which texture they wear, it has a preview of the texture on your character, which works great, in the background the game scene is being loaded, after they choose a texture they can hit start then the game scene is shown but the texture does not load(although i have tested it and it tries to apply the texture but im guessing the texture hasn't loaded in time), then you lose and go back to the menu.  After that first sequence the textures are applied fine if you do the same sequence again, my hypothesis is that by then they are cache somehow, so no need for new loading.  Just gotta get it working for the first sequence.  I believe this is just a problem with how i have my code structured but if you have any ideas let me know.

 

Thanks,

DD

Link to comment
Share on other sites

Alright the wild goose chase is over, i had depreciated code, which was i had an older function freeze the material the texture is on, to save performace(i thought that would help, from what i understand it would but not very much...)

once i took out that material.freeze() it started working perfectly!

 

Sorry everyone for the goose chase :( 

Thanks everyone for helping though! :D 

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