Home Technical Talk

Questions about Cubemap

polycounter lvl 16
Offline / Send Message
onionhead_o polycounter lvl 16
From some ppls work i have seen them use a cubemap for reflection. And I have been wondering how to create one? Also does it only work with stationary objects? and where to plug it in in max for it to work?

Replies

  • Jonathan
    Options
    Offline / Send Message
    In Max 2008 and and later you can generate a cubemap using the MetalBump shader/DX plugin that comes w/ Max, via the options in the material browser.

    There is also this,
    http://developer.amd.com/gpu/cubemapgen/pages/default.aspx

    Are you planning on using realtime shaders in the Max viewport?
  • onionhead_o
    Options
    Offline / Send Message
    onionhead_o polycounter lvl 16
    thanks for the info. mainly i just want to learn about the method of creating cubemap. and where to apply the technique.

    just one more question - does reflection cubemap only work with realtime shaders?
  • onionhead_o
    Options
    Offline / Send Message
    onionhead_o polycounter lvl 16
  • JostVice
    Options
    Offline / Send Message
    JostVice polycounter lvl 12
    Well, out of 3DMax they're used in a lot of games as reflections, like UT3, and I think you can use a cubemap as reflection while rendering... ;)
  • Mechadus
    Options
    Offline / Send Message
    @ Jonathan - Awesome - very helpful! Thanks for posting.

    Ive also been trying to figure this stuff out mostly for my own entertainment. I have a sub-question, however...

    Is there any way in Max to display a reflection glossiness map in the viewport?** I know some studios use the ref-gloss map in games and I was just wondering what the most efficient way to preview one is - right now I tweak --> update --> render --> repeat, and it seems very counter productive since the rendered frames never look the same as an in-engine screenshot.

    ** I dont have access to an engine here at work, so Im trying to make due with max8 and photoshop 7....
  • Eric Chadwick
    Options
    Online / Send Message
    Max can display cubemaps in the viewport if you use the DDS cubemap format, and you use a DirectX shader.

    I was going to post an updated wiki page, but the server's crapping out. Here's the info, eventually I'll post it here in the wiki...

    =============================
    A cubemap is six images that are mapped onto a cube. The cube is always centered on the current viewpoint. This means, when used as a backdrop or skybox it always appears infinitely distant.

    When used for reflections, the reflection cubemap is always 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. These angles determine what parts of the cubemap are rendered for reflection, and where on the surface they are projected.

    Cubemaps can also be used for soft ambient-occlusion-like environment lighting, by using a [:Diffusely_Convolved_Cube_Map:diffusely convolved cubemap].

    If you turn on wireframe mode in any 3d engine using a cubemap skybox, you'll see the geometry of the box. Cubemaps are supported in hardware so they're really quick to transform and render, there's a unified method for rendering them in games.

    The bitmaps for all six sides need to be square and each of the six need to be the same size. You can store the bitmaps as six separate files, or you can store all six in a single DDS file (compressed or uncompressed).

    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 it is: RT, LF, UP, DN, BK, FR.

    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:BR +XBR -XBR +YBR -YBR +ZBR -ZBR

    How to compile a DDS cubemap in {{{DxTex}}}:

    1. Open an existing texture by selecting the File -> Open... menu item.
    1. Select the Format -> Make Into Cube Map... menu item.
    1. 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.
    1. For each of the other cube faces, select the View->Cube Map Face menu item and select a face from the list that appears.
    1. Select the File->Open Onto This Cubemap Face... menu item and select a texture to open from the dialog that pops up.
    How to create a cubemap by rendering a 3ds Max scene:

    1. Setup a scene you wish to render into a cubemap.
    1. 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.
    1. Configure your rendering options.
    1. Load a Reflect/Refract map in any material.
    1. In the map, set ''Source'' = ''From File''.
    1. 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.
    1. Use the ''Render Cubic Map Files / To File:'' button to set the prefix name and bitmap format to render to.
    1. Press ''Pick Object and Render Maps'' to select the viewpoint object. The render cannot be cancelled once the object is picked, so save your Max file before rendering, in case Max freezes!
    1. 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.

    http://projects.ict.usc.edu/graphics/HDRShop/tutorial/images/uffizi_cube.jpg
    A cubemap created from photographs, using [http://projects.ict.usc.edu/graphics/HDRShop/ HDRShop].
  • Mechadus
    Options
    Offline / Send Message
    WOW - Thanks Eric! I was researching and playing around with cube maps earlier, and I discovered some of this, but what you just posted has really cleared up a lot of questions and misconceptions I had about the way that the maps are used, and about the .dds file format. Again, I really appreciate it!

    -Nick
  • onionhead_o
    Options
    Offline / Send Message
    onionhead_o polycounter lvl 16
    Thanks a ton . Eric for such an in depth explanation. I really appreciate your help.
  • Eric Chadwick
    Options
    Online / Send Message
    Sure, you're welcome, added it to the wiki.
  • Xoliul
    Options
    Offline / Send Message
    Xoliul polycounter lvl 14
    Mechadus wrote: »
    @ Jonathan - Awesome - very helpful! Thanks for posting.

    Ive also been trying to figure this stuff out mostly for my own entertainment. I have a sub-question, however...

    Is there any way in Max to display a reflection glossiness map in the viewport?** I know some studios use the ref-gloss map in games and I was just wondering what the most efficient way to preview one is - right now I tweak --> update --> render --> repeat, and it seems very counter productive since the rendered frames never look the same as an in-engine screenshot.

    ** I dont have access to an engine here at work, so Im trying to make due with max8 and photoshop 7....

    This is strange. I've never heard of a reflection gloss map, if it is what I think it is, ie a map that controls reflection blurriness, then there's only one way to do that, which is to blend between a sharp and a blurred cubemap depending on a grayscale mask. I'm not even sure if that would look any good... If it's just a reflection mask (reflect - don't reflect and anything in between), then you can use my shader: http://boards.polycount.net/showthread.php?t=62006
    You should check it out, I tried to give it really good fresnel and reflection controls :)
  • Brice Vandemoortele
    Options
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    Pas op manneke

    Well, you know it's not the only way, the easiest being fetching lower mipmaps of the cubemap :)
    wReflect.xyz = -reflect( input_vtx.eye, input_maps.normal );
    	wReflect.w = input_maps.specularPower * ReflectionBlurFactor;
    	half3 env = texCUBElod(EnvSampler, wReflect).rgb;
    

    you can bruteforce a blur kernel into the shader, but it's slightly more expensive... :)
  • Xoliul
    Options
    Offline / Send Message
    Xoliul polycounter lvl 14
    Okay very interesting, I'm learning. I read something like this in the ATi cubemapgen paper, where they said lower LOD's are stored in the alpha channel or something, but it really wasn't explained very clearly there, and I thought I understood that this sort of stuff only worked for CubeMapGen generated cubemaps.
    So, the W component of the reflect vector used to sample the cube, determines the LOD? What sort of value does this function expect; how is LOD level expressed by this number? This is exactly what I need to implement IBL into my shader without forcing the user to use an extra, blurry cubemap.
  • Brice Vandemoortele
    Options
    Offline / Send Message
    Brice Vandemoortele polycounter lvl 19
    Well with the former texCUBE() you had to use additional code to fetch a specific mipmap, and that included, if i'm correct, to store the miplevel as a grayscale value in the alpha.
    Since sm3 we have texCUBElod which is more convenient :) but you'll still need some sort of preprocessing into cubemapgen for the seams between the faces of the cube not to appear.
  • SHEPEIRO
    Options
    Offline / Send Message
    SHEPEIRO polycounter lvl 17
    Xoliul wrote: »
    This is strange. I've never heard of a reflection gloss map, if it is what I think it is, ie a map that controls reflection blurriness, then there's only one way to do that, which is to blend between a sharp and a blurred cubemap depending on a grayscale mask. I'm not even sure if that would look any good... If it's just a reflection mask (reflect - don't reflect and anything in between), then you can use my shader: http://boards.polycount.net/showthread.php?t=62006
    You should check it out, I tried to give it really good fresnel and reflection controls :)

    isnt this a version of sperical harmonics, or at least a simplified version?
  • Andreas
    Options
    Offline / Send Message
    Andreas polycounter lvl 11
    Very handy Eric thanks! Was looking to learn what a cube map was and you covered pretty much every question I had. :D
Sign In or Register to comment.