Cubemap Builder

0 votes
Version: 
1.0
Date Updated: 
08/02/2016

Description:
A maxscript Utility for the batch generation of cubemap faces across multiple cameras, and optional assembling of a "complete" cubemap in DDS format. The completed DDS texture is ready to use in the DirectX shader material - the original inspiration and motivation for this script.

Additional Info: 

Cube map creation and export script for 3ds Max
Version 1.0
8/2/2016
[email protected]

Description:
A maxscript Utility for the batch generation of cubemap faces across multiple cameras, and optional assembling of a "complete" cubemap in DDS format. The completed DDS texture is ready to use in the DirectX shader material - the original inspiration and motivation for this script.

Install:
Unzip the "cubebuilder.mse" and "stitcher.exe" to anywhere on your system. "Your max install\scripts" works, but isn't a requirement.
In max, navigate to the Utility Tab and choose Maxscript > Run Script
Select the .mse file you extracted
"Cubemap Builder 1.0" should now appear in the Utilities dropdown list
For clarity, read the script preparation and scene prep sections before using, and in that order.

Script Parameters:
Once the script is run, you have some options:
"Folder" sets a folder to store individual cube map faces that are rendered
"Hide Camera parent obj" will optionally hide the parent object that a camera is linked to. useful if you camera is 'inside' an object (center of a vehicle, etc)
"Float VFB" will set the framebuffer of the "Main" render to be HDR. This only sets the flag, support depends on the Renderer in use.
"Show faces after" will show the cubemap faces in max after rendering. once face per window. Not recommended if multiple cameras or elements are rendered.
"Render Elements" will render the currently active render elements per-face. If you want just diffuse, or shadows or depth as a cubemap, this is for you. Only "Production" renderer supported for now.
"Resolution" is the output resolution the first time a camera is rendered. This value is saved to the camer object, and future renders use the value saved on the camera - not the value in the utility. This facilitates per-camera resolutions, while sacrificing some usability. See QA for more info.
"Render cube faces" will render cubemap faces for every camera you have selected. Full scene rendering occurs once per face, per camera, so 6 renders per camera.
Careful, render times can add up fast! For example, rendering 3 cubemaps cameras will render the scene 18 times :)

"Stitch output cubemaps" determines if "stitching" will occur when renderign is complete. Must be enabled to generate completed DDS cubemap files
"To" sets the path for completed, stitched DDS cubemaps. This can be separate from the folder with the individual face textures.
"Exe" path to the 'stitcher.exe' included. Point it to whereever you extracted the exe. This is a Direct3D9 program that builds a complete DDS-format cubemap from the individual faces rendered.
"Stitch Cube faces" will run the stitcher program, with the LAST faces that were rendered. they need to be rendered first, or nothing will happen.

"Render and stitch" will render the scene, and automatically stitch the outputs together when rendering is completed.

Script Preparation:
Once you have run the script, you MUST set the paths for the cubemap faces. This will bring up a file "Save as" dialog, where you can set the type of file you want to save the faces as. Supported formats are DDS, TGA, PNG and HDR.
DDS, only X8, A8 and 32bit Float textures were tested. Mipmaps not supported by the stitcher.
TGA: Use 32 bit textures, 24bit and Alpha-split is not supported by stitcher.
PNG: use 24bit images.
HDR: Standard and RealPixel both work. this will output a 32bit float DDS cubemap.
BMP: Not supported by the stitcher.
Other formats not listed, are not supported at this time.
If you want to stitch the cubemaps, then you must also set the "To" for the DDS cubemaps, and "Exe" to point at the stitcher program.

Scene preparation:
Create either a Target or Free camera. Physical cameras are not supported at this time.
The camera created is going to be the center of your cubemap. Place it where you want to render a cubemap from
Optional: You can link the camera to a parent object, and the script will optionally "hide" the parent while rendering.
With the camera(s) selected, you may either render the faces alone, or render them and stitch automatically(recommended)
Press one of the buttons and Render!

Rendering elements:
Render elements are supported, in additional to the 'main' render pass.
Set up the render elements as you normally would
Render element faces are stored in the same folder as the 'main' textures set by the "Folder"
If no output file is specified, the image type used is the same as that set by the "Folder"
If you want to specify a different format for the element, say a float texture for the Z depth, then set the file path and type within the elements window. The path will be ignored, but the file type will be respected for cubemaps.

About rendering depth elements:
Do not use the "Update" parameter, as this will use a different set of min/max values, per-face. the resulting cubemap will not be usable. the script will detect the zdepth pass, and check your camera for clipping. If clipping is enabled, the script set the Near/Farclip values for the element to those of the camera, and they will match across all 6 faces. In this way you can capture the depth for an area as a cubemap, not unlike a Pointlight/Cubic shadowmap :)

Requirements:
The script was developed and tested on 3ds Max 2016, however it may be compatible with older versions
The stitcher helper program uses Direct3d 9, and should work on any machine that can run 3ds max.

QA:
Q: I changed the render size, but my cubemaps still render at the old size, how do I change this?
A: The script supports per-object cubemap resolutions by saving the render size as a user property. To change this, Right-click on your cubemap camera, select "Object Properties", and go to the "User Defined" tab. the key "cubemap_res" controls the output resolution.

Q: The output image is too light/dark!
A: Under investigation. The "main" renderpass should respect the system gamma, but I have noticed linear output as well.

Version Requirement: 
3ds Max 2016
AttachmentSize
cubebuilder.zip31.59 KB
screenshot.png4.56 KB