Jump to content

export to DDS file for babylonjs environment


efxlab
 Share

Recommended Posts

While DDS may work for an intel based MacBookPro, conversion tools may not.  First double check what extensions are supported for your environment.  You might also run this to see what compressed format gets picked for your machine.

Remember, this is the web.  What will work on one computer, will not on another.  DDS for sure will not work on Android, iOS.  DDS is also very old.

While you may explicitly use DDS with BabylonJS, using ktx containers will allow your page to pick the appropriate compressed texture format.  The doc is here, although I seem to remember a previous topic which had a problem with conversion tools on OSX.

Link to comment
Share on other sites

I found ! I go with a tool called cmft, any unix commande line:

https://github.com/dariomanesku/cmft

Its too tricky to do with GUI app cmftStudio.

I used PVRTexToolGUI.app from by PowerVR for inspect the babylonjs dds file used in demos.

Finally this a batch type for convert HDR image for babylonjs viewer in dds: 

#!/bin/bash

# 8bits 256x256
cmft \
--input ~/Desktop/cmft_osx64/bonifacio_aragon_stairs.hdr \
--dstFaceSize 256 \
--output0params dds,BGRA8,cubemap \
--generateMipChain true \
--output0 ~/Desktop/cmft_osx64/bonifacio_aragon_stairs


# 16 bits 256x256
cmft \
--input ~/Desktop/cmft_osx64/bonifacio_aragon_stairs.hdr \
--dstFaceSize 256 \
--output0params dds,rgba16f,cubemap \
--generateMipChain true \
--output0 ~/Desktop/cmft_osx64/bonifacio_aragon_stairs

# 16 bits 512x512
cmft \
--input ~/Desktop/cmft_osx64/bonifacio_aragon_stairs.hdr \
--dstFaceSize 512 \
--output0params dds,rgba16f,cubemap \
--generateMipChain true \
--output0 ~/Desktop/cmft_osx64/bonifacio_aragon_stairs

Edited by efxlab
Link to comment
Share on other sites

On 20 janvier 2018 at 10:48 PM, efxlab said:

I found ! I go with a tool called cmft, any unix commande line:

https://github.com/dariomanesku/cmft

Hello Efxlab…

Sorry ! I'm “like a chicken who found a knife” but how do you use cmft when downloaded on MacOS and your command lines.

I learnt many things about BabylonJs for last months but converting HDR to DDS is a too big challenge for me and my Mac environment !!

Link to comment
Share on other sites

  • 2 weeks later...

You run from mac terminal, you can drag and drop the cmft exe file, and copy the text above for setup your image for exemple :

# for create a 16 bits 512x512 :
path/to/your/cmft \
--input path/to/your/hdr/bonifacio_aragon_stairs.hdr \
--dstFaceSize 512 \
--output0params dds,rgba16f,cubemap \
--generateMipChain true \
--output0 export/to/bonifacio_aragon_stairs

 

change lines : path/to/your/, path/to/your/hdr/, export/to/ to your own path

Link to comment
Share on other sites

  • 6 months later...

@efxlab thanks for posting about cmft, that's a great find.

One issue I have though, is that when I try to use the sandbox to convert the dds file to a BabylonJS env file using the converter here https://sandbox.babylonjs.com/?assetUrl=https://models.babylonjs.com/PBR_Spheres.glb , I get an error  "The cube texture should allow HDR (Full Float or Half Float)." even though I've selected rgba16f as the output format for cmtf. Looking at the source for the tool https://github.com/BabylonJS/Babylon.js/blob/9d6f4db1e205c72ad58dc8168dda72ccda2ac3e3/src/Tools/babylon.environmentTextureTools.ts#L144 , it seems it thinks the pixel format is uint, rather than float.

Link to comment
Share on other sites

I can't seem to get the .env file working in BabylonJS though. The DDS file works fine using 

sky.reflectionTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("assets/textures/Mono_Lake_B_Ref.dds", scene);

It also works on iOS Safari (I think I read somewhere that dds files didn't work on iOS?)

But when I try the same code with the .env file, no texture loads and I get the console log "Cannot load cubemap because files were not defined"

Link to comment
Share on other sites

DDS files uncompressed work evrywhere as we are parsing them in js, but it is true that compressed DDS do not have support cross platform.

About your .env, you should be able to load them with sky.reflectionTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("assets/textures/Mono_Lake.env", scene);

Link to comment
Share on other sites

1 hour ago, Sebavan said:

DDS files uncompressed work evrywhere as we are parsing them in js, but it is true that compressed DDS do not have support cross platform.

About your .env, you should be able to load them with sky.reflectionTexture = BABYLON.CubeTexture.CreateFromPrefilteredData("assets/textures/Mono_Lake.env", scene);

Yeah, when I try that I get "Cannot load cubemap because files were not defined"

Link to comment
Share on other sites

2 minutes ago, Sebavan said:

You can see a working version here: https://www.babylonjs-playground.com/#09R6ZA#1

Are you sure your server is authorizing .env to be served ?

Oh, maybe not. My dev environment is webpack-dev-server --> localhost. Is the authorizing process documented anywhere?

Thanks for the playground link, looks good in Chrome, but the gamma seems to be off in Safari.

Link to comment
Share on other sites

The skybox looks a lot better in safari with that second playground you posted.

When you said

Quote

Are you sure your server is authorizing .env to be served

Does this mean I need to supply a mimeMap for .env? Currently I'm building my babylonJS app as a static site using webpack. I'll experiment with using a package like https://www.npmjs.com/package/mime to add a mapping for .env. Any pointers you could give me on this would be very much appreciated.

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