Difference between revisions of "Cube map"
(Zeller Samuel link) |
(re-org, added Maya section, added links) |
||
Line 1: | Line 1: | ||
− | |||
<!-- ## page was renamed from Cube Map --> | <!-- ## page was renamed from Cube Map --> | ||
= Cube Map = | = Cube Map = | ||
A cubemap is six images that are mapped onto a cube. Cubemaps are supported natively in graphics hardware so they're really quick to transform and render, there's a unified method for rendering them in games. | A cubemap is six images that are mapped onto a cube. Cubemaps are supported natively in graphics hardware so they're really quick to transform and render, there's a unified method for rendering them in games. | ||
+ | |||
+ | |||
{| border="1" cellpadding="2" cellspacing="0" | {| border="1" cellpadding="2" cellspacing="0" | ||
Line 16: | Line 17: | ||
The cube is always centered on the current viewpoint. This means, when used as a backdrop or skybox it always appears infinitely distant. If you turn on wireframe mode in any 3d engine using a cubemap skybox, you'll see the geometry of the box. | The cube is always centered on the current viewpoint. This means, when used as a backdrop or skybox it always appears infinitely distant. If you turn on wireframe mode in any 3d engine using a cubemap skybox, you'll see the geometry of the box. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
== Reflections & Lighting == | == Reflections & Lighting == | ||
Line 41: | Line 27: | ||
Either store the bitmaps as six separate bitmaps, or more commonly store all six in a single DDS cubemap file. | Either store the bitmaps as six separate bitmaps, or more commonly store all six in a single DDS cubemap file. | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
=== 3ds Max === | === 3ds Max === | ||
Line 67: | Line 33: | ||
# [[#Reflect/Refract Map|Reflect/Refract Map]] ... more steps, but not limited to a resolution or format. | # [[#Reflect/Refract Map|Reflect/Refract Map]] ... more steps, but not limited to a resolution or format. | ||
− | 3ds Max can display cubemaps in real-time if you use the DDS cubemap format, and you use the | + | 3ds Max can display cubemaps in real-time if you use the DDS cubemap format, and you use the DirectX Shader material. |
==== Metal Bump9 ==== | ==== Metal Bump9 ==== | ||
Line 95: | Line 61: | ||
− | === | + | === [[DxTex]] === |
+ | Microsoft's DxTex is another way to create a DDS cube map from six images. DxTex is automatically installed when you install the [http://msdn.microsoft.com/en-us/directx/aa937788.aspx DirectX SDK]. Once installed it will be found in the folder (SDK root)\Utilities\Bin\x86 or x64. Use the x86 version unless you're running a 64bit OS. There's also a DDS plugin for Photoshop in the SDK, it expects a 1x6 layout in Photoshop: | ||
+ | * +X | ||
+ | * -X | ||
+ | * +Y | ||
+ | * -Y | ||
+ | * +Z | ||
+ | * -Z | ||
+ | |||
+ | How to compile a DDS cubemap in DxTex: | ||
+ | |||
+ | # Open an existing texture by selecting the File -> Open... menu item. | ||
+ | # Select the Format -> Make Into Cube Map... menu item. | ||
+ | # The current texture will occupy one face of the cube map. From the dialog that pops up, select which face you want the texture to occupy, and click OK. | ||
+ | # For each of the other cube faces, select the View->Cube Map Face menu item and select a face from the list that appears. | ||
+ | # Select the File->Open Onto This Cubemap Face... menu item and select a texture to open from the dialog that pops up. | ||
+ | |||
+ | === Maya === | ||
+ | The easiest way to render a Maya scene into a cubemap is to use six cameras, then stitch the six images together into a cubemap. | ||
+ | |||
+ | Workflow tips can be found in the Polycount thread [[http://www.polycount.com/forum/showthread.php?t=75213|[Maya 2009] how to render an environment map?]]. | ||
+ | |||
+ | === Photoshop === | ||
+ | The [http://developer.nvidia.com/object/photoshop_dds_plugins.html NVIDIA DDS plugin for Photoshop] is one way to create DDS cubemaps. It expects you to lay out the faces of the cubemap horizontally: +X -X +Y -Y +Z -Z. In 3ds Max terms this is: RT, LF, UP, DN, BK, FR. | ||
+ | |||
+ | == Cubemap Seams == | ||
+ | Cubemaps can show seams along the edges of the cube if they aren't mapped properly. Texture filtering can cause a sliver of the opposite side of the texture to creep into the opposite edge. This is simply because the texture is tiling. | ||
+ | |||
+ | There are two solutions for this: | ||
+ | # Set the texture coordinate address mode to Clamp instead of Wrap. Then the edge pixels will be sampled instead of the opposite side. | ||
+ | # Or, for each face of the cube: copy the edge pixels out a couple times, scale each face back down to a powers-of-two size, and scale the UVs down a little. | ||
+ | |||
+ | {| border="1" cellpadding="2" cellspacing="0" | ||
+ | | [[attachment:cubemap_powervr_seams.jpg|Media:CubeMap/attachments/cubemap_powervr_seams.jpg | ||
+ | | width=500}} | ||
+ | | [[attachment:cubemap_powervr_borders.jpg|{{attachment:cubemap_powervr_borders.jpg | ||
+ | |- | ||
+ | | Seams on the edges of a cubemap.<<BR>><span style="font-size: smaller">Image by [http://www.imgtec.com/powervr/insider/ PowerVR]</span> | ||
+ | |} | ||
+ | |||
+ | == Links == | ||
* [http://zellersamuel.wordpress.com/2010/03/06/cubemaps/ Cubemaps how-to and why] by Zeller Samuel<<BR>>A great introduction to cubemaps. | * [http://zellersamuel.wordpress.com/2010/03/06/cubemaps/ Cubemaps how-to and why] by Zeller Samuel<<BR>>A great introduction to cubemaps. | ||
− | * [http://www.cgtextures.com/content.php?action=tutorial&name=cubemaps Cubemaps Tutorial] by CGTextures.com<<BR>>Tutorial using | + | * [http://www.cgtextures.com/content.php?action=tutorial&name=cubemaps Cubemaps Tutorial] by CGTextures.com<<BR>>Tutorial using Photoshop, NVIDIA's Photoshop plugin, and [[CubeMapGen]] to convert cubemaps into various layouts. |
− | * [[Diffusely Convolved Cube Map]] | + | * [http://developer.amd.com/gpu/cubemapgen/pages/default.aspx CubeMapGen] from AMD. |
+ | * [http://msdn.microsoft.com/en-us/directx/aa937788.aspx DirectX SDK] has the DxTex tool from Microsoft. | ||
+ | * [http://developer.nvidia.com/object/photoshop_dds_plugins.html DDS plugin for Photoshop] from NVIDIA. | ||
+ | * [http://www.outerspace-software.com/bixorama.html Bixorama] ($) a panorama conversion utility. | ||
+ | * [http://www.hdrshop.com/ HDR Shop] ($) free for non-commercial use. | ||
+ | * [[Diffusely Convolved Cube Map]] wiki page describes how to downsample cubemaps to use for lighting. | ||
---- | ---- | ||
[[Category:Texturing]] [[Category:EnvironmentMap]] | [[Category:Texturing]] [[Category:EnvironmentMap]] |
Revision as of 18:49, 30 July 2010
Contents
Cube Map
A cubemap is six images that are mapped onto a cube. Cubemaps are supported natively in graphics hardware so they're really quick to transform and render, there's a unified method for rendering them in games.
[[Image:CubeMap$cubemap_Sorsele_humus.jpg}} |
A cubemap in horizontal-cross format.< >Image by Emil 'Humus' Persson |
The cube is always centered on the current viewpoint. This means, when used as a backdrop or skybox it always appears infinitely distant. If you turn on wireframe mode in any 3d engine using a cubemap skybox, you'll see the geometry of the box.
Reflections & Lighting
When used for reflections, the reflection cubemap is centered on the mesh object. The viewing angle bounces off the mesh surface at an angle opposite to the surface normals, so it points to particular parts of the cube map.
Cubemaps can also be used for soft ambient-occlusion-like environment lighting, by using a diffusely convolved cubemap.
Creating Cubemaps
The bitmaps for each of the six sides need to be square, each needs to be powers-of-two in size (128, 256, 512, etc.), and all six images need to be the same size.
Either store the bitmaps as six separate bitmaps, or more commonly store all six in a single DDS cubemap file.
3ds Max
There are two main ways to render cubemaps in 3ds Max.
- Metal Bump9 ... saves directly into DDS cubemap format, but limited to 256x256 and you can't set the DDS compression (uses ARGB).
- Reflect/Refract Map ... more steps, but not limited to a resolution or format.
3ds Max can display cubemaps in real-time if you use the DDS cubemap format, and you use the DirectX Shader material.
Metal Bump9
- Setup a scene you wish to render into a cubemap.
- Place some type of object at the viewpoint you wish to render the cubemap from, for example a camera or a point helper or a geometric object. The orientation of the object doesn't matter, and the object itself won't be rendered into the cubemap.
- Create a Standard material, open the DirectX Manager rollout, and change the None flyout to Metal Bump9.
- Press Pick object and create and select the object.
- Choose a name and a location to render to.
3ds Max will render it directly into DDS cubemap format, but it's limited to 256x256, and you can't set the DDS compression (it uses ARGB).
Reflect/Refract Map
- Setup a scene you wish to render into a cubemap.
- Place some type of object at the viewpoint you wish to render the cubemap from, for example a camera or a point helper or a geometric object. The object itself won't be rendered into the cubemap.
- Configure your rendering options.
- Create a Standard material and load a Reflect/Refract map into any slot.
- In the map, set Source = From File.
- Set the Size spinner to the resolution you want to render. If you're going to use the cubemap for a game it should be a powers-of-two number (128, 256, 512, etc.).
- Use the Render Cubic Map Files / To File: button to set the prefix name and bitmap format to render to.
- Press Pick Object and Render Maps and select the viewpoint object.
- The six bitmaps will automatically be loaded into the Reflect/Refect map, or you can convert them into a DDS cubemap with
Dxtex
or another tool.
#!wiki caution Warning: The render cannot be canceled once the object is picked, so save your Max file before rendering, in case Max freezes!
DxTex
Microsoft's DxTex is another way to create a DDS cube map from six images. DxTex is automatically installed when you install the DirectX SDK. Once installed it will be found in the folder (SDK root)\Utilities\Bin\x86 or x64. Use the x86 version unless you're running a 64bit OS. There's also a DDS plugin for Photoshop in the SDK, it expects a 1x6 layout in Photoshop:
- +X
- -X
- +Y
- -Y
- +Z
- -Z
How to compile a DDS cubemap in DxTex:
- Open an existing texture by selecting the File -> Open... menu item.
- Select the Format -> Make Into Cube Map... menu item.
- The current texture will occupy one face of the cube map. From the dialog that pops up, select which face you want the texture to occupy, and click OK.
- For each of the other cube faces, select the View->Cube Map Face menu item and select a face from the list that appears.
- Select the File->Open Onto This Cubemap Face... menu item and select a texture to open from the dialog that pops up.
Maya
The easiest way to render a Maya scene into a cubemap is to use six cameras, then stitch the six images together into a cubemap.
Workflow tips can be found in the Polycount thread [[Maya 2009 how to render an environment map?]].
Photoshop
The NVIDIA DDS plugin for Photoshop is one way to create DDS cubemaps. It expects you to lay out the faces of the cubemap horizontally: +X -X +Y -Y +Z -Z. In 3ds Max terms this is: RT, LF, UP, DN, BK, FR.
Cubemap Seams
Cubemaps can show seams along the edges of the cube if they aren't mapped properly. Texture filtering can cause a sliver of the opposite side of the texture to creep into the opposite edge. This is simply because the texture is tiling.
There are two solutions for this:
- Set the texture coordinate address mode to Clamp instead of Wrap. Then the edge pixels will be sampled instead of the opposite side.
- Or, for each face of the cube: copy the edge pixels out a couple times, scale each face back down to a powers-of-two size, and scale the UVs down a little.
[[attachment:cubemap_powervr_seams.jpg|Media:CubeMap/attachments/cubemap_powervr_seams.jpg | width=500}} | [[attachment:cubemap_powervr_borders.jpg|{{attachment:cubemap_powervr_borders.jpg |
Seams on the edges of a cubemap.< >Image by PowerVR |
Links
- Cubemaps how-to and why by Zeller Samuel<
>A great introduction to cubemaps. - Cubemaps Tutorial by CGTextures.com<
>Tutorial using Photoshop, NVIDIA's Photoshop plugin, and CubeMapGen to convert cubemaps into various layouts. - CubeMapGen from AMD.
- DirectX SDK has the DxTex tool from Microsoft.
- DDS plugin for Photoshop from NVIDIA.
- Bixorama ($) a panorama conversion utility.
- HDR Shop ($) free for non-commercial use.
- Diffusely Convolved Cube Map wiki page describes how to downsample cubemaps to use for lighting.