Depth of Field Quality Adjustment in mental ray

Written December 6th, 2010
Categories: Articles, Rendering / Compositing
4 comments

In this quick article, we’ll be visually exploring how to adjust the quality of the depth of field effect in 3d Studio Max with mental ray.  The process is closely tied with how you increase the quality of your render (sampling).  All you have to do is increase your render sampling to smoothen the depth of field effect. Once you’ve had some practice, you’ll know just how to adjust your render to get great results every time.

Let’s begin with my warehouse sample scene.  There are several aspects of the scene that make it perfect for testing depth of field.

  1. There are numbers around the scene that represent a distance from the camera in feet.  ”2″ is 2 feet from the camera, “4″ is 4 feet from the camera, etc.
  2. There are lots of detail around like girders and windows that will accentuate any blurring effects.
  3. The floor and wall have a checker pattern that is 1-foot by 1-foot squares.  They also help us understand the blurring effect.
basic render of the warehouse

This is a basic render of the warehouse scene. Not great.

We can do better than this, but let’s set up our depth of field effect first.  Once we get an effect we like, we can improve the quality.

Select the camera, and engage the depth of field (mental ray) effect.

engage-depth-of-field-mental-ray-camera

Engage the effect.

When we take another render, we can see that some elements have gotten blurry.  With a target distance of 32 feet, we can see the number “32″ clearly, but the number “2″ is blurrier.

warehouse-render-dof

Warehouse render with default depth of field.

Notice that the image is still pretty grainy, and we’re even getting sampling artifacts on the tile flooring and garage doors.  Let’s improve our render sampling and get a comparison to see how we can improve the quality.  The most direct way to improve the quality is to increase our sampling from {1/4 and 4} to 1 and 16.  We’ll also want to use a better filter type.

increased-render-sampling

Increased render sampling and using a better filter.

Below you can see the new render plus a comparison of key areas before and after the Samples per Pixel change.

warehouse-fine-render

A finer render of the warehouse.

A clear improvement in details.

The depth of field effect improved, too.

Now there’s a catch to all of this.  The original render only took 2:41 while the finer render took 6:53.   Remember not to turn up your depth of field quality settings until you’re ready to take a final render!

Warehouse Depth of Field Demo Scene

Written December 6th, 2010
Categories: Downloads, Models, Scenes
5 comments

You can use this simple 3d Studio Max scene to practice your mental ray rendering with depth of field. There are numbers placed around the scene at escalating distances from the camera. There are numbers at 2, 4, 8, 16, 32, and 64 feet from the camera.  Try modifying the camera’s f-stop value and target distance to see what kind of effect the blurring has on the different numbers.  The checker pattern on the back wall is exactly 1-foot by 1-foot squares.

This scene was used in my mental ray depth of field quality tutorial.

Enjoy!

Click this link to download the Material-Randomizer-v0.84. To install, just download the zip file and decompress it into your plugins/std folder. You can also run it directly by running it from the Maxscript menu.

How to Deploy MaxScript Scripts

Written December 1st, 2010
Categories: Articles, Scripting / Programming
1 Comment »

You’ve spent a lot of time putting together a useful MaxScript and you want the whole world to enjoy it!  Unfortunately, you’re not sure of the best way to get it into the hands of the people.  Luckily, MaxScript comes with three major techniques for deploying a script and we’re going to cover them today.  These three techniques are

  1. Executable script – run it when necessary
  2. Macroscript (optional auto-deploy) – bind it to a hotkey or menu item
  3. Scripted plug-ins – connect to the 3ds Max interface directly

We’ll be going through these examples with a simple “Select Non-Quad Polygons” script from the MaxScript documentation.

Method 1- Executable Script

The first way is best for beginners and involves coding up a script that executes in a single go.  The script below operates in that way.  It iterates across all faces in the object to select non-quadrilateral faces.  Note that this script only works for editable poly objects and will throw an error for anything else!

local face_selection = #{}
local base_obj = $.baseobject
local num_faces = polyop.getNumFaces base_obj
for f = 1 to num_faces do
(
	local num_face_verts = polyop.getFaceDeg base_obj f
	if num_face_verts != 4 do face_selection[f] = true
)--end f loop
polyop.setFaceSelection base_obj face_selection
max modify mode
modPanel.setCurrentObject base_obj
subobjectlevel = 4

In this case, when the script is run, the faces are selected and the user is unceremoniously dropped off at the object’s “Polygon Select” level.  For a script with this level of involvement, this is an appropriate deployment mechanism.  The user just runs the script whenever they need it.  The script usually sits in a folder somewhere waiting for the user to invoke it.

Method 2- Macroscript (With optional auto-deploy)

A Macroscript is a wrapper that goes around your entire script and allows it to be bound to a hotkey or made a UI item.  This deployment method is good for intermediate users and for larger scripts that are a little more involved.  Let’s try wrapping the script above into a Macroscript and see it in the 3ds Max user interface.

macroscript SelectNonQuadPolys category:"Bluesummers" \
tooltip:"Select Non-Quads"
(
	on isEnabled return
	(
		selection.count == 1 and classOf selection[1].baseobject == Editable_Poly
	)
	on execute do
	(
		local face_selection = #{}
		local base_obj = $.baseobject
		local num_faces = polyop.getNumFaces base_obj
		for f = 1 to num_faces do
		(
			local num_face_verts = polyop.getFaceDeg base_obj f
			if num_face_verts != 4 do face_selection[f] = true
		)--end f loop
		polyop.setFaceSelection base_obj face_selection
		max modify mode
		modPanel.setCurrentObject base_obj
		subobjectlevel = 4
	)--end on execute
)--end script

Notice that in this case we’ve added two important elements. The first is a check to make sure we have an editable_poly object selected.  The second is the Macroscript wrapper that allows this tool to become part of the user interface. It has a name, a tooltip, a category, and can even take on a standard or custom icon (see MaxScript documentation). If you execute the script above and then go to “Customize > Customize User Interface” and select the “Bluesummers” Category, you’ll see the script appear.  You can bind it to a hotkey or add it to a Quad Menu or rollout floater.

In order to deploy this kind of script, you’ll need to have the user drop it into their “StdScripts” folder of their 3d Studio Max installation.  This is no fun since it adds some complexity.  For most 3dsMax installations, that folder is

C:\Program Files\Autodesk\3ds Max 2009\stdplugs\stdscripts

Any scripts in this folder will be run during 3dsMax’s startup process, and when you have the Macroscript wrapper around your script then you’re effectively “registering” a new tool during startup.

You can get pretty creative during this process. For example, during startup you can register the Macroscript into the user’s interface which basically “installs” it into 3d Studio Max. Consider the following snippet from my WedTexVerts script that installs it into the 3d Studio Max UnwrapUVWs modifier UI automatically.

Macroscript <...>
(
	<...shortened...>
)
-- If the registration fails, that means it's already there.
if menuMan.registerMenuContext 0x1c413679 do
(
	local ToolsMenuIndex, ToolsMenuItem
	local ToolsMenu, WeldVertTool, UVW_MenuBar

	-- Get the main UVW menu bar
	UVW_MenuBar = MenuMan.getMenu 128 

	-- The above is not always true.  Let's check to make
	-- sure so we don't totally wreck the UI
	if UVW_MenuBar.getTitle() != "UVW Unwrap - Menu Bar"
	do throw "Critical Error: Your UI Could not be modified \
				because you have made changes to your .mnu \
				file."

	-- Get the tools index.  Should be 4th from the left.
	-- Double check the title to make sure.
	for i = 1 to UVW_MenuBar.numItems() do
		if (UVW_MenuBar.getItem i).getTitle() == "Tools" do
			ToolsMenuIndex = i

	-- Get the menu item that holds the help menu
	ToolsMenuItem = UVW_MenuBar.getItem(ToolsMenuIndex)

	-- Get the menu from the item
	ToolsMenu = ToolsMenuItem.getSubMenu()

	-- Create a menu item that calls the WeldTexvert Tool.
	WeldVertTool = (menuMan.createActionItem "WeldSelectedFloater" "Bluesummers' Tools")

	-- Add the action item to the end of the help menu.
	ToolsMenu.addItem WeldVertTool 7

	-- redraw the menu bar with the new item
	MenuMan.updateMenuBar()
)

