Sign in to follow this  
gamefan

Issues when using compressed Textures [using setTextureFormatToUse]

Recommended Posts

Hi,

Started using compressed textures in our projects. Came across three possible bugs, not sure about the last one. PG: https://www.babylonjs-playground.com/#RK0W5S#2

1 and 2 are demonstrated in the above PG. Comment line #5 to compare results when not using compressed textures.

1.) Incorrect texture returned when Engine is set to use a ktx format texture and Texture is made via Texture.CreateFromBase64String. Possibe fix: bypass textureFormatInUse when buffer is available in Engine.CreateTexture

2.) Callback passed to Texture is not fired when CreateTexture falls back to url passed on not finding its ktx counterparts. Need this to finish a "change texture" flow. Possible fix: Ignore fallback argument and create onLoadObserver in Engine.CreateTexture

3.) When engine is set to use ktx format , CubeTexture looks for one ktx file instead of 6. I don't know if the cubeTextures in ktx formats are to be composited into a single file. I use this gulp task to create compressed textures.

Got a work around for 1 and 2 but 3 is beyond me. Want this to support 360 tours on low spec devices.




 

Share this post


Link to post
Share on other sites

1) Compressed textures can only be url based.  This is because the actual texture to use is not known at build time.  An iOS system is going to want PVRTC or also ASTC in the future.  A Win desktop is probably going to pick DXT.  You only have one string, not 5.  If you are only saying that you cannot use CreateFromBase64String while compressed textures are enabled, that is true.  Whether it is a bug or not, do not know.  If you can PR change that allows both at the same time, go for it.

2) When falling back due to a .ktx file not found, it looks like null is being passed when createTexture calls itself.  Not sure if this can pass the value from the first call or not, but that is where you might make a change.  I think I just did the same thing as a DDS container did.

3) Yes, I am pretty sure that cube textures in .ktx are all sides in one file, since facesExpectedis a constructor argument.  Been a while since I wrote this, and never had the time to test cubes.  Try using the interactive PVRTexTool for one of those.  I did the bat version, but also think the node version only did one face textures too.
 

Share this post


Link to post
Share on other sites

@JCPalmer
1.) Yes, createFromBase64String not usable while compressed Textures being enabled. I will see if I can make a PR, will be my first. 😀Exciting.

2.) Even when onload from original call is passed, onLoad is not added to the loaded observable in case of a fallback. But I am guessing allowing this is not straightforward, and could affect other cases.

3.) Will try the pvrTextTool. Actually I have the gulp task run through all my folders to make these compressed textures. This treated the cubeTextures the same way it treated other images.

@Deltakosh

I have 1 and 2 working with some changes (not sure if they are fool proof).

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.