djRivet.mel updated to 1.5.5

david | mel script | Wednesday, August 29th, 2007

Just a quick update to correctly detect maya8.5 sp1 and improved error handling if an objects transforms are already animated.

Download here.

physical_light and areaLight

david | mentalray,rendering,tutorials | Friday, August 24th, 2007

Today I read a post on CGTalk that brought to my attention something I hadn't noticed before about area lights and mentalray. Prior to maya 8, if you wanted an area light in mentalray you would start with a spotlight and set some attributes to turn it into an area light. This changed in maya 8 where the maya areaLight now has a mentalray section with a bunch of new attributes.

The thing I had not noticed is best explained by showing some renders.

The first picture, which I will use as a comparison, is rendered using maya software renderer with raytraced shadows. An areaLight has been scaled into a thin rectangle. (I have positioned a white polygon to give a visual reference of the light's position). The illumination does not look very realistic given the shape of the light.

swAreaRender01.jpg

Here is a snapshot of the areaLight's attributes. Notice that I have set quadratic decay to simulate that of a real light.

swAreaAttr01.jpg

The second picture was rendered using mentalray and I simply enabled the mentalray area light with the "Use Light Shape" flag. (The white polygon is no longer required since mentalray area lights can be flagged "Visible".) This is worse than the software render - there appears to be no relationship between the shape of the light and the illumination.

mrAreaRender01.jpg

Here is a snapshot of the mentralray tab in the areaLight's attribute editor.

mrAreaAttr01.jpg

The thing is that the walls are brightly illuminated, with a sudden cut off at the height of the light. It is as if the areaLight is extending to infinity and ignoring the shape of the light!

Fortunately the solution to this problem is a simple one. You need to use a mentalray physical_light shader, which you simply connect to the "Light Shader" slot in the "Custom Shaders" tab of the areaLight's attributes.

The third picture is a mentalray render using an areaLight with a physical_light as the light shader. This is a much more convincing result.

mrAreaRender02.jpg

The physical_light has it's own set of attributes with take over most of the funtionality of the areaLight. So here's a snapshot of the areaLight attributes.

mrAreaAttr02.jpg

and the physical_light attributes.

physicalLightAttr01.jpg

Note that the color swatch is used to set the intensity of the light as well as its hue. In my render I set the luminance value of that swatch to 10,000.

The "Cosine Exponent" can be used to control the spread of the light. It is interesting to note that setting it to 0.1 gives a result similar to the render without the physical_light connected. A value of 5.0 makes the light very directional with almost no spread at all.

One more thing. If you go to the trouble of hooking up a physical_light you can get a little bit extra for almost no cost. Make a few copies of the areaLight and hook up the same physical_light to each copy.

hyperShade01.jpg

This is what it looks like rendered using mentalray with three areaLights that share a single physical_light as the light shader.

mrAreaRender03.jpg

shadow attenuation

david | rendering,tutorials | Thursday, August 16th, 2007

The maya shadow attenuation attribute that is in the raytrace options of maya shaders like lambert, blinn and phong, sometimes causes problems for people who either dont know it exists, or dont know what it does. They say "My shader is 100% transparant, but it is still casting a shadow!". They have checked that they are using raytraced shadows and that the shader really is 100% transparant and the trace depths are high enough - but there are still shadows. And if they are really unlucky, some objects with the same shader are working correctly, with no visible shadow.raytraceOptionsAttributeEditor.jpg

The location of the shadow attenuation attribute can be seen here in a snapshot of the raytrace options of a lambert shader's attribute editor. For a new user shadow attenuation appears to be related to refraction (easy to see why) and so in the beginning they may just ignore it if they are not doing refraction. The problem is that shadow attenuation is active regardless of whether refraction is enabled and its default value is 0.5 (It would probably have been better if this defaulted to zero).

In the pictures that follow I will demonstrate the effect of the shadow attenuation with values of 0.0, 0.5 and 1.0 and show how the orientation of the surface normal relative to the light direction changes the result.

Here's a wireframe of my test setup:

setup1_camView.jpg

And here are three different renders, with a side view wireframe inset at top right.

example_noVisibleShadows.jpg

example_withVisibleShadows.jpg

example_withSphereShadows.jpg

Render A shows that if the surface normal is parallel with the light direction then there is no shadow attenuation effect at all, resulting in no visible shadows.

Render B shows that when the light passes through the surface at an angle then non-zero shadow attenuation causes a shadow even when the shader is 100% transparant.

Render C shows why the shadow attenuation can be very useful for creating shadows that look more realistic when transparant surfaces are involved.

NOTE: shadow attenuation works in both the maya software render and mentalray-for-maya.

Powered by WordPress | Based on a theme by Roy Tanck