This is a pretty complicated process, so I’ll leave it to you to read more about the MaxScript MenuMan object. You should just be aware that your users may not always be smart enough to bind up your tools to a hotkey and you can take the liberty of putting your new functionality directly into their interface.  However, you should also be extremely careful as the smallest mistake could damage the user’s interface.

Method 3- Scripted Plug-Ins

Finally, it’s possible for us to deploy scripted plug-ins. These tend to be the largest scripts of all and are basically full extensions of 3dsMax functionality. You can create render filters, meshes, modifiers, and more. You’ll basically deploy your script similarly to a Macroscript- by having your user insert the script into their 3dsMax C:/…/stdscripts/ folder. However, instead of wrapping your functionality in a Macroscript, you’ll wrap it in a scripted plug-in context.

Take a look at the code below, where the script creates a new object type called a Cuboid.

plugin geometry Cuboid
name:"Cuboid"
classID:#(0x133077, 0x54375)
category:"Scripted Primitives"
extends:Box
(
	fn fmax val1 val2 = if val1 > val2 then val1 else val2
	tool create
	(
		on mousePoint click do
		case click of
		(
			1: nodeTM.translation = gridPoint
			2: #stop
		)

		on mouseMove click do
			if click == 2 then
				delegate.width = delegate.length = delegate.height = \
				2 * fmax (abs gridDist.x) (abs gridDist.y)
	)
)

Granted this procedure takes significantly more work than the other two options, it does integrate your tools more deeply into 3d Studio Max and can be quite useful for circumstances where you want to create a “normal” extension of the tools available.

And there you have it!  Those are three awesome ways to deploy your scripts to anyone who needs them.  Happy coding!

Wire Bundle Script

Written November 5th, 2010
Categories: Downloads, Scripts
18 comments

This is a simple script that you can use to create bundles of wires with ease in 3d Studio Max. Just drop the .MS file into your <3dsMax>/stdplugs/stdscripts folder. Then it’ll show up in your “Customize>Customize User Interface…” window, under the “Bluesummers” Category. Bind it up to a hotkey and you’re good to go!

Click this link to download the WireBundle_0.90.zip. To install, just download the zip file and decompress it into your <3dsMax>/stdplugs/stdscripts folder. You can also run it directly by running it from the Maxscript menu.

Creating Custom 3d Studio Max Rollouts

Written October 8th, 2010
Categories: Articles, Scripting / Programming
2 comments

In this quick tutorial, we’ll look at how you can create custom 3d Studio Max rollouts for your tools.  You can make custom floating or docked windows or toolbars that hold your tools and that make it easy to customize your workspace.  These tools are usually called “actions” and can be almost anything you imagine!  They can be

  • 3dsMax modifiers like bevel, extrude, etc,
  • actions like “Convert to Editable Poly…”, or
  • tools like align, hide, etc.

It can save you time and that’s part of what getting better at 3d is all about.

Step 1- Right click on an empty interface area

Right click on an empty interface area to get the interface customization menu.  Select “Customize…”  Otherwise, you can go to Customize > Customize User Interface… and select the “Toolbars” tab.

3dsmax-custom-rollouts-step-1

Step 1- Right click on an empty interface area, and select "Customize…"

Step 2- Create a new rollout

What you need to do is create a new rollout by clicking the “New…” button.

3dsmax-custom-rollouts-step-2

Step 2- Create a new rollout by clicking the "New…" button.

Go ahead and give your new rollout a name.  I’m calling mine “Common Tools”.

3dsmax-custom-rollouts-step-3

Assign your custom toolbar a name.

Step 3- Assign some actions to the new toolbar

Click and drag some actions into the new toolbar.  The vast majority of what you can do in 3d Studio Max can be assigned to buttons in toolbars.  Interestingly, all of these actions are also scriptable via MaxScript.

3dsmax-custom-rollouts-step-4

Select the actions that you want to appear in the new toolbar by click+dragging them over.

You now have a new custom toolbar.  You can access it using the right-click menu we used to start this process.  Right-click on an empty area of the UI and select your new “Custom Tools” toolbar.

3dsmax-custom-rollouts-step-6

You now have a custom toolbar!

BONUS: Assign custom actions to your toolbar using MaxScript

You can assign custom actions to your toolbar with the MaxScript Macro Recorder Window.  Press F11 or open the listener through MaxScript > MaxScript Listener…

3dsmax-custom-rollouts-step-7

Enable the MaxScript Macro Recorder from the Listener window.

Enable the MacroRecorder as shown.  This will record everything you do in 3d Studio Max in the pink window, and allow you to record a pre-defined set of actions.  This could be everything from making flower petals to building a skyscraper.

3dsmax-custom-rollouts-step-8

When you have your action recorded, drag the script to your toolbar.

When you have your action recorded, select all of the text in the pink window and drag it over to your toolbar.  If you have extra actions recorded, you may have to remove those.  Remember that everything you click or do is being recorded, so make sure you did what you want to record and nothing else.

You can right-click on the button that was created and select “Edit Button Appearance…” to change the image or text of your new button.

3dsmax-custom-rollouts-step-9

I gave mine a label and tool-tip so that I don't forget what it does.

The Hyatt Hotel Uses Vampires in Their Ads

Written October 6th, 2010
Categories: Blog
1 Comment »

That’s the most fun explanation for this absurd advert in the September 18th issue of The Economist. It’s more likely that their ad department sent the wrong version of the ad copy and didn’t notice.  If you look closely you can see that the entire pool is fake.  Normally that wouldn’t bother me but they really dropped the ball on the effect here.

Anyway, take a look at the image below.  I had to really double check to make sure I wasn’t crazy.  Click on the image to see a high-res version.

The woman's reflection is missing.

There's something odd about this image…

Arch & Design Material: Tips and Tricks

Written October 5th, 2010
Categories: Articles, Rendering / Compositing, Textures / Materials
2 comments

This is a duplicate of the Arch & Design Overview document by Autodesk and not written by Mr. Bluesummers.

Final Gather Performance

The final gather algorithm in mental ray 3.5 is vastly improved from earlier versions, especially in its adaptiveness. This means you can often use much lower ray counts and much lower densities than in previous versions of mental ray.

In many cases, you can render still images with such extreme settings as 50 rays and a density of 0.1. If this causes “oversmoothing” artifacts, you can use the built-in ambient occlusion to solve those problems.

When using final gather together with GI (photons), make sure the photon solution is fairly smooth by first rendering with Final Gather disabled first. If the photon solution is noisy, increase the photon search radius until it “calms down,” and then enable Final Gather.

Quick Guide to Some Common Materials

Following are some quick rules of thumb for creating various materials. Each assumes the basic default settings as a starting point.

General Rules of Thumb for Glossy Wood, Flooring, and So On

These are the kind of “hybrid” materials you might require for architectural renderings; lacquered wood, linoleum, etc.

