Friday, January 20, 2006

Cube Maps

I've been using cube maps for various things in my shaders lately. I'm especially excited about high dynamic range cube maps because of the nice image quality they give both when used to light objects and also when used for reflections. Now that both Max and Photoshop support 16 bit float images, HDR cube maps are pretty easy to make - especially since the Nvidia DDS plugin for Photoshop can save a dds cubemap in 16 bit float. The pipeline for using cube maps is getting better.

About a month ago, Jolyon Webb from CodeMasters told me about a new tool from ATi that makes working with cube maps even easier. It's called CubeMapGen. It will read in a verticle cross HDR cube map right out of HDRshop and save it in 16 bit DDS format. That means that you don't even have to use Photoshop at all and you no longer have to hand-place the six panels of the cube. This new tools turns the process of creating a cube map into just two steps. First, convert a light probe into verticle cross format in HDRshop and save it. Second, open it in CubeMapGen and resave in 16 bit DDS format. That's it! You can also give it the 6 sides as seperate images if you want to.

Another really nice thing that it does is handle mip-map generation and filtering correctly for a cube map so you never see seams in your cube map no matter what mip-level you use. Nice! You can grab this tool here:

http://www.ati.com/developer/cubemapgen/index.html

I'm working on a new tutorial about using cube maps for real-time global illumination. It probably won't be done for awhile since I don't have a lot of extra time to work on it, but I'm planning on explaining how this tool fits into the process

15 Comments:

Anonymous Dave said...

The ati cube map tool is very cool. We've switched over to cubemap based lighting at work (although we're not using HDR Cubes yet). I was tasked with making all the cube maps that the programmers use for our new lighting and that's when I found ATI's new tool, and what a godsend it is.

With my personal projects and shaders, I've been working on reworking a few of my older shaders to use cube based lighting as well.

January 23, 2006 12:50 AM  
Anonymous Anonymous said...

Thanks for the textures in your site man, they are awesome; really gave my model some variaty in the wood textures; Nice size of the file and resolution.
Thanks again and peace out!

January 23, 2006 11:22 AM  
Blogger Ben Cloward said...

Dave, sounds very cool. Has your game been announced yet? Can you tell me what you're working on or is it still under wraps? What company do you work for?

The next major update of our tools at work will include a version of cube map lighting. Our programmers say that they'll try to do something similar to the hammer editor where you just place a bunch of points down in the level and it creates a cube map at each one and then the model uses the closest one for lighting - all automagically. I'm hoping it will be that easy! Creating these by hand is a lot of work - even with the ATi tool.

January 23, 2006 7:08 PM  
Anonymous dave said...

Well, I've only been working there a couple of months, and I know our publisher can be a bit, shall we say uptight... so I'm not sure how much I can say without breaking NDA.

But I think it's okay to mention I'm working on a golf game for the PC.

Of course the nice thing there is, it's all outdoors. We don't really have to setup points to render cube maps at, we just have a few cube maps we blend between depending on time of day.

The automatic cube rendering shouldn't be too difficult, just a specilized camera rig. We don't use anything like that for CubeMaps, but our engine has a similar thing for automatically rendering out front facing tree billboards, for the lowest LODs.

For my own stuff at home I was working on using Cubemaps w/ ambient occlusion as ambient fill light, and then having 1 key light. But after playing around with pure cube lighting, I might just use it only, and scrap the key light.

I'm currently working on a dynamic normal map shader which gives you a 2nd normal map that contains up to 4 overlays that can be blended into the base normal map. Here's an early test.

http://home.comcast.net/~dayveeman/DynamicNormalMapTest01.avi

The idea is to hook it up directly to bone rotations or morph targets, not sure how feasable that is in a game engine, but it's easy enough to wire up in 3DS Max.

I'm actually quite proud of how it's turning out, my solution for how to squeeze in the overlay alphas, and my technique to blend it in is pretty "out of the box" for me. They whole thing is still only a single pass in PS 2.0, and I only add in one extra map for the normal overlays.

I'm also trying to take J.I. Styles' awsome skin shader and see if I can dumb it down just enough to add in dynamic normal mapping, and still keep it to one pass in PS 2.0.

