Painting Base Lighting with the FXTree

May 23rd, 2006 by Guillaume Laforge - Viewed 29234 times -

The idea of painting base lighting in XSI, is to control the lighting like with a standard lighting setup but instead of adding lights in the scene, you paint light in a map. This technique is not a new lighting technique, it is just the “Image Based Lighting” technique (IBL). The goal of painting base lighting is to be as flexible as 3d lights objects.

In this article I will show how it is possible in Softimage XSI to interactively paint the lighting with the FXtree.

A bit of background

In Mental Ray there are two ways to use image-based lighting. The first one is to turn on Final gathering and use an environment shader. The second way is to use an occlusion shader in Sampled Environment mode. You will find all the information to use this shader here (pdf).

I choose to use the second method for this article as the painting technique creates a “low dynamic range image”. It will be easier to paint such an image and have good tonemapping between bright color and dark color than it would be with a high dynamic range image that is more optimal for final gathering. Also for static objects you can render map the occlusion and the render time will be faster. It is possible to render map only the self occlusion to be able to move the non-deformable objects but as far as I know it is only implemented standalone Mental Ray and not yet exposed in XSI. You will find information in this article by Harry Bardak.

Setting the environment up

Assuming you already know how to setup the occlusion shader, I will focus on the painting process.

How to know were does the light comes from?

As the map will be used by the environment shader, it will, by default, be wrapped on an infinite sphere around the scene. We will paint in a 2D UV space. To precisely paint our “lights” on the map we need to know where we are. Use the picture below as an environment map and set the “Spread” parameter to 0 in your occlusion shader to find your way.

Map with markers

Shader at 0 spread

The Black to white gradient is the seam where the left and the right stick together. It is aligned with the Z axis. If we need a light with a position equal to 0 on the Z axis we must paint half a light on each side of the seam. In the video capture at the end of this article I will show how to deal with this particular position with a bunch of FXtree nodes. The other way is to rotate the spherical projection on the Y axis in the environment shader to avoid a sun light in the side of the map.

You will see the non blured picture like bellow.

Environment from outside

Painting the map in the FXtree:

Now than we know where are the front, back, left and right we can start painting!

By default the map used in your environment shader is the noIcon pic, you can get it in the FXtree from the clip menu. Then add a vector paint node and set its size to 128 by 64 pixels. The smaller the environment map is, the faster the render will be. Plug the vector node in the “ToClip_noIcon_pic” input. Now you can start to paint the sky for example. Keep a render region and an FX viewer open at the same time to see how your painted lights behave on the 3D objects.

XSI Layout example

Now all you need is to add one vector paint node by shape . You could use only one vector paint but in this case you couldn’t change the order of the shapes. The interesting thing is that you will often use large white ellipsoid shape and it won’t be longer to render when compared to area lights.

You can add as many nodes as you need, it won”t change the render time.

PBL setup

You will find a video capture showing the process here. You will need the TechSmith codec for this one.

I hope you found this article interesting. Happy PBL :-)

7 Responses to “Painting Base Lighting with the FXTree”

  1. Just had to mention how neat I find this trick to be! Easy, simple, flexible, interactive, etc… Be sure to check out the screen capture Guillaume did, it”ll eat up bandwidth I know but that”s what it”s there for and the video makes it all so clear!

    Thanks Guillaume,

  2. Kris says:

    Wow, really cool. Never thought about doing that. Now if the FX Tree would only support floating point HDRI or OpenEXR, then that would really be something!!

  3. Morten Bartholdy says:

    Excellent stuff as usual Guillaume – it comes quite handy in a project I am working on right now :)

    Thanks for the very clear and informative movie file. It makes it straight forward to follow.

    Morten Bartholdy

  4. Wow!! Excellent!! Now this really reminds us how powerful can be having the FXtree right into XSI! Imagine what could be having the raster painter linked with the weight painter?
    Let”s say we could somehow convert the weight painter strokes to XY coordinates for the raster painter, then we could use it to paint our textures directly into XSI, which I”m pretty sure would be a lovely thing for many of us…
    Just a thought.

    Thanks a lot Guillame!

  5. Mark says:

    Could you elaborate a bit more on the shading side of things?
    I dont quite understand the setup of the Ambient Occlusion shader.
    Thanks alot for the article though. Looks like a realy powerful way
    for setting up base lighting.

  6. Hi Mark,

    You can directly use the ”XSIAmbientOcclusion” shader if you set the ”output mode” to ”Sampled Environment” and add an environment shader to your pass or material. If you want to bake bent normals to your object to speed up the rendering like in my video example you must use the ”mib amb occlusion” and the ”mib bent normal env” shaders. There are two links at the begining explaining how it works. It should help you.

  7. rene castillo says:

    oh rock on i had been using IBL for sometime and that was a nice presente.