How the Hell do I make a cubemap with my own art?
I was having a really tough time finding tools to create a workflow that allowed me to hand paint an environment and then generate the six images needed to create a cubemap from it. It seemed like such a simple thing. Could I paint directly on a sphere in Zbrush of Mudbox with the uv’s mapped in an equirectangular fashion, and then take this image and have it cut up by some magic tool into a cube map?
No.. forget it. And after weeks of searching for panorama tools and Photoshop plugins I finally stumbled across a quite effortless solution. 3D Studio Max has a basic material – the Reflect/Refract material that one would place on an object that needs to be shiny or reflective at render time, and to create this illusion, the material has a little tool built into it that auto generated the six images that form a cube map.
Basically, anything you place in a scene around your ‘reflective’ object, will be projected onto the cube map images and then could be used in a game engine that uses that convention for generating a skydome or environment map.
For those not familiar, a common game engine convention is to use 6 images to create the illusion of an environment that is persistent around the player’s position. It could be a sky, a forest, a room… In my case it was a cloudy sky over an Island filled ocean plane as the game was at a high elevation looking down.
The cube map:
But how to generate it, and as you can see the tricky distortion built into each plane, that when viewed from the player’s position to appear like the curve of the horizon.
I created a simple squashed sphere or ‘skydome’ in 3D Studio Max, where a long strip of clouds wrapped around the walls of the cylinder, and the bowl of the ocean plane was another. Everything is softly curved and I even added a bit of geo to the islands to add some parallax when I generate the cube map. The sky is separate from the ocean only to show the use of the textures. The ceiling or ‘cap’ of the skydome is just a single pixel of blue stretched across.
Once you have the skydome assembled, place an object in the center of the scene (or wherever you want the cube map to be generated ‘from’) I placed a small cube. This cube will have the Standard > Reflect/Refract Material assigned to it.
1> Place the cube where you want the ‘point of view’ of the cube map to be.
2> Assign an empty material node to it. Click on the ‘diffuse’ channel button and select ‘Reflect/Refract’ from the pop up menu.
Now the fun part! Once switched to Reflect/Refract, the options dialog panel will appear…
1> Switch the Source from ‘Automatic’ to ‘From File’. Switching to ‘From File’ enables the Render Maps feature below.
2> Enter what resolution you want your cube map images to be. I chose 512 for a nice crisp environment map.
3> Click on the empty ‘To File’ entry field and proceed to save a file. There is nothing to save, but this process is how the tool comes up with what naming convention to use when it generates the maps.
4> Then click ‘Pick Object and Render Maps’ and select the cube object in the center of your scene. A small render window will appear as the tool creates the images and closes.
5> Now you will see your 6 new images listed in the Material.
You’re pretty much done! You now have six images that an be plunked into a game engine for creating an environment map. Mine looked something like this:
Now, because at the time I created the textures for the skydome there was no way to actually match the bottom of the long 1024 texture to the round ocean plane, once the images are projected you can open them and paint out the seams, but with help of the curved distortion to guide you. Like so…
So there you go. A nice little way to have your hand painted imagery be projected onto the 6 separate images needed to create a cube map… with all the proper distortion.
Happy Game Deving!