Babylon .env files, programmatic creation?

Hey,

I was thinking we could create a sub domain on Babylonjs homepage where people can download different .env and .dds files for IBL lighting.

I have created some scripts to convert hdris from hdri heaven to dds.
But now I want to programmatically convert the dds files into .env files.

I’ve currently been dragging the .dds files into the sandbox and exporting them from the options pane, but it’s a bother if you have a lot of files.

would it be possible have programmatic access to that feature?

If so, I could create the a simple app for you to host that builds the files via github actions and displays them in a simple downloadable way.

What do you think?

1 Like

I really wanted this too… The ability to generate env files right from the Unity Exporter

You already have access to it :slight_smile:

CreateEnvTextureAsync in EnvironmentTextureTools

this is what we use in the sandbox:

        const scene = this.props.scene;
        EnvironmentTextureTools.CreateEnvTextureAsync(scene.environmentTexture as CubeTexture)
            .then((buffer: ArrayBuffer) => {
                var blob = new Blob([buffer], { type: "octet/stream" });
                Tools.Download(blob, "environment.env");
            })
            .catch((error: any) => {
                console.error(error);
                alert(error);
            });

This can only work with webgl2 and premultipliedAlpha set to false in the canvas.

1 Like

Is there a way to do this with node.js runtime… That way we can make a command line tool to generate the .env

As I said you need webgl2 and a canvas to do it so not directly from node only but you could think of using a test like framework to drive Chrome ???

For anyone else looking for a solution,
this command converts hdr > env files

npx github:HugoMcPhee/hdr-to-babylon-env

(requires node and chrome)

code: GitHub - HugoMcPhee/hdr-to-babylon-env: An npx tool to convert hdr files to env files (requires chrome)

thanks sebavan for suggesting using a test framework

3 Likes