For these materials, set BRDF to Custom Reflectivity Function; that is, you’ll define a custom BRDF curve. Start out with 0 degree reflectivity of 0.2, 90 degree reflectivity of 1.0, and apply a suitable texture map to the Diffuse Color. Set Reflectivity between 0.6 and 1.0.

How glossy is the material? Are reflections clear or blurry? Are they strong or weak?

  • For clear, fairly strong reflections, keep Reflection Glossiness at 1.0.
  • For slightly blurry but strong reflections, set a lower Reflection Glossiness value. If performance becomes an issue try turning on Fast (interpolate).
  • For slightly blurry but also very weak reflections, you can “cheat” by applying a lower Reflection Glossiness value for broader highlights while setting Reflection Glossy Samples to 0. This shoots only one mirror ray for reflections, but if they are very weak, the viewer can often not really tell.
  • For moderately blurry surfaces, set an even lower Reflection Glossiness value and maybe increase the Reflection Glossy Samples value. Again, for improved performance turn on Fast (interpolate).
  • For extremely blurry surfaces or surfaces with very weak reflections, try turning on Highlights+FG Only.

A typical wooden floor could use Reflection Glossiness of 0.5, Reflection Glossy Samples of 16, Reflectivity of 0.75, a nice wood texture for Diffuse Color, perhaps a slight bump map. If bumpiness should appear only in the lacquer layer, turn on Special Purpose Maps rollout > Do Not Apply Bumps To The Diffuse Shading.

Linoleum flooring could use the same settings but with a different texture and bump map, and probably with slightly lower Reflectivity and Reflection Glossiness values.

Ceramics

Ceramic materials are glazed; that is, they’re covered by a thin layer of transparent material. They follow rules similar to the general materials mentioned above, but set the BRDF method to By IOR (fresnel reflections) and set IOR to about 1.4 and Reflectivity to 1.0.

Set the Diffuse Color to a suitable texture or color, such as white for white bathroom tiles.

Stone Materials

A stone object usually has a fairly matte finish, or has reflections that are so blurry they are nearly diffuse. You can simulate the “powdery” character of stone with the Diffuse Roughness parameter; try 0.5 as a starting point. Porous stone such as brick would have a higher value.

Stone would have a very low Reflection Glossiness (lower than 0.25) and one can most likely use Highlights+FG Only to good effect for very good performance. Use a nice stone texture for Diffuse Color, some kind of bump map, and perhaps a map that varies the Reflection Glossiness value.

The Reflectivity would be around 0.5-0.6 with By IOR (fresnel reflections) off and 0 degree reflectivity at 0.2 and 90 degree reflectivity at 1.0

Glass

Glass is a dielectric, so By IOR (fresnel reflections) should definitely be on. The IOR of standard glass is 1.5. Set Diffuse Level to 0.0, Reflectivity to 1.0 and Transparency to 1.0. This is enough to create basic, completely clear refractive glass.

If this glass is for a window pane, turn Thin-walled on. If this is a solid glass block, turn Thin-walled off and consider if caustics are necessary or not, and set Refractive Caustics accordingly.

If the glass is frosted, set Refraction Glossiness to a suitable value. Tune the Refraction Samples for good quality or turn on Fast (interpolate) for performance.

Colored Glass

For clear glass, use the tips in the preceding section. Colored glass, however, is a different story.

Many shaders set the transparency at the surface of the glass. And indeed this is what happens if one simply sets a Refractive Color to some value, such as blue. For glass with Thin-walled turned on this works perfectly. But for solid glass objects this is not an accurate representation of reality.

The scene in following illustration contains two glass blocks of different sizes, a sphere with a spherical hole inside it, and a glass horse.


Note: The spherical hole was created by inserting a second sphere with its normals flipped inside the outer sphere. Don’t forget to flip the normals of such surfaces or they will not render correctly.

With a blue refraction color: Glass with color changes at the surface

The problems are evident:

  • The two glass blocks are of different thicknesses, yet they are exactly the same level of blue.
  • The inner sphere is darker than the outer one.

Why does this happen?

Consider a light ray that enters a glass object. If the color is located at the surface, the ray is colored somewhat as it enters the object, retains this color through the object, and receives a second coloration (attenuation) when it exits the object:

Diagram for glass with color changes at the surface

In the above illustration the ray enters from the left, and at the entry surface it drops in level and gets slightly darker (the graph illustrates the level schematically). It retains this color throughout its travel through the medium and then drops in level again at the exit surface.

For simple glass objects this is quite sufficient. For any glass using Thin-walledit is by definition the correct thing to do, but for any complex solid it is not. It is especially wrong for negative spaces inside the glass (like the sphere in our example) because the light rays have to travel through four surfaces instead of two, getting two extra steps of attenuation at the surface.

In real colored glass, light travels through the medium and is attenuated as it goes. In the Arch & Design material this is accomplished by turning on Advanced Rendering Options > Refraction > Max Distance, setting the Color At Max Distance, and setting the Refraction Color to white. This is the result:

Glass with color changes within the medium

The result is clearly much more satisfactory: The thick glass block is a deeper blue than the thin one, and the hollow sphere now looks correct. In diagram form it looks as follows:

d=Max Distance where attenuation is Color at Max Distance

The ray enters the medium and is attenuated throughout its travel. The strength of the attenuation is such that precisely the Max Distance (d in the figure) the attenuation matches that of Color At Max Distance. In other words, at this depth the attenuation is the same as was received immediately at the surface with the previous scene. The falloff is exponential, so at double the Max Distance value the effect is that of Color At Max Distance squared, and so on.

There is one minor tradeoff:

To render the shadows of a material correctly using this method, you must either use caustics or make sure mental ray is rendering shadows in Segments mode (see Shadows & Displacement Rollout (mental ray Renderer)).

Using caustics naturally gives the most correct-looking shadows (the above image was rendered without caustics), but requires that the scene has caustic photons enabled and contains a physical light source that shoots caustic photons.

On the other hand, the mental ray Segments shadows have a slightly lower performance than the more widely used Simple shadow mode. But if it is not used, the shadow intensity will not take the attenuation through the media into account properly. However, the image might still look pleasing.

Water and Liquids

Water, like glass, is a dielectric with an IOR of 1.33. Hence, the same principles as for glass (above) apply to bodies of water, which truly need to refract their environment. An example is water running from a tap. Colored liquids use the same principles as colored glass.

Water into wine

To create a liquid in a container, as in the preceding image, it is important to understand how the Arch & Design material handles refraction through multiple surfaces vs. the real-world behavior of light in such circumstances.

What is important for refraction is the transition from one medium to another with a different IOR. Such a transition is known as an interface.

For lemonade in a glass, imagine a ray of light travelling through the air (IOR=1.0). When it enters the glass, it is refracted by the IOR of the glass (1.5). The ray then leaves the glass and enters the liquid; that is, it passes through an interface from a medium of IOR 1.5 to another medium of IOR 1.33.

One way to model this in computer graphics is to make the glass one separate closed surface, with the normals pointing outward from the surface of the glass and an IOR of 1.5, and a second, closed surface for the liquid, with the normals pointing outward and an IOR of 1.33, leaving a small air gap between the container and the liquid.

This approach works, but can cause a problem: When light goes from a higher IOR to a lower there is a chance of an effect known as total internal reflection (TIR). This is the effect you see when diving into a swimming pool and then looking up: You can see the objects above the surface only in a small circle straight above. Anything below a certain angle shows only a reflection of the pool and things below the surface. The larger the difference in the IOR of the two media, the greater the chance of TIR.

So in our example, as the ray goes from glass (IOR=1.5) to air, there is a large chance of TIR. But in reality the ray would move from a medium of IOR=1.5 to one of IOR=1.33, which is a much smaller step with a much smaller chance of TIR. This looks different:

