V!nc3r

KTX textures loading, missing files and HDR environmentTexture are in a boat

Recommended Posts

I can't get console error into playground, but the bug is still here: if I want to use KTX compressed textures, BJS don't fallback to source texture if the ktx file isn't found. So inevitably the use of a scene HDR envTexture cancel the scene loading.

line 16, set the value to true: https://www.babylonjs-playground.com/#F70HUY (texture files comes from here)

In a more gobal way, if a texture miss its KTX version, it could be very convenient to use source texture instead (when you have hundreds of texture, you can't convert files each time you update them). Here an example with a jpg texture which doesn't have its corresponding ktx file: https://www.babylonjs-playground.com/#F70HUY#1

If I well remember (not sure), a few (long?) time ago, BJS was doing this source-texture fallback, am I wrong?

Share this post


Link to post
Share on other sites

After some tests it looks like OK. I made a test scene if people are interested https://www.dropbox.com/s/1ut7f5e63ju6wpn/ktx-test.zip?dl=0 with ktx loading at launch but also when a new texture is created on the fly.

Also, this can help someone, I put it here: in the doc it says ktx files have to be Y flipped (and the bat files provided are OK about that) >>> I've lost an hour 'cause PVRTexToolCLI version 4.17 wasn't doing the flip... updating to 4.2 solved the issue.
 
Note that in the gltf scene I had to set albedoTexture.vScale = -1 to get my texture in the right symmetry.

Share this post


Link to post
Share on other sites

@trevordev actually I maybe spot a bug, when dealing with gltf file, but I have no idea from where this come from, I've made a video capture about that:

https://dl.dropboxusercontent.com/s/j42kkodjxnz68nr/ktx-loading.mp4

and my zip test file is updated. Don't know how to reproduce on playground 'cause dropbox doesn't really share folder (which is an issue when you want find files with same name as the engine when dealing with ktx).

It looks like not all ktx files are detected in gltf loading.

gBLSyyO.png

wood-dxt.ktx doesn't exist, error is normal

UrnUaFK.png

environment-dxt.ktx doesn't exist, error is normal, but no error for wood, and checker-arrow is not loaded as ktx while this ktx file exists

Share this post


Link to post
Share on other sites

Hi. Sory to reopen this discution, but I think I missunderstood something.
So basicaly these compressed textures should work with a gltf file, right?
I mean, yes, if I'm adding a new texture from code to an imported gltf file then it is working.
But if I'm loading a gltf file I would like that its textures to be loaded as compressed if they exist. What do you think about this?

Share this post


Link to post
Share on other sites

(I haven't redo tests since the last fix, 'have to do that)

@MarianG if you load a file (fbx, babylon, gltf, etc) with materials using textures (with their usual format - jpg, png, etc), the engine should load them as ktx is the file exist.

And you just have to use this bit of code:

var available = ['-astc.ktx', '-dxt.ktx', '-pvrtc.ktx', '-etc1.ktx', '-etc2.ktx'];
var formatUsed = engine.setTextureFormatToUse(available);

(no need to transform your textures url with .ktx)

Share this post


Link to post
Share on other sites
6 hours ago, V!nc3r said:

(I haven't redo tests since the last fix, 'have to do that)

@MarianG if you load a file (fbx, babylon, gltf, etc) with materials using textures (with their usual format - jpg, png, etc), the engine should load them as ktx is the file exist.

And you just have to use this bit of code:


var available = ['-astc.ktx', '-dxt.ktx', '-pvrtc.ktx', '-etc1.ktx', '-etc2.ktx'];
var formatUsed = engine.setTextureFormatToUse(available);

(no need to transform your textures url with .ktx)

@V!nc3r I'm already doing this, but they load as usual textures, and not ktx. And I'm haveing the lines above too. I got a warning about hdr texture, but nothing about internal png, jpg images.

@trevordev

later edit: I'm using v4.0.0-alpha.8 and it is not working :( 

Share this post


Link to post
Share on other sites

Problem solved :) 
I was an idiot and forgot to update gltf loader too, I updated only babylonjs file.
 Thank you so much.
Only a small observation. Here is a texture which is loaded twice. I don't know why. I hope I saw it clear and it is not a different :))

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

  • Recently Browsing   0 members

    No registered users viewing this page.