envSphere, mentalray and IBL
The way mentalray has been integrated with maya's native shaders is a constant source of curiosity. Some things work the way you expect, some not at all and some need to be tricked into working. In this post I'm going to share the results of my experimentation with maya's envSphere shader in a mentalray context, which led me to the obvious conclusion that IBL is a better choice.
After years of using maya's own software renderer I'm used to doing things in a certain way. The envSphere environment shader is easy to use. I hook up a fileTexture, or a rampTexture and I can then use the place2dTexture node control exactly how they sit within the sphere. For example if I have a 180deg panorama, I will probably want to set the repeatU=2 in the place2dTexture.
The trouble with envSphere is that it doesnt seem to work properly with mentalray shaders. If I connect it to the camera's mentalray environment shader slot maya crashes when I attempt to render.
To the untrained eye, the mentalray equivalent of an envSphere would appear to be mib_lookup_spherical, but it is not so user-friendly, because it forces you to use a mentalrayTexture node and a whole bunch of other nodes to get anything approaching the functionality of the place2dTexture. Too hard! And I could never figure out how to hook up a ramp texture. Often I have simply resorted to mapping my fileTexture onto a big nurbs sphere. Easy!
But I like messing around with mentalray and the hypershader, and today, almost by accident, I discovered that its possible to use envSphere as a mentalray environment shader after all. Rather than connect it directly to the camera, you need to go via a multiplyDivide node (or something similar). Here is a snapshot of the hypershade connections (click image for the full size version).
I guess the multiplyDivide node acts as some kind of data converter. Here's a render I did.

I'm using a fairly lores image, but it should not be that blurry. What I realized is that you need to set the fileTexture filter=0 in the effects tab (dont set the filter type to none; leave it as quadratic of mipmap). Then when I rerendered I got this.

This works pretty well. I've got the convenience of the place3dTexture to rotate the environment and the place2dTexture to set my repeats and to fine tune the offset. Here is one I did with a ramp instead.

My excitement was short lived though. When I turned on final gather I got this.

Dohhh!
Fortunately, there is a solution - Image Based Lighting. You can create a mentalrayIbl node by clicking a button in the Environment tab at the bottom of the render settings window. There is no need to connect it to the camera. Once the IBL node is in your scene mentalray will use it as your environment.
Here is my artifact free render with final gather where I have removed the envSphere from the scene and created an IBL node and connected my ramp to it.

When you create an IBL it defaults to Type=Image File and expects you to give it the name of your image file. But if you want to fine tune your image mapping with a place2dTexture node or you want to use a ramp then you need to change to Type=Texture and connect a maya fileTexture or a ramp texture.
A minor inconvenience is that you cant simply drag-and-drop the texture node onto the texture swatch in the IBL attribute editor. You can try, but no connection gets made. To connect an existing node you need to use the connection editor and connect as shown here.

Notice how the IBL attribute called "texture" in the attribute editor (below) is called "color" in the connection editor (above right) - just to confuse you.

A bonus with the IBL node is that you get a textured preview in the viewport which really helps you line up your reflections. By default the IBL will be scaled very large and you may need to scale it down to see it within your camera's clipping planes.

The IBL can also do light and photon emission. Neither are turned on by default, but they are there if you want them, and you can afford the render time.
Conclusion: Sometimes it is possible get mentalray to do things it probably wasn't meant to do, but for an environment shader, Image Based Lighting is a better choice than envSphere (and forget mib_lookup_spherical unless you like complication).

Hello David, well after finally getting my linear workflow all figured out with 90% of the help from you! (Very well appreciated) I have a few more questions now in reguards to what I am now learning, or at least trying to learn from HDR Labs. And that has to do with sIBL and rayswitchs and Background, Refl., and Env. maps. Dont know if you use those techniques in your workflows or not, but its something I have to be quite useful thus far.
So while trying to maintain a linear workflow, I have the option to click on a button for "linear workflow" in the sIBL edit function in which then creates my BG, ENV, and REF with gamma correct nodes connected to them. Do I really need a gamma correct node on the HDR images which are the REF. and ENV. images? I thought HDR files are already linear. As for the BG image, which is a hi res jpeg, there is also a gamma node on it. Do I need that, or can I just go into photoshop and turn it into an exr file?
Lastly, I read something above mentioning the "Filter Type". As of now, all my textures in my scene are .exr files and choose a filter type of "OFF". Is that not the correct way to go, or should it be Quad. or Mipmap? I hope Im not confusing you are asking you too many questions, but its just something I have been thinking about for a few days and thought you'd be the man to ask. Thank you and will be looking forward to your suggestions and comments.
Comment by smokedogg — December 15, 2009 @ 10:26 am
I can't believe it has been almost two years since I wrote this post. Back then I was writing about my experiments. I do still use the IBL node for a quick environment setup. But I'll often set up something similar to the way sIBL works with geometry and raySwitch nodes. I have not actually used sIBL though - even though the simple interface is very appealing. In fact I did setup a shared sIBL collection library at work - just never got around to using it.
Anyway, to answer your questions. The HDR images do not usually need gamma correction in the workflow that the sIBL loader creates. HDR images are normally stored as linear data. The gamma nodes that are connected to the HDRs have gamma=1, so they are not doing anything.
I'm guessing that the sIBL loader script author decided to create those extra gamma nodes in case you wanted to use a frameBuffer gamma correction, which is a common alternative to the lens shader method that sIBL sets up. In that case you would need to gamma correct your linear data and not your 8-bit images.
Yes, you could convert your jpg to a 32-bit float and save as EXR. I know some studios do that for all their images and avoid as many gamma corrections as possible.
Setting "filter type" to OFF is not good for animation (and may even look bad in a single frame) due to aliassing artifacts. For animation I most often use MIP-MAP and then turn on Elliptical Filtering. This gives nice sharp results with minimal aliassing. I do not use the optimize options though. They are a bit misleading, and create some very large local copies of your fileTextures that can really slow down network renders.
Comment by david — December 15, 2009 @ 8:52 pm
yeah it has been awhile since ya posted this, but i figured this was the place to ask ya about hdr and IBL. Thanks for the promt response! And as for the answers, very well understood and will def. take into account on the filter types as I do have all filters off and have noticed artifacting. I know on bump maps and such, that it should be set as off. Thanks again!
Comment by smokedogg — December 16, 2009 @ 2:01 am
Bump maps still need filtering. This filtering is required because the pixels in the fileTexture need to be mapped to the pixels in the final image and there is almost never a 1:1 correspondance. If you do not use some kind of filtering then aliassing will occur. Fltering may result in an image that appears less sharp, but for animation this is better than an image that buzzes. Elliptical filtering is good at preserving detail where it is needed, and softening gracefully.
Comment by david — December 16, 2009 @ 10:02 pm
So even on bump maps you apply a filter setting to the file? You dont just have it off? Or do you use a mip-map filter for bumps too? Thanks.
Comment by smokedogg — January 7, 2010 @ 5:22 am
With no filtering, there will be aliasing if there is any animation. Even in a single frame you may get moire effects for some textures. So the answer is yes. I always filter bump maps just like everything else. Filtering does soften the image somewhat. Some people dont like it. I prefer a slight blur to bad aliassing. With the mip-map combined with elliptical filtering things stay nice an sharp where it is needed.
The following article, and the one it refers to, may be relevant in this discussion.
http://prolost.com/blog/2009/12/3/you-didnt-believe-me.html
Comment by david — January 8, 2010 @ 11:01 pm