Left: Correct refraction; Right: the “air gap” method

The result on the left is the correct one, but how it is obtained?

The solution is to rethink the modeling, and not to think in terms of media, but in terms of interfaces. In our example, we have three different interfaces, where we can consider the IOR as the ratio between the IORs of the outside and inside media:

  • air-glass interface (IOR=1.5/1.0=1.5)
  • air-liquid interface (IOR=1.33/1.0=1.33)
  • glass-liquid interface (IOR=1.33/1.5=0.8)

In the most common case of an interface with air, the IOR to use is the IOR of the media (because the IOR of air is 1.0), whereas in an interface between two different media, the situation is different.

To correctly model this scenario, then, we need three surfaces, each with a different Arch & Design material applied:

  • the air-glass surface (blue), with normals pointing out of the glass, covering the area where air directly touches the glass, having an IOR of 1.5
  • the air-liquid surface (green), with normals pointing out of the liquid, covering the area where air directly touches the liquid, having an IOR of 1.33
  • the glass-liquid surface (red), with normals pointing out of the liquid, covering the area where the glass touches the liquid, having an IOR of 0.8

The three interfaces for a liquid in a glass

By setting suitable Max Distance and Color At Max Distance values for the two liquid materials (to get a colored liquid), we obtain the glass on the left in the preceding rendered image.

Ocean and Water Surfaces

A water surface is a slightly different matter than a visibly transparent liquid.

The ocean isn’t blue; it is reflective. Not much of the light that penetrates the surface of the ocean gets anywhere of interest. A small amount of light is scattered back up again, doing a bit of literal subsurface scattering.

To make an ocean surface with the Arch & Design material, follow these steps:

  1. Set Diffuse Level to 0.0, Reflectivity to 1.0, and Transparency to 0.0. That’s right: No refraction is necessary.
  2. Set IOR to 1.33 and turn on By IOR (fresnel reflections). Apply an interesting wobbly shader to Bump (Ocean (lume) works well here) and your ocean is basically done.

This ocean has reflections guided only by the IOR. But this might work fine; try it. Just make sure there is something there for it to reflect. Add a sky map, objects, or a just a blue gradient background. There must be something or it will be completely black.

The ocean isn’t blue; the sky is.

For a more tropical look, try setting Diffuse Color to a slightly blue-green color, set the Diffuse Level to a fairly low number such as 0.1, and turn on Do Not Apply Bumps To The Diffuse Shading.

Now you have a base color in the water that emulates the small amount of scattering that occurs in the top level of the ocean.

Enjoy the tropics.

Metal

Metals are reflective, which means they need something to reflect. The best looking metals come from having a true HDRI environment, either from a spherically mapped HDRI photo, or something like the mental ray physical sky.

To create classic chrome, turn off By IOR (fresnel reflections), set Reflectivity to 1.0, 0 degree reflectivity to 0.9 and 90 degree reflectivity to 1.0. Set Diffuse Color to white, and turn on Metal Reflections.

This creates an almost completely reflective material. Tweak the Reflection Glossiness parameter for various levels of blurry reflections. Also consider using the Round Corners effect, which tends to work very well with metallic objects.

Metals also influence the color of their reflections. Because you turned on Metal Reflections, this is already happening; try setting the Diffuse Color to a golden color to create gold.

Try various levels of Reflection Glossiness (with the help of Fast (interpolate) for performance, when necessary).

You can also change the Reflectivity value. This has a slightly different meaning when Metal Material is on; it blends between the reflections (colored by the Diffuse Color) and normal diffuse shading. This allows a blend between the glossy reflections and the diffuse shading, both driven by the same color. For example, an aluminum material would need a bit of diffuse blended in, whereas chrome would not.

Gold, silver, and copper

Brushed Metal

Brushed metal is an interesting special case. In some cases, creating a brushed metal requires only turning down the Reflection Glossiness to a level where you obtain a very blurred reflection. This is sufficient when the brushing direction is random or the brushes are too small to be visible even as an aggregate effect.

For materials that have a clear brushing direction and/or where the actual brush strokes are visible, creating a convincing look is slightly more involved.

The tiny grooves in a brushed metal surface all work together to cause anisotropic reflections. This can be illustrated by the following schematic, which simulates the brush grooves by modeling many tiny adjacent cylinders, shaded with a simple Phong shader:

Many small adjacent cylinders

As you can see, the specular highlights in the cylinders work together to create an aggregate effect which is the anisotropic highlight.

Also note that the highlight isn’t continuous; it is actually broken up into small, adjacent segments. So the primary visual cues that a material is brushed metal are:

  • Anisotropic highlights that stretch out in a direction perpendicular to the brushing direction
  • A discontinuous highlight with breaks in the brushing direction

Many attempts to simulate brushed metals have looked only at the first effect: the anisotropy. Another common mistake is to think that the highlight stretches in the brushing direction. Neither is true.

Hence, to portray brushed metals, it is necessary to simulate these two visual cues. The first is simple: Use Anisotropy and Anisotropy Rotation to make anisotropic highlights. The second can be done in several ways:

  • with a bump map
  • with a map that varies the Anisotropy or Reflection Glossiness values
  • with a map that varies the Reflection Color

Each has advantages and disadvantages, but the one we suggest here is the last one. The reason for choosing this method is that it works well with interpolation.

  1. Create a map for the brush streaks. The possible ways to do this include painting a map in a paint program, or using a Noise map that has been stretched heavily in one direction. The map should vary between middle-gray and white.
  2. Apply this map to the Reflection Color in a scale suitable for the brushing.
  3. Set Diffuse Color to white (or the color of the metal) but set Diffuse Level to 0.0 (or a small value).
  4. Make sure Metal Material is on.
  5. Set Reflection Glossiness to 0.75.
  6. Set Anisotropy to 0.1 or a similar value. Use Anisotropy Rotation to align the highlight properly with the map. If necessary use Anisotropy Channel to base it on the same texture space as the map.

Brushed metal

Set AdSense Channels by Browser, Referrer, etc.

Written October 2nd, 2010
Categories: Articles, Scripting / Programming
No Comments »

Ever wondered how you can set channels in your Google AdSense ad units based on on-the-spot data like user browser or origin? In this quick tutorial I’ll be showing you how to set AdSense channels in order to track statistics based on user browser types, how they arrived at your site, and pretty much anything else.  It all pivots on the google_ad_channel parameter.  For those of you who are extra savvy, here’s a summary:

  1. Build an AdSense ad unit using native code,
  2. Create AdSense channels for your parameters,
  3. Write JavaScript code to detect the value you need to use,
  4. Use the google_ad_channel parameter to track stats on the right channel.

Build an AdSense Ad Unit With Native Code

Creating an AdSense Unit

Creating an AdSense Unit is Easy. Channel setup can be tricky.

Consider the following ad code which would form a regular 300×250.

<script type="text/javascript"><!--
google_ad_client = "ca-pub-xxxxxxxxxxxx1083";
/* Testing 300x250 - Do not target */
google_ad_slot = "1168546099";
google_ad_width = 300;
google_ad_height = 250;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

When you create an ad unit, you’re given a chance to create and assign channels to it. Normally, these channels are going to be set values that are true no matter what. For example, “Medium-Rectangle”, “Above-The-Fold”, and “Articles-Section-Sidebar”. What you can’t seem to set are conditional parameters like “User-Came-From-Google” or “User-On-Firefox”.

Create a Channel for your Parameter

Create an AdSense channel to track your parameter.

