Thursday, March 26, 2015

Different Ways to Light a Bedroom

Ending this series on lighting is interior lighting. Compared to a character and an exterior set, I found interior set the most difficult to light. Here is why.

Interiors are enclosed space usually lit naturally by sunlight. This means the only light sources are openings such as the windows on the images above. The big question is how do we bounce light from the windows to all other parts of the room? (This bounce light question can be answered easily in the two other cases. For characters, we simply add more fill lights. For exterior set, the need for bounce light is minimized by lighting from the sky.) There are two answers that I know of.

The first is using Final Gather to bounce the light. This is, after all, what Final Gather was designed to achieve. The first image was rendered using this method.
The main disadvantage of this method is render time. The Final Gathering step took 2+ hours (I needed 3 diffuse bounces to reach the floor area under the bed); the rendering time took 5 hours. The reason for 5-hour render time is noise elimination. This method uses no fill light at all, requiring high sampling quality to eliminate shadow noise.
Another disadvantage is artistic control. Controlling image contrast with lighting alone is impossible; post-render color correction is needed.

The other alternative is using an ambient light. You can read about this method as explained by Zap Anderson on his blog. The ambient light is an omni light with Ambient Occlusion projection map.
This method renders much faster. The ambient light helps to (1) eliminate the need for Final Gather diffuse bounce (I used Final Gather with 0 diffuse bounce) as well as (2) minimize the visibility of shadow noise from the key lights (the window lights).
Finally, this method allows more artistic control. By setting different intensity for key light and ambient light, I could control image contrast even at rendering stage.

Friday, March 20, 2015

Different Ways to Light a Town Center

After character lighting, I continued with exterior set lighting. Getting a basic lighting for a set is not difficult. The difficulties mainly come from working with a large file and fixing mistakes in the model; not from lighting itself.

Creating a good-looking mood lighting, though, takes more effort. The first difficulty is designing interesting lighting schemes. I researched for ideas at Pinterest. There are many boards there to get lighting schemes from, such as 2D3D_env board and Digital Environments board.

Next step is implementing the lighting schemes I picked, which are 2D paintings, in a 3D scene. Using 3ds Max Daylight System with mental ray Sun & mental ray Sky helps a lot. I spent most of my time placing the Sun. After that, I only needed to make minor adjustments. One interesting step is perhaps about getting cloud shadow. I experimented placing a floating box near the Sun and was pleasantly surprised that mental ray Sun creates a soft shadow as expected. I used this trick for the "Morning" image. If you know another trick, please share it in the comments.

I did color corrections in Photoshop. Color Balance adjustment layers are effective to get colors close to those in the lighting schemes. I also cheated lighting quite a bit. For example, in the "Morning" image, I used an extra rim lighting on the foreground tree to get more details. In the "Sunrise" image, I brightened the bright line along the road, which made the lit wall on the left extremely bright. I hand-painted a layer mask so that only the road was brightened.

As always, feel free to tell me what you think in the comments.

Thursday, March 12, 2015

Different Ways to Light a Character


Different ways to light Bruce Willis
Recently I have been practicing lighting, specifically character lighting. First big question: How many ways should I light the character?

After a little research, I decided to cover 7 ways that I thought were large enough a variety. In addition, 7 cases should be enough opportunity to develop an understanding of what is important in lighting.

The more I researched for reference, though, the more interesting lighting schemes I came across. This gave me the one extra case to make a total of 8 schemes above.

Next big questions:
  • Should I vary the camera angle to maximize impact?
  • Should I employ compositing, again, to maximize impact?
Well, I am hoping to use these as material for a short course on lighting. The course goal is to give students chance to experience lighting as much as possible. This means the class is simply lighting, lighting, and lighting.

With this in mind, I decided to keep one camera angle so that comparisons between lighting schemes will be more objective. I also decided to forego compositing to keep the focus on lighting.

This does not mean that I am not planning to polish these :)

Tuesday, March 3, 2015

3ds Max 2014 Visual Diagnostics Work Around

Currently I am trying out 3ds Max 2014. I have been using 3ds Max 2011 since 2010, so I thought it was time for me to make the switch. As expected, there are changes to get used to.

One such change is the Mental Ray visual diagnostics. (You can find this in Render Setup dialog > Processing tab.) I use it often to make sure that I have enough Final Gather points. To my surprise, the "Enable" check box is greyed out, unclickable.
Figure 1. "Enable" checkbox is unclickable

A quick search revealed that this is because the new default Sampling Mode "Unified/Raytraced" does not work with the diagnostics feature. (You can find this in Render Setup dialog > Renderer tab.) The work-around is by setting the Sampling Mode to "Classic/Raytraced". The visual diagnostics will work as previously.
Figure 2. Changing the Sampling Mode from "Unified/Raytraced" to "Classic/Raytraced"

Here is an article at Autodesk's AREA blog that explains this work-around: http://area.autodesk.com/blogs/maxstation/b001-mental-ray-diagnosis.

Edited on 5 March 2015.

Friday, February 27, 2015

Scripting Particle Flow - Making Particles Cast Light



Creating glowing particles is easy. However, the particles should cast light to the scene, as the video above shows. Creating the light pass is not so easy. This post will suggest two methods to create such light pass using 3ds Max.