I'm still a litte green and shader programming though, so it's slow going. Plus I've been busy over the holidays and at work lately. One day I hope to get everything ready to release into the world, and maybe demo it for work, see if they'd be interrested in implimenting it (it's too late to add in anything new this year, but perhaps for next years version).

January 24, 2006 12:24 AM  
Blogger Ben Cloward said...

Dave, that normal map blending shader is very cool! Nice work. I'll also be excited to see this together with the skin shader.

The main problem with using cube maps as your only light source is shadows. You can't really cast a shadow from a cube map. I think that's why most people are going with a combination cube map and directional light. Of course, if you bake all your shadows into light maps - then you're good - but that would only work for static objects.

Another reason to use a directional together with the cube map is most light probe images don't do a good job of capturing the full brightness of the sun. When you diffusly convolve the light probe - where the sun's not bright enough - it ends up blurring the strong directional of the sun too much and not giving a strong enough result. If you're not using an HDR cube map, you also loose all of the power of the sun in the cube map. If you're using a directional for the sun, you can give it all the power you want and it's controlable seperate from the rest of the sky light.

Good luck with you're projects and keep me updated!

January 26, 2006 9:56 PM  
Anonymous Dave said...

Thanks, it might be a while until I get dynamic normals working with the skin shader, I'm still trying to deconstruct the skin shader enough to know what I can remove or simplify. I've already yanked a few things ,but still need to shave a few more instructions off. Maybe I'll have to brake down and use 2 passes.

I also have a detail normal shader that uses a very similar approach to dynamic normals to mix in repeating tileable details with a base normal map. It's basically the old concept of detail maps, but on the normal map rather then the color map. So you can have a base normal map defining, say... the ripples in a sand dune, then a repeating noise normal map to define the grainyness of the sand.

It's an idea to increase normal map detail, but decrease overall texture memory used. The detail normal textures, could be reused over and over again, and since small details are defined by a repeating texture, the base normal can often be reduced in size since it only defines the larger details.

Also on the cube map lighting, we split up our cube lighting into 2 components, one is a static color ambient cube, the other a greyscale light intensity cube (for the sun), which rotates and gives the directional light componant, and can still be used to give a more global illumination look to the lighting. The Z+ direction of the rotating intensity cube is used for keying shadow and specular off of.

Of course the nice thing about a golf game is it's all outdoors, during the day. I don't know how well our approach would work for other games. I'm sure you could find a way to get it to work, even in changing lighting conditions, but there's probably more practical solutions for those situations.

Anway, I've been too busy lately to get much done, but hopefully I'll get some free time to get one of these shaders finialized... I'll let you know when I do.

January 27, 2006 12:57 AM  
Anonymous Anonymous said...

I would like to thank you for your generousity in posting all the metal textures. I am a builder in the game Second Life and will used them to rebuild the Sith Library in the sim Korriban.

You are a cool guy!

January 29, 2006 11:49 AM  
Blogger Ben Cloward said...

Dave,

Your detail normal map shader is a good idea. I wrote one like that too!

I really like the lighting setup that you described for your golf game. Using two cube maps is a cool idea - especially rotating the cube map that has the sun in it for time-of-day changes. Thanks for sharing!

I know what you mean about being busy. I have this big list of cool ideas that I want to work on and it seems like all kinds of other things keep getting in the way.

February 01, 2006 8:41 PM  
Anonymous Joel Styles said...

if you have any luck with my shader, give me a shout! I'd love to see your results :)

one thing too, I've been too lazy to adopt Ben's normal map convention to get around the tangent bug, so that's something you could use and also shave off some instructions. Other than that, I've been noticing how much of a mess it is and how much more I could nest instructions within other functions to get the same results, so if you anything for imrpovement I'd love to hear it too :D

cheers guys!
-Joel

February 08, 2006 7:08 PM  
Anonymous iko said...

Ben,

I was searching for "wood textures" on google, trying to find something with good quality to texture some Second Life objects with :) I was really amazed to find out the first link on google images pointed to... your website! Now your name is familiar to me because I've worked with ClowardRig before... when we did some art outsourcing work for Vicious Cycle last year here at Southlogic Studios, where I'm currently employed. I had to write you a comment right away :) It's a small world (or internet).

Anyways, thanks for the textures. If you ever come to Second Life and want to see how I used them, drop me a line.

(just noticed another SL builder's comment. Hehee.)

peace, from brazil, ~iko

February 21, 2006 7:30 PM  
Anonymous kim said...

Hello! Just wanted to say thanks for putting on the free textures -- I'm a student at the Ringling School of Art & Design, and will be using a couple wood and stucco ones in my next project.

Thanks! :)

March 01, 2006 5:00 PM  
Anonymous robotjam said...

Ben,

Great free textures !! Thanks for those.

March 07, 2006 10:18 AM  
Blogger David Silverman said...

I've tried to use the Cube Map Tool that Ati created and haven't been able to get any decent results. When it actually outputs a cubemap, the result doesn't look much different from the source (just uglier).

Any tips?

April 05, 2006 12:15 PM  
Blogger David Silverman said...

I figured it out. Very cool tool that I'll be able to put into use right away.

Realtime graphics is all about creating a convincing illusion often at the expense of accuracy. I don'y think true HDR will catch on for quite some time. Until then, expect to see teams faking it with blooming and whatnot.

April 05, 2006 4:33 PM  
Blogger Ben Cloward said...

David, I'm glad you got it working. I really like the ATI tools as it saves me several steps when making cube maps.

At this point I don't think there's a real definition for "true HDR." :0) But yeah, it's still in the future a ways for main stream PC games. I think it will catch on quicker on the new consoles, though, where you don't have to worry about minimum specs and creating something for a range of computer capabilities.

April 06, 2006 8:10 PM  

Post a Comment

<< Home