Create a new channel to track what you’re looking to gather stats for. This could be just about anything, but for this example I’m going to create 5 channels

  • “Users from Google”,
  • “Users from Bing”,
  • “Users from Yahoo”,
  • “Users from 3rd Party Sites”,
  • and “Internal Link – No Referrer”.

When you create these channels, you’ll see that each one has a 10-digit ID number in the “ID” column.  Take note of that- we’ll need it later!

Write JavaScript to Detect Parameter Values

At this point, you’ll need to write JavaScript code to detect the parameter you want to track.  In our case, it’s going to be bucketing where the user is coming from when they load a page.  I’ll also include code for tracking users by browser, but the sky is the limit on this technique!

Tracking AdSense Metrics by Referrer

In order to attach the appropriate channel ID based on referrer, we need to build code that determines the user’s origin.  Consider the following:

<script type="text/javascript">
var adsense_referrer = document.referrer;
var adsense_referrer_channel = "0123456789";  // Set a default value, like "Users from 3rd Party Sites" channel.

if (adsense_referrer.search(/google\.*/i) != -1)
    adsense_referrer_channel = "1234567890"; // Set to "Users from Google" channel.

else if (adsense_referrer.search(/bing\.*/i) != -1)
    adsense_referrer_channel = "2345678901"; // Set to "Users from Bing" channel.

else if (adsense_referrer.search(/yahoo\.*/i) != -1)
    adsense_referrer_channel = "3456789012"; // Set to "Users from Yahoo" channel.

else if (adsense_referrer.search(/mrbluesummers\.*/i) != -1 || !adsense_referrer)
    adsense_referrer_channel = "4567890123"; // Set to "Internal Link - No Referrer" channel.
</script>

Tracking AdSense Metrics by Browser

You can follow the above system for assigning a channel value, but the difference here is that you’ll pivot on detecting the name of the user’s browser. There’s an excellent (long) article on how to use JavaScript to detect the user’s browser. It’s a little trickier than working with referrer because there’s so many browsers, so I’ll leave it to you.

Use the google_ad_channel Parameter to Track Metrics

At this point, you can just insert your new channel into the ad code using the google_ad_channel parameter.  This will append the value to your channels, not overwrite them! So, for example, if you have two channels in your ad unit- “Sports” and “Leaderboard”- you’ll now have 3 channels- “Sports, “Leaderboard”, and “Users from Google”.  Note that if you want to use more than one channel, the google_ad_channel parameter is an array of strings, so just stack up your strings as an array and you can get even more powerful reporting!

<script type="text/javascript"><!--
google_ad_client = "ca-pub-8741444217221083";
/* Testing 300x250 - Do not target */
google_ad_slot = "1168546099";
google_ad_width = 300;
google_ad_height = 250;
google_ad_channel = adsense_referrer_channel;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script>

3d Studio Max Arch & Design Preset Examples

Written September 26th, 2010
Categories: Articles, Rendering / Compositing, Textures / Materials
10 comments

The Arch & Design material presets.

In October of 2006, Autodesk implemented a material type called the “Arch & Design” material for the 3d Studio Max implementation of mental ray.  This material type is an elaborate construct of mental ray shaders and includes a useful set of preset material configurations that- with proper lighting- can make any render look special.

Today we’re going to take a deep dive into each one of these mental ray material presets.  By the end of this tutorial you’ll have a firm grasp over what each material does and when to use it.  One thing I’d like to note is that the 3dsMax documentation in this area is spectacular.

The material has a number of significant features:

  • Easy to use, yet flexible – more complicated than VRay, but much simpler than the usual mental ray standard.
  • Templates – allow fast access to settings combinations for common materials.
  • Physically accurate – the material is energy conserving, making it impossible to create shaders that break the laws of physics.
  • Glossy performance – advanced performance boosts including interpolation, emulated glossiness, and importance sampling.
  • Tweakable BRDF – the user can define how reflectivity depends on angle.
  • Transparency – “Solid” or “thin” materials: transparent objects such as glass can be treated as either solid or thin.
  • Round corners – simulate fillets to allow sharp edges to still catch the light in a realistic fashion.
  • Indirect Illumination control – set the final gather accuracy or indirect illumination level on a per-material basis.
  • Built-in Ambient Occlusion – for contact shadows and enhancing small details.
The Arch & Design Material Window

The Arch & Design Material Window

The Arch & Design Default

Let’s take a render of the mental ray Arch & Design material’s default configuration.  For this tutorial, we’ll be using the Stanford Dragon Model scene.  The grey material has some glossiness and specularity, but no special effects like blurring or transparency.

Arch & Design Defaults Render

Arch & Design defaults to a glossy grey material.

The Arch & Design Presets

There are 28 individual presets in the 3d Studio Max Arch & Design material, of which only 23 are full materials.  Let’s take a quick look at each one and get a feel for what it’s used for.  Below is a high resolution render showing you what each material looks like relative to one another.  While some of the more elaborate ones like masonry aren’t too impressive, the basic materials like copper and solid glass are excellent.

The Arch & Design material presets.

Let’s look more closely at each one of these presets and how they differ from each other.  Remember that the render above is using one of the free high-resolution HDRI maps and smart lighting, while the images below are using a plain white background and some big area lights.  That’s a recipe for some pretty ugly renders, so don’t look at these materials and gag right away.  Remember that they look good under the right lighting.

Satin Varnished Wood

Satin Varnished Wood

The satin varnished wood material is a reasonable wood material that is fine for most purposes.  It includes a diffuse map that gives it a grain, but you’ll need UVW mapping in order for it to look right.  The satin finish means that there’s little glossiness/specularity so this might be appropriate for construction sites or old toys.

Glossy Varnished Wood

The glossy varnished wood material is very similar to the satin wood above.  The main difference is in the reflection, glossiness, and specularity parameters.  Whereas you’d select satin varnished wood for more rural wood selections, you’d pick glossy varnished wood as a base material for flooring or for polished wood furniture.

Glossy Varnished Wood

Rough Concrete

Rough concrete is a strong selection for more distant 3d objects like roads, sidewalks, and buildings.  However, you probably would select your own bitmap for close up objects, or use a different material entirely.

Rough Concrete

Polished Concrete

Polished concrete removes the bump map from the regular rough concrete material, and has higher specularity and glossiness settings.  This is a great choice for floors in showr0oms or clean warehouses.

Polished Concrete

Glazed Ceramic

Glazed ceramic is your basic DGS material in mental ray.  It’s a typical medium glossiness/specularity material with some light reflections.

Glazed Ceramic

Glazed Ceramic Tiles

Glazed ceramic tiles is a twist on the ordinary glazed ceramic material where a tile bump/color map has been added.  While you have to dig down into the material in order to access the tile parameters like size and spacing, it does give you a quick way to get to tiled materials that look pretty convincing.

Glazed Ceramic Tile

Glossy Plastic

Glossy plastic is similar to the ceramic material but with different reflection falloff parameters.

Glossy Plastic

Matte Plastic

Matte plastic removes most of the reflection from the plastic material above, and tones down the specularity and reflection significantly.  This is approximately the same as the “Wall Paint” pro material type.

Matte Plastic

Masonry

The masonry material can be difficult to work with since getting realistic results often requires manipulating diffuse maps.  Masonry is another good choice for distant objects.

Masonry

Rubber

The rubber material is a little too specular for my tastes, but ultimately a convincing material under realistic lighting conditions.  This material is more like industrial rubber rather than tire rubber, so for automotive renders consider reducing the specularity/glossiness further to get a dirtier look.  The Oren-Blinn shader should help also.

Rubber

Leather