Method 1: Using Final Gather

You may already be jumping on your seat, screaming "Use FG!" to your screen. Final Gather (FG) is a method to compute indirect, or bounced, lighting. In the case of our glowing particles, the glowing material will cast indirect light to the scene (only lights cast direct lighting in CG renders). This method resulted in the video below.


This method kind of works. However, it has these weaknesses:
  • The resulting light pass flickers. On the video above, this is especially clear on the ceiling.
  • The color of light cast is difficult to control. FG tends to produce pale (desaturated) colors.
  • Render time is rather long. The light pass for the video above took around 3 hours to render.
With all these weaknesses, we should be thinking of a better way to render the light pass.

Method 2: Scripting Particle Flow

This method uses direct lighting and therefore avoid all weaknesses associated with Final Gather. The question is how do we move lights according to particle movement?

We can do so using an operator for Particle Flow called Script Operator. Here is my Particle View setup:
To add our custom script, select the Script Operator and click the "Edit Script" button. A new dialog will appear. Replace the script with the following:
on ChannelsUsed pCont do
(
     pCont.usePosition = true
)

on Init pCont do
(
    -- Keep the lights in an array.
    global LightArray = $ParticleLight* as array

    -- Default position for the lights.
    global defaultPos = getNodeByName("Help_LightDefaultPos")
)

on Proceed pCont do
(
    t = pCont.getTimeStart() as float
    if t >= 0 then
    (
        -- Move particle lights.
        pcount = pCont.NumParticles()
        for i in 1 to pcount do
        (
            pCont.particleIndex = i
            if i <= LightArray.count then
            (
                LightArray[i].position = pCont.particlePosition
            )
        )

        -- Move extra lights to default position.
        if LightArray.count > pcount then
        (
            for i in pcount+1 to LightArray.count do
            (
                LightArray[i].position = defaultPos.position
            )
        )
    )
)

on Release pCont do
(

)
This script assumes the following:
  • There are lights in the scene.
    • That is, the script does not create the lights.
    • You can create a lot of light using 3ds Max Array tool ("Tools" menu > "Array...").
  • The lights are named "ParticleLight*". For example, there should be "ParticleLight001", "ParticleLight002", and so on.
  • There is an object named "Help_LightDefaultPos" somewhere in the scene. A light will be aligned to this object if the light is not yet needed.
Here is what the script does. It starts by collecting all the lights into an array called "LightArray". Then, on each frame, it will move a light to each particle. If there are more lights than particles, the unused lights are aligned to the object called "Help_LightDefaultPos".

This method resulted in the video at the top of this post. You can download my Max file and study it.

Further Reading

This post only touches the smallest tip of particle scripting. To learn particle scripting further, have a look at Bobo's tutorials on Particle Flow scripting.

Thursday, January 29, 2015

Making Blurry Texture Crisp in 3ds Max

It is common to get blurry bitmap texture in renders, especially if the geometry is almost perpendicular to the camera line of sight (i.e. at glancing angle). Here is a render for illustration. Observe how the lines between tiles are blurred.

While reading the book "Architectural Rendering with 3ds Max and V-Ray", I learned about the filtering option "Summed Area" for Bitmap map under "Bitmap Parameters" rollout. Here is where the option is in Material Editor:
By default, the filtering method is "Pyramidal."
If you are wondering what image filtering is about, you can read the Wikipedia article on Mipmap. Basically a texture image needs to be filtered so that the rendered texture is anti-aliased.
Here is a comparison between the 2 methods.
Observe that the white lines between tiles are now crisp and nice.

... Too nice, in my opinion, that I wondered if there was a further story to this option.
According to Autodesk, both methods take approximately the same render time, but "Summed Area" method needs much more memory:
  • "Pyramidal" needs around 133% of the size of the bitmap;
  • "Summed Area" needs around 400% of the size of the bitmap.
This means that "Summed Area" method should be used sparingly. My own take at the moment is to use this for Diffuse maps of geometries, especially those at glancing angles to the camera such as ground, floor, et cetera. Perhaps Bump maps need "Summed Area" filtering depending on geometry and lighting. Specular maps should not need it.

Mental Ray used to not support "Summed Area" method, as was discussed in this CGTalk forum thread. However, I tested this and found that Mental Ray in 3ds Max 2011 supports "Summed Area" method.

Finally, there is an alternative method described by Neil Blevins.

I admit that the title of this post is rather bombastic. Apologies.

Wednesday, January 21, 2015

Mazda RX-8 Compositing

Mazda RX-8 compositing

The VFX class I am teaching is currently in the topic of Lighting, Rendering, & Compositing. One student, Suresh Kalai, suggested using a new car model for the class exercise. It is a Mazda RX-8 2004. Here is the starting render.
Initial render using materials that come with the model

I spent half a day fiddling with the new model (a messy business because all geometries are separate), working on the shaders, lighting, and rendering. Here is a work-in-progress render.
WIP render after half a day
As always, the 80/20 Rule happens. I spent the next 2 class days fiddling with the materials (while the students are working on their files) until I am happy with the final product above.

Mazda RX-8 model courtesy of archibase.net.
Back plate and HDRI sky courtesy of HDRI-Hub.com.