The Case of the Missing Clouds



The Mental Ray for Maya's physical sky is pretty handy. With the click of a button you can have a nice clear sky. But see that is one of the problems with this sky, there isn't a single cloud to be seen. One would think it would be pretty straight forward and relatively easy to add texture to it, maybe there's a channel somewhere that can be mapped with some sort of panoramic image of rain heavy clouds or perhaps a night sky bursting with stars. Nope!



Well there's the “Use Background” checkBox with an image slot below it. What's that for? Don’t get your hopes up, it’s a total tease, you can map a texture to it but, and this is a huge but, it will not be visible in the reflections or refractions of any of the objects in the scene, they will reflect/refract a clear sky! Boo.

MasterZap made a post on getting clouds into the sky and Ash made a Maya version, these helped and gave me much hope. But I was having problems, my sky was overblown by the time I started seeing the clouds and everything turned yellow/orange! It got really bad really quickly when using an HDR image, by the time I got up to multiplying the sky texture by 5 it was too much and I even got some artifacts, the low dynamic range needed to be multiplied even more while yielding a less detailed sky and lighting. Either way by the time I really started seeing clouds, the sky was so orange it looked like a Benson & Hedges ad.




LDR Map: multiplied x 10



The setup involves these nodes:

File texture node (for sky texture)

mib_lookup_spherical (for mapping the texture in a dome like manner)

multiplyDivide (for controlling the strength of the texture)

luminance (to extract the grayscale information from the texture to drive the sky haze)

------

fileNode.outColor -> mib_lookup_spherical.tex

mib_lookup_spherical.outValue -> multiplyDivide.input1

multiplyDivide.output -> luminance.value

luminance.outValue -> physicalSky.haze

Ensure the operation on the multiplyDivide node is set to multiply and adjust the input2 to influence the strength of the sky map.

HDR Map: multiplied x 2


However, relying solely on the sky’s haze attribute just wasn't enough.

As you can see the clouds are still barely visible yet the orange hue is already out of control, not even adjusting the exposure node's whitepoint helped me here. I started searching for a way to combine the sky texture with the physical sky node before it hits the camera. In steps my old friend, the mib_color_mix. I prepared for Maya to crash when I hit the render button, but instead success!




Essentially, the sky texture is layered on top of the physical sky using the color mix. The color mix is then plugged into the camera instead of the physical sky.

The setup is as follows:

physicalsky.outValue  -> mib_color_mix.color1

mib_lookup_spherical.outValue -> mib_color_mix.color2

mib_color_mix.message -> cameraShape.miEnvironmentShader

Color mix settings:

Num is set to 2 since I’m using only 2 layers.

Mode 0 can be left at blend or mix.

Weight 0 is 1.000 (100%  coverage, this is why blend mode doesn’t matter here)

Mode 1 is set to add (since I want the clouds to accentuate the sky and not be a weird semi-transparent residue that's trying to compete with it)

Weight 1 is set to 2.000(this is just personal preference, see images below)


Texture layer weight 1 ---- Texture layer weight 2



Another thing I noticed is that the sky now contributed to the alpha channel. Well that was because the sky texture had no alpha. If I wanted it to behave like the default non-alpha generating sky then I could just take the texture into Photoshop and add an empty alpha to it. It turned out pretty nicely. And just incase you're wondering, no it's not physically accurate (was it to begin with?) but it's working.  Now, I'm trying to see if I can get a rig going to link up the rotation of the directional light and the image and see if I can find a non headache inducing way of getting some shadows from these clouds. Wish me luck!

Notes:

The physical sky was also plugged into the camera's volume shader slot to get the "visibility distance" attribute to work.

The color mix approach yields very visible clouds on its own, the mapped sky haze in addition to that produces a more diffused and in my opinion, a more blended sky.




1 comment:

  1. Huh. That's really awesome! In researching cloud techniques for my thesis, this is one of the most unique options I've seen that is native to mental ray. Thanks for sharing!

    ReplyDelete

Leave a message at the beep...wait for it...:p