The leather material is a dark, rough, but glossy material suitable for a wide variety of skins and clothing.  You’ll need a convincing diffuse map in order to achieve superior results.

Leather

Glass (Thin Geometry)

The thin geometry glass material is made for objects that are made of a single sheet of polygons or very thin closed geometry like soap bubbles.  In the case of thin geometry, the material is instructing mental ray to render the surface as two-sided such that the render is extremely fast for translucent objects and light is still colored as it exits the object.

Glass, Thin Geometry

Glass (Solid Geometry)

The solid geometry glass material is the usual one-sided glass material we’re all used to.  As light enters one side of the object it undergoes refraction and this process occurs again as light exists the other side of the object.  In this case, the material is still an approximation, so light traveling through the object isn’t colored based on distance, but instead based on the number of times it enters/exits the 3d object.  You’ll notice that thick and thin areas of the object below undergo the same coloration.

Glass, Solid Geometry

Glass (Physical)

The physical glass material takes the longest to render, but yields excellent results.  The difference with this material is that light is colored based on how long it travels inside of the object.  Thus thick parts of the object below are colored with a deeper blue while thinner areas get less coloration.

Glass, Physical

Translucent Plastic Film (Thin)

The translucent plastic film material is similar to the thin geometry glass material in that it is meant for extremely thin objects and for “one-way trips” through geometry.  The thin translucent material allows a face illuminated on it’s normal side to illuminate it’s backside, too.

Translucent Plastic Film, Thin

Translucent Plastic Film (Opaque)

The opaque translucent plastic film material allows solid geometry to have a translucent effect.  This is useful for objects with closed geometry, but is computationally more expensive than the equivalent thin material.

Translucent Plastic Film, Opaque

Water, Reflective Surface

The reflective water surface material is actually not transparent and a great proxy for water at shallow angles and/or at a distance from the camera.  Consider using it whenever possible to save render time.

Water, Reflective Surface

Chrome

The chrome material is simply a 100% reflective material.  This is useful for extremely clean, polished metal surfaces.

Chrome

Brushed Metal

The brushed metal material is a chrome material with blurred reflections.  This is suitable for most metal objects.

Brushed Metal

Satin Metal

The satin metal material is like the brushed metal material but with even more blurred reflections.  This is suitable for stainless steel.

Satined Metal

Copper

The copper material is a very shiny colored metal.  It’s closer to brass in my opinion, but it still responds well to realistic lighting and HDRI.  Use it in darker renders if possible since with this white background it looks like gold.

Copper

Patterned Copper

The patterned copper material is a darker, duller version of the copper material with an added glossiness, specularity, and reflection shader.

Patterned Copper

My New Circuit-Bent Speak & Read

Written September 21st, 2010
Categories: Blog, Videos
2 comments

This is my new circuit-bent speak & read. For those unfamiliar with this kind of thing, there are people who open up old Gameboy or Speak & Spell equipment and modify it to play music or make unusual sounds. It’s a pretty awesome toy.

I bought it at a store here in San Francisco called Robot Speak that sells all kinds of computerized music equipment. The video was recorded simultaneously with separate tracks. The audio came from my headset while the video came from my Nexus One.

Despite the outpouring of negative feedback for this video, I’ve decided to post it to my blog anyway.  While I understand that most (all) of you are eagerly awaiting additional 3dsMax instruction, it’s coming time that I start branching out this blog into other interests.

That doesn’t mean I’ll abandon the article I’m writing about mental ray ProMaterials though.  Expect that after my travels are complete in October.

W3 Total Cache, YARPP, and mySQL: A deadly combo

Written September 18th, 2010
Categories: Articles, Blog, Scripting / Programming
2 comments

Last night I got an e-mail at 2:00 am from Bluehost stating that my account was being blocked for excessive resource use.  Naturally, I was not happy because it was very late at night, I was a few beers in and couldn’t see straight, and the e-mail was totally out of the blue.  Take a look:

Dear Alejo:

Your web hosting account for **************.com has been deactivated, as of 09/18/2010. (reason: site causing performance problems)

This deactivation was due to a Terms of Service violation associated with your account. At sign-up, all users state that they have read through, understand, and agree to our terms. These terms are legal and binding.

Although your web site has been suspended, your data may still be available for up to 15 days from the date of deactivation; if you do not contact us during that 15 day period, your account and all of its files, databases, and emails may be deleted.

If you feel this deactivation was made in error, or in order to gain access to your account, please call our customer service line as soon as possible at (***) ***-4678.
Please read the following, derived from our Terms of Service agreement, for additional information regarding the matter.

Engaging in any activity that, in BlueHost.Com’s sole and absolute discretion, disrupts, interferes with, or is harmful to (or threatens to disrupt, interfere with, or be harmful to) BlueHost.Com’s services, BlueHost.Com’s business, operations, reputation, goodwill, subscribers and/or subscriber relations, or the ability of BlueHost.Com’s subscribers to effectively use BlueHost.Com’s services is prohibited.

Please review the current copy of our Terms of Service here:
http://www.bluehost.com/cgi/terms

Thank you,
BlueHost.Com Technical Support

I immediately called them up to get more information, and got to talk to a nice gal in tech support right away.  She looked up my account.

Yah, we’re not sure what your site is doing but you’re putting some heavy strain on that mySQL server you’re sharing.

“Absurd! My site only gets a few thousand hits per day.  There’s no way I’m dragging things down.”

Nope, it says right here.  In the last few days you’ve moved 1.9 terabytes in and out of the ****** and ******* tables.

I’ll show these dunderheads.  I logged in to my PHPMyAdmin and quickly found out that she was right.

Well this isn't good.

So a few diagnostics later, we figured out the problem.  My W3 Total Cache (W3TC) plugin was set to automatically pre-cache pages at a rate of 10 pages per minute.  Combined with a relation-intensive plug-in like the Yet Another Related Posts Plugin (YARPP) this meant that the server was hitting the database for the wp_term_relationships table hundreds of times per minute.  This created a stupid amount of database traffic.

I think you may have a point Julie at Bluehost…

The moral of the story here is that you should be really careful with what your plug-ins are doing and how they might interact with each other.  And take frequent backups- you never know when your host will drop a bombshell on you.

Mr. Bluesummers Goes On A Trip – Part 1

Written September 17th, 2010
Categories: Blog
1 Comment »

In the interest of beefing out a real “blog” section I thought I’d talk a little bit about real life.

As some of you know, I don’t work in the industry.  I have an ordinary desk job helping people make money with online advertising.  The nice kind, not the annoying kind.  Well that desk job is about to send me on a 3 week trip around the world to make everyone some money.  It would be pretty sweet to make a project out of this, so I’m going to post my itinerary and hope that you can help me think of something totally sweet to try.

Here’s the rundown.  Starting Sunday the 19th…

  1. Fly to New York City.  This is the easy part.  I’m bringing LSDJ and I want to learn how to use it.
  2. Stay in New York until Wednesday, brainstorming with smarter people and hugging our engineers because they tolerate us in Ops pretty well.
  3. Wednesday I fly down to Austin TX to meet up with some friends and be reminded that there’s no place like Texas.
  4. On Thursday I fly back to SF to get my bearings, sleep comfy for a few nights, and get a Star Craft 2 fix.
  5. Then on Sunday (09/26) I fly back to New York City as a layover to Dublin, Ireland.
  6. It’s a full week of rocking out with other kids in operations with trainings, coaching clients, and making everyone some money.
  7. Go partying with the Dubliners as often as possible and as hard as possible without requiring hospitalization.
  8. Then the following Saturday it’s off to Paris to spend some time with family and get put in my place for only speaking English like an idiot American.  I also can’t readily distinguish between a Chardonnay and a Pinot Grigio which probably won’t win me any points either.
  9. Then on Wednesday it’s a grueling 2 day flight that would have taken two months by boat a few hundred years ago.  What an inconvenient distance!

