Creating an environment file from a .dds image

Since reading the posts by @JCPalmer and @PatrickRyan over on the Blender Exporter 6.1 thread and this BJS documentation thread, I had this thought about creating my own files.

I looked at the .DDS files that Mr. Ryan has posted and the images are laid out in a PX,NX,PY,NY,PZ,NZ kind of format. Like a single long texture made from six regular SkyBox textures. Now I have created a number of regular skybox sets in the past, so I thought maybe I could use them to create a compressed environment texture using the sandbox

So here are the steps I used:

  1. Create a png image of a skybox laid out the way a .DDS file is - see below.
  2. Import that into PVRTexTool and save it out as a.DDS file
  3. Open a BJS sandbox window , drag and drop the PBR Spheres file, then drag and drop a .DDS file and then save as a ,env file.

When I tried step 3 with files from Mr. Ryan - it works fine. When I tried it with .DDS files I had created in PVRTexTool, the Sandbox locks up.

Am I just barking up the wrong tree here and it is not possible, or making a mistake somewhere along the way? Any thoughts welcome.

cheers, gryff :slight_smile:

I do not know, but when you used PVRTexTool, did you create a cubemap?


1 Like

@PatrickRyan Can you help?

@JCPalmer : TY for that Jeff. I was laying out the the images in a texture before hand and trying to convert that. Your method gets me one step beyond that with a successful load of the resulting DDS file from PVRTexTool into the sandbox.

However, trying to create a .env file produces a popup indicating an error (see below) and a whole bunch of error messages in the console of this type:

Error: WebGL warning: readPixels: Framebuffer not complete. (status: 0x8cd6) COLOR_ATTACHMENT0Attachment has an effective format of COMPRESSED_RGBA_S3TC_DXT3_EXT, which is not renderable. babylon.js:16:207787
Error: WebGL warning: readPixels: Framebuffer must be complete. babylon.js:16:207787

I tried a couple of formats (encoding BC2 and BC3 linear RGB) for the DDS save. So maybe I have picked the wrong encoding now. And as you know, there are a lot of formats to chose for DDS saving.

But one step at a time. By the way, I created this new thread so not to distract from your important stuff on the Blender exporter. So which format do I need to select?

And any thoughts from @PatrickRyan are of course welcome.

cheers, gryff :slight_smile:


@gryff sorry for the delay. Yes, a cube texture is what we expect for our environments in the DDS format. I am unfamiliar with PVRTexTool, so I will need to do a little looking into what the tool does. We expect 8 mip levels in the DDS and we need to use legacy DDS headers for the environment to work. Let me do some looking into the tool and I’ll report back.

@PatrickRyan : No rush. I I happened to see the discussion on the Babylon 6.1 exporter thread (I linked to above) and I remembered some of the skyboxes I had created over the last few years with Bryce 7 that happens to be on sale right now for $5.0.

If I can get this method to work, then it is possible to create all kinds of fantasy .env files - alien planets for example. I now that creating files with a camera and natural scenes can be time consuming. I was just looking for a way to create those alien environments and add them to the list of available freebies.

I will perhaps post some images of the kind of skyboxes I am talking about later. Image posted for something I called “SulphurWorld” - see image below. (not a DDS file, just the skybox arranged in the PX -> NZ order

Take your time - there is no rush.

cheers, gryff :slight_smile:

The alert is coming from BJS, here.

    if (texture.textureType === Constants.TEXTURETYPE_UNSIGNED_INT) {
       return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");

My understanding is HDR is not only a cube texture, but each of the colors can have a range of more than 256 colors. This is accurate lighting. When a texture type is unsigned int, it does not create a big enough range to be useful for an environment texture.

My guess is the best environment textures are designed for this at the beginning, not retro fitted. You might try encoding in one of the DirectX 11 float formats inside the DDS container file.

@JCPalmer : TY for the thoughts Jeff. I’ve tried a couple of those - no luck :frowning:

I’ll keep trying - it just gets a little frustrating.

cheers, gryff :slight_smile: