Creating Cubemaps

From Blue Mars Developer Guidebook

Jump to: navigation, search
There are security restrictions on this article

To create a good environment map for a level you will need to create a cubemap derived from the level itself (preferably after the level is completed). To do this we will be doing 3 major steps with lots of little ones in between.

First you need to get a panoramic view of your level. Place a camera in Sandbox at the position you want to take your shot from. Face it along the +Y axis (This is the default anyway). Do a quick look around and make sure that all of you particle effects have initialized. Now change your current view to the new camera.

Image:choosecamera.jpg

Next open the console (~ or ^) NOTE: For all console commands you should just type what is inside the quotes, you don't need to type the quotes. Now you need to type: "e_screenshot_height 1024" - A good size to work with in Photoshop and you'll be scaling it down later. "e_screenshot_width 4096" - 4 times the height so you'll basically be collecting 4 1024X1024 images right next to each other. "e_screenshot 2" - this saves the resultant image into the Game\Screenshots\Panoramic directory.

Now you need to get the top and bottom views, to do this simply change the rotation of the camera to face along the -Z axis (make sure your current view is set to that camera) then type into the console "e_screenshot_width 1024" then "e_screenshot 1". Now change the rotation of the camera to face +Z and type console command "e_screenshot 1". Note that these screenshots will take a lot longer than the panoramic, up to 5 minutes each. These images will be placed in the Game\Screenshots\HiRes directory.

The second step is to put all of your maps together in Photoshop. So open your panoramic with Photoshop. Change the canvas size to 1024X6144 aligning to the left.

Image:cubecanvassize.jpg

This gives you room to bring your top (+Z) and bottom (-Z) maps in. The top goes next to the panorama then the bottom at the end.

Image:pantopbottom.jpg

Now save yourself lots of annoyance and just cut your panoramic into layers each containing a 1024X1024 piece. From left to right these layers should be called -x,+y,+x,-y,+z,-z.

Image:panlabeled.jpg

Now you need to transform each layer as following:

  • -X - scale -100% Width (mirrored) then rotate 90 degrees (clockwise).
  • +Y - scale -100% Height
  • +X - rotate -90 degrees (counterclockwise)
  • -Y - scale -100% Width
  • +Z - rotate 180 degrees
  • -Z - Leave it alone

Finally you need to rearrange the layers to the following order +x,-x,+y,-y,+z,-z

Image:cubefinal.jpg

Now you have a huge beautiful cubemap, unfortunately it's also an extremely slow cubemap. You need to scale this thing down to something like 256X1536 or even 128X768.

Finally in order to save this out you need to have the Nvidia Texture Tools plugin for Photoshop installed. Save it as a .DDS (this will open Texture Tools) select cubemap from the drop down and make sure create mipmaps is turned on. Then simply save it out.

Image:Nvidiadialog.jpg

Now apply it to the environment slot of a material in SandBox.

Image:Envmaterial.jpg

You need to enable Specular Environment map in the Shader Generation Parameters. Specular color acts as a multiplier for the Environment map. The next place to tweak the Environment map is in Shader Parameters. Reflect amount changes how much reflection is mixed with the material. Fresnel scale determines how bright the reflection is when seen at an angle. Fresnel Bias changes the angle at which the map will be visible. For Shiny objects I usually use Reflect amount 5, Fresnel scale 0, Fresnel Bias .1

Once you have your map on the object you may find that in all the rotating and scaling you've managed to breed in some lines that break the effect of your map. If this is the case you can simply go into Photoshop find the offendig line of pixels and duplicate the line of pixels next to them. It won't be noticeable in the end result. One other thing you may notice is that your ground and sky don't match exactly. What you can do is just move the +z layer around to where it attaches to the other 4 sides and blend them together a bit. If you have geometry in your sky that doesn't match with the sides you should blur them together then blur the top out, giving the impression of depth of field. The player won't notice the it as long as there is no seam.

Problems with this wiki page? Contact us either by: Support Email or Support Ticket System

Blue Mars Guidebook Privacy Policy
Blue Mars Guidebook Community Guidelines

Personal tools