On the one hand, this means I get to see the world and hang out with people that I only really know as e-mail addresses right now.  On the other hand, it means working while under the stresses of jet lag, language barriers, and my regular workload.

Anyway, if anyone has any ideas on a neat project to go with this that doesn’t get me hurt or fired I’m all ears.

More to follow as it happens!

MrBluesummers.com Back Online

Written September 12th, 2010
Categories: Blog
11 comments

Thanks for taking the downtime like a trooper.  The website is back online, and better than ever.  I’ve got big plans for this new revision!

For your information, check out the stats below.  Taken before and after the front-end revision.

Performance metrics before and after WordPress theme change

The new site is about 20% as big as the old site, and more flexible, too!

Pending Redesign Launch

Written September 8th, 2010
Categories: Blog
2 comments

Hey all,

Just wanted to let you guys know that I’ve been working off and on with a site change. It’s mostly thematic and color changes based on the feedback I got for the old CGCodex project.

Why are you doing this?

The fact is that the current site isn’t as flexible as I once thought, and this gives me more ability to make changes and improvements in the future.  It loads faster for people in other countries, too.  Yes, Brazil; I know you’re watching and this is my way of thanking you!

Anyway, there are a lot of things I want to fix but I’ll roll out the first version this week.

We want more tutorials!

I know.  I’m in the middle of serious real-life stuff at the moment that prevents me from taking the kind of 4-hour work sessions needed to build up a real tutorial.  Luckily it doesn’t prevent me from taking 10 minutes here and there to keep working on a new blog interface.  If things back off a little this weekend I’ll hammer away at that Arch & Design tutorial I’ve got coming up.

mental ray Arch & Design Overview

Written September 7th, 2010
Categories: Articles, Rendering / Compositing, Textures / Materials
1 Comment »

This is a duplicate of the Arch & Design Overview document by Autodesk and not written by Mr. Bluesummers.

This topic serves as an introduction to the Arch & Design material for mental ray.

A range of material effects available with the Arch & Design material.

What Is the Arch & Design Material?

The mental ray Arch & Design material is a monolithic material shader designed to support most materials used in architectural and product-design renderings. It supports most hard-surface materials such as metal, wood and glass. It is especially tuned for fast glossy reflections and refractions (replacing the DGS material) and high-quality glass (replacing the dielectric material).

The major features are:

  • Easy to use, yet flexible – controls are arranged logically in a most-used-first fashion.
  • Templates - allow fast access to settings combinations for common materials.
  • Physically accurate – the material is energy conserving, making it impossible to create shaders that break the laws of physics.
  • Glossy performance – advanced performance boosts including interpolation, emulated glossiness, and importance sampling.
  • Tweakable BRDF (bidirectional reflectance distribution function) – the user can define how reflectivity depends on angle.
  • Transparency – “Solid” or “thin” materials: transparent objects such as glass can be treated as either solid (refracting, built out of multiple faces) or thin (nonrefracting, can use single faces).
  • Round corners – simulate fillets to allow sharp edges to still catch the light in a realistic fashion.
  • Indirect Illumination control – set the final gather accuracy or indirect illumination level on a per-material basis.
  • Oren-Nayar diffuse – allows “powdery” surfaces such as clay.
  • Built-in Ambient Occlusion – for contact shadows and enhancing small details.
  • All-in-one shader – photon and shadow shader built in.
  • Waxed floors, frosted glass and brushed metals – all fast and easy to set up.

Physics and the Display

The Arch & Design material attempts to be physically accurate, hence its output has a high dynamic range. How visually pleasing the material looks depends on how colors inside the renderer are mapped to colors displayed on the screen.

When rendering with the Arch & Design material it is highly recommended that you operate through a tone mapper/exposure control such as the mr Photographic Exposure Control in conjunction with gamma correction, or at the very least use gamma correction.

A Note on Gamma

Describing all the details of gamma correction is beyond the scope of this topic; this is just a brief overview.

The color space of a normal, off-the-shelf computer screen is not linear. The color with RGB value 200 200 200 is not twice as bright as a color with RGB value 100 100 100, as one might expect.

This is not a bug because, due to the fact that our eyes see light in a nonlinear way, the former color is actually perceived to be about twice as bright as the latter. This makes the color space of a normal computer screen roughly perceptually uniform. This is a good thing, and is actually the main reason 24-bit color (with only 8 bits or 256 discrete levels for each of the red, green and blue components) looks as good as it does to our eyes.

The problem is that physically correct computer graphics operates in a true linear color space where a value represents actual light energy. If one simply maps the range of colors output to the renderer naively to the 0–255 range of each RGB color component it is incorrect.

The solution is to introduce a mapping of some sort. One of these methods is called gamma correction.

Most computer screens have a gamma of about 2.2 (known as the sRGB color space), but 3ds Max defaults to a gamma of 1.8, which makes everything look too dark (especially midtones), and light does not “add up” correctly.

Using a gamma of 2.2 is the theoretically correct value, making the physically linear light inside the renderer appear in a correct linear manner on screen.

However, because the response of photographic film isn’t linear either, users find that this theoretically correct value looks too bright and washed out. A common compromise is to render to the default gamma of 1.8, making things look more photographic; that is, as if the image had been shot on photographic film and then developed. However, when exporting and importing images (for example, as texture maps) with external image-editing programs, for best results set all gamma values on Preferences > Gamma and LUT Preferences to 2.2.

Tone Mapping

Another method for mapping the physical energies inside the renderer to visually pleasing pixel values is known as tone mapping. You can accomplish this either by rendering to a floating-point file format and using external software, or with a plug-in that allows the renderer to do it on the fly. In 3ds Max such plug-ins are known as exposure controls and are accessed from the Environment dialog.

Use Final Gathering and Global Illumination

The Arch & Design material is designed to be used in a realistic lighting environment; one that incorporates full direct and indirect illumination.

mental ray provides two basic methods for generating indirect light: Final Gathering and Global Illumination. For best results, be sure to use at least one of these methods.

At the very least, enable Final Gathering, or use Final Gathering combined with Global Illumination (photons) for quality results. Performance tips for using Final Gather and Global Illumination can be found here.

If you use an environment for your reflections, make sure the same environment (or a blurred copy of it) is used to light the scene through Final Gathering. In 3ds Max this means you should include a Skylight in your scene set to Use Scene Environment, or use Daylight system with Skylight set to mr Sky.

Use Physically Correct Lights

Traditional computer-graphics light sources live in a cartoon universe where the intensity of the light doesn’t change with the distance. The real world doesn’t agree with that simplification. Light decays when leaving a light source due to the fact that light rays diverge from their source and the intensity of the light changes over distance. This decay of a point light source is 1/d2; in other words, light intensity is proportional to the inverse of the square of the distance to the source.

One of the reasons for this traditional oversimplification is the fact that in the early days of computer graphics, tone mapping was not used and problems of colors blowing out to white in the most undesirable ways was rampant. (Raw clipping in sRGB color space is displeasing to the eye, especially if one color channel clips earlier than the others. Tone mapping generally solves this by “soft clipping” in a more suitable color space than sRGB.)

However, as long as only Final Gathering (FG) is used as indirect illumination method, such traditional simplifications still work. Even light sources with no decay still create reasonable renderings. This is because FG is concerned only with the transport of light from one surface to the next, not with the transport of light from the light source to the surface.

It’s when working with Global Illumination (GI) (that is, with photons) the troubles arise.

When GI is enabled, light sources shoot photons. For the Arch & Design material (or any other mental ray material) to be able to work properly, it is imperative that the energy of these photons to match the direct light cast by that same light. And since photons model light in a physical manner, decay is built in.

Hence, when using GI:

Light sources must emit photons at the correct energy.
The direct light must decay in a physically correct way to match the decay of the photons.
Therefore it is important to make sure the light shader and the photon emission shader of the lights work well together.

In 3ds Max this is most easily solved by using the photometric lights. All of these lights are guaranteed to have their photon energy in sync with their direct light. It is built in and automatic and one does not need to worry about it.

Features

The Shading Model

From a usage perspective, the shading model consists of three components:

  • Diffuse - diffuse channel /including Oren Nayar “roughness”).
  • Reflections - glossy anisotropic reflections (and highlights).
  • Refraction - glossy anisotropic transparency (and translucency).

The Arch & Design material shading model

Direct and indirect light from the scene cause diffuse reflections as well as translucency effects. Direct light sources also create specular highlights.

Ray tracing is used to create reflective and refractive effects, and advanced importance-driven multi-sampling is used to create glossy reflections and refraction.

The rendering speed of the glossy reflections/refraction can further be enhanced by interpolation as well as “emulated” reflections with the help of Final Gathering.

Conservation of Energy

One of the most important features of the material is that it is automatically energy conserving. This means that it makes sure that diffuse + reflection + refraction <= 1. In other words, no energy is magically created and the incoming light energy is properly distributed to the diffuse, reflection and refraction components in a way that maintains the first law of thermodynamics.

In practice, this means, for example, that when adding reflectivity, the energy must be taken from somewhere, and hence the diffuse level and the transparency will be automatically reduced accordingly. Similarly, adding transparency happens at the cost of the diffuse level.

The rules are as follows:

  • Transparency takes energy from diffuse; that is, at 100% transparency, there is no diffuse at all.
  • Reflectivity takes energy from both diffuse and transparency; that is, at 100% reflectivity there is neither diffuse nor transparency.
  • Translucency is a type of transparency, and the Translucency Weight parameter defines the percentage of transparency vs. translucency.

From left to right: Reflectivity=0.0, 0.4, 0.8, and 1.0

From left to right: Transparency=0.0, 0.4, 0.8, and 1.0

Conservation of energy also means that the level of highlights is linked to the glossiness of a surface. A high Reflection Glossiness value causes a narrow, intense highlight, while a lower value causes a wider, less intense highlight. This is because the energy is now spread out and dissipated over a larger area.

BRDF: How Reflectivity Depends on Angle

In the real world, the reflectivity of a surface is often view-angle dependent. A fancy term for this is bidirectional reflectance distribution function (BRDF); that is, a way to define how much a material reflects when seen from various angles.

The reflectivity of the wood floor depends on the view angle.

Many materials exhibit this behavior. The most obvious examples are glass, water, and other dielectric materials with Fresnel effects (where the angular dependency is guided strictly by the index of refraction), but other layered materials such as lacquered wood and plastic display similar characteristics.

The Arch & Design material allows this effect to be defined by the index of refraction, and also allows an explicit setting for the two reflectivity values for:

  • 0 degree faces (surfaces directly facing the camera)
  • 90 degree faces (surfaces 90 degrees to the camera)

Reflectivity Features

The final surface reflectivity is in reality caused by the sum of three components:

  • The diffuse effect
  • The actual reflections
  • Specular highlights that simulate the reflection of light sources

Diffuse, reflections, and highlights

In the real world, highlights are just glossy reflections of the light sources. In computer graphics it’s more efficient to treat these separately. However, to maintain physical accuracy the material automatically keeps highlight intensity, glossiness, anisotropy, etc. in sync with the intensity, glossiness and anisotropy of reflections. Thus, there are no separate controls for these as both are driven by the reflectivity settings.

Transparency Features

The material supports full glossy anisotropic transparency and includes a translucent component, described in detail here.

Translucency

Solid versus Thin-Walled

The transparency/translucency property can treat objects as either solid or thin-walled.

If all objects were treated as solids at all times, every window pane in an architectural model would have to be modeled as two faces: an entry surface that refracts the light slightly in one direction, and immediately following it an exit surface, where light is refracted back into the original direction.

Not only does this entail additional modeling work, it is a waste of rendering power to simulate refraction that has very little net effect on the image. Hence the material allows modeling the entire window pane as a single flat plane, foregoing any actual refraction of light.

Solid vs. thin-walled transparency and translucency

In the preceding illustration the helicopter canopy, the window pane, the translucent curtain, and the right-hand sphere all use thin-walled transparency or translucency, whereas the glass goblet, the plastic horse, and the left-hand sphere all use solid transparency or translucency.

Cutout Opacity

Beyond the “physical” transparency, which models an actual property of the material, the material provides a completely separate, non-physical “cutout opacity” channel to allow “billboard” objects such as trees, or to cut out objects such as a chainlink fence with an opacity mask.

Special Effects

Built-in Ambient Occlusion

Ambient Occlusion (AO) is a method spearheaded by the film industry for emulating the look of true global illumination by using shaders that calculate the extent to which an area is occluded, or prevented from receiving incoming light.

Used alone, an AO shader, such as the separate mental ray Ambient/Reflective Occlusion shader, creates a grayscale output that is dark in areas light cannot reach and bright in areas where it can:

The following image illustrates the main results of AO: dark crevices and areas where light is blocked by other surfaces, and bright areas that are exposed to the environment.

An example of AO applied to a scene

One important aspect of AO is that the user can how far it looks for occluding geometry.

AO looked up within a shorter radius

Using a radius creates a localized AO effect: Only surfaces within the given radius are considered as occluders. This also speeds up rendering. The practical result is that the AO provides nice “contact shadow” effects and makes small crevices visible.

The Arch & Design material gives you two ways to utilize its built-in AO:

  • Traditional AO for adding an omnipresent ambient light that is then attenuated by the AO to create details.
  • Use AO for detail enhancement together with existing indirect lighting methods such as Final Gathering or photons.

The latter method is especially interesting when using a highly smoothed indirect illumination solution, such as a high photon radius or an extremely low final gather density, which could otherwise lose small details. By applying the AO with short rays these details can be brought back.

Round Corners

Computer-generated imagery tends to look unrealistic, partly because edges of objects are geometrically sharp, whereas most edges in the real world are slightly rounded, chamfered, worn, or filleted in some manner. This rounded edge tends to “catch the light” and create highlights that make edges more visually appealing.

The Arch & Design material can create the illusion of rounded edges at render time. This feature is intended primarily to speed up modeling, so that you need not explicitly fillet or chamfer edges of objects such as a tabletop.

Left: No round corners; Right: Round corners

The function is not a displacement; it is merely a shading effect, like bump mapping, and is best suited for straight edges and simple geometry, not advanced, highly curved geometry.

Performance Features

Finally, the Arch & Design material contains a large set of built-in functions for optimal performance, including but not limited to:

  • Advanced importance sampling with ray rejection thresholds
  • Adaptive glossy sample count
  • Interpolated glossy reflection/refraction with detail enhancements
  • Ultra-fast emulated glossy reflections (Highlights+FG Only mode)
  • The option to ignore internal reflections for glass objects
  • The choice between traditional transparent shadows, suitable for objects such as a window pane, and refractive caustics, suitable for solid glass objects, on a per-material basis.
Designed by Alejo "Mr. Bluesummers" Grigera"
©2012 MrBluesummers.com