Showing posts with label mental ray. Show all posts
Showing posts with label mental ray. Show all posts

2008-08-28

Max 2009 Lighting Analysis

If you haven't played with Max 2009's new lighting analysis tool, it's definitely worth checking out. For this blog I will briefly explain how to use it.



Before I jump into lighting analysis, I have a disclaimer for lighting studies/software. When it comes to lighting analysis, the results are just estimates on how much lighting a space is receiving. There are too many physical factors to be accurate. Materials have to act exactly as they do in reality to bounce light properly. This includes physical characteristics as index of refraction/reflection, caustics etc. Max does a pretty darn good job at simulating these though, so good infact that it is recognized by LEED as program for obtaining lighting analysis credits.

With that said, here is a quick look at how we set a scene up. Firstly, be sure the space you are modeling, is as accurate as possible. The windows need to be the right size, and there cannot be any openings in the space other than the windows. Secondly be sure that the materials you are using are either all ProMaterials or A&D materials, and they act as the material would in real life (tile being reflective, gyp being non-reflective, etc). One of the most important materials is the glass, because it will determine how and how much light will enter the space. The way the glass is modeled is important as well. If the glass is a single plane, in your glass A&D material be sure to specify under the "Advanced Rendering Options" that it "Thin-walled". If your glass has a thickness or it is a box, just leave the setting on "Solid". Thirdly, the lighting must be accurate and represent true-life physical amounts. Creating a Daylight system is the best way to achieve physical properties for your sun, just don't mess with the multiplier amounts. If you also want to include light fixtures the best type of light for this are photometric lights.




Once you have your scene set up, in the menu under"Lighting Analysis" use the "Lighting Analysis Assistant." Basically this box checks your scene to make sure that you don't have any un-natural materials or lights. If you do, it will tell you how many materials and lights need to be tweaked. The "Analysis Output" tab is where you can create a light meter. The Light Meter is just a plane that record light data in the scene and spits out numbers of light intensities (measured in foot candles fc or lux). In the US everyting is measured in foot candles, so I use fc. The modifier settings for the light meter controls the amount of segments, orientation arrows, type of illuminance, and it can export the numbers to an excel csv file.

For the lighting analysis, you will only get figures for where the planes are. So if you need all four walls of room, you will need 4 light meters, one for each wall. Note: the lighting analysis is no gauge on how the scene will render. Much like a camera, you can make a very dark room appear light with the right exposure settings. The exposure settings also don't have any effect on the lighting analysis since these numbers are fixed amounts of energy.

2008-07-05

Ambient Occlusion with Transparency!

I ran into a scene where I wanted to render an ambient occlusion (AO) pass, but certain objects were using transparency maps as cutouts. So when I rendered the AO pass, those objects with transparency maps turned out solid...not the desired result.

Disclaimer: This is some-what of a half solution for AO with transparencies. AO works based on geometry proximity and does not take into account mapping. So this solution is an approximation. With that said, lets take a look at AO with transparencies.

I'm going to explain how you can render an AO pass while keeping the transparency of certain objects, just using the mental ray and A&D shaders. The example I'm using here is a tree textured with A&D materials.




The leaves on the tree are simply planes, but when rendered you see the leaves, because the planes have a alpha-map of the leaves in the cutout slot of the A&D material.










When you render an AO pass (click here to go to my AO in mental ray posting), the transparency on the leaves go away and the occlusion shows the planes. Of course this is not what we're wanting.











So to render an AO pass with transparency, there are regular objects and there are the objects that we want with transparency. So we will need 2 AO shaders. The first is my regular AO shader, and the second is one with transparency. There is a trick to creating the AO shader with transparency. I create a mental ray material, and in the first slot I insert a mix map. In color #1 I insert a "material to shader". That shader is an A&D material, where I turned up the refraction to 1.0, the IOR to 1.0. For color #2, I use my regular AO shader, and for the mix amount, I use the leaves transparency map to mix the AO with the 100% transparent A&D shader.




When I render my AO pass the easiest way to do this is plugging in the AO material into the material override in the Processes tab of the Rendering Settings. But it's not enough to insert the AO material with the transparency into the material override, because we also have regular objects that shouldn't render with the leaves transparency. To overcome this problem I create "Sub-Object" material shader, with ID 1 being the regular AO shader and ID 2 being the AO shader with transparency. I plug the Sub-Object material into the material override.


Then I select all of the objects in my scene (in this case it's the tree trunk), and apply a material modifier to assign the material ID to 1. Then I select my leaves in the scene and also apply a material modifier, and set the ID to 2.

Presto, the scene is ready for an AO pass with transparencies!

If you have several different transparency maps in one scene, you will have several AO shaders for each transparency, and put them all into the Sub-Object material, then you will need to apply the material modifier with the correct ID to each object for it's respective transparency maps.

2008-06-26

Mental Ray glossy samples

Earilier I wrote about vray dmc glossy samples, so I figured I would do one with mental ray glossy samples as well.



This chart for mental ray takes the combination of samples per pixel vs. A&D material glossy samples.

You decide which one is best for the amount of rendering time. I also found it interesting to compare with the v-ray test and see what overall gave the best performance results.

Check out the pdf, and decide for yourself what are the best settings.

Here's the max file (max 2008, mental ray) if you're interested in the rest of the settings. I was using an hdr map, so you will notice a broken link to that map.

2008-06-11

Translucent leaves

I have been using v-ray for several years but just recently switched to mental ray. If you haven't used mental ray since Max 8 I highly recommend trying the Arch & Design shaders. Continuing to experiment with the A&D shader, I wanted to explore the translucency features. If used properly the results are actually quite convincing.



Translucent leaves


I wanted to create a leaf material that worked similar to how they are perceived in reality. If a leaf is front lit they seem very opaque and specular, but if it is back lit suddenly they take on totally different properties including translucency. I wanted to capture this and apply it to a tree.









With the A&D material, translucency is a factor of the transparency. You will only see the effects of translucency if transparency is higher than 0.0, and you will see the greatest effect if it's cranked up to 1.0.









So I set transparency to 1.0, and to keep it from refracting, I changed the IOR to 1.0 (vacuum). Also to keep it from being transparent I put a Two-Sided base into the color slot. This is what makes the translucency more believable. Of course I turned on Translucency and the value is controlled by an image. For the color of the translucency I chose a light green color based on what a leaf looks like when it's back lit.




The Two-Sided base that controls the transparency value allows each side of a face to take on different properties. For the front side, I didn't want any translucency so the transparency value is black/off. For the back I wanted the translucency to be strong so the value of the transparency is on and controlled by a gray-scale map of leaves. This keeps the leaves from being transparent.

Here is a max file (max 2008) that has a shader with the translucent properties. Just place the appropriate texture maps.

2008-05-26

Ultimate Mental Ray Grass Shader!

I'd been wanting to do this for some time now. I wanted to create a grass shader that would work for every situation. Whether the camera was 500' or 5' from the ground the grass would look good.



mental ray grass shader



There were alot of factors I wanted
to consider when creating this shader. When the camera was far away from the grass I didn't want it to look like repeated tiles of the same grass map. Rather I wanted it to have that random field look, as if you were in a plane looking down of the world. So I created an image map from an aerial photograph of what grass would look like from 500' in the air. From this distance I also knew that having displacement on the grass would be useless from so far away, so I put a falloff in the displacement slot based on distance. So at this distance, displacement wasn't even calculated.








When the camera came closer to the grass, then it would displace the shader. The close up grass also uses a different grass map from the far away grass. For the far away and close up grass, both of them also have a falloff that simulates atmosphere or grass blades on the horizon. So as the grass gets further from the camera the color fades out and gets lighter.












You could use this for v-ray as well, but it's really optimized for mental ray with the mr photographic exposure control (the reason the maps in the output are so dark). I put together a diagram that shows how exactly I created this shader if you're curious.

Here is the max file (max 2008) with the grass shader.

2008-04-30

Ambient Occlusion Pass for interior scenes

There are several ways to render out an ambient occlusion (AO) pass in max with mental ray. However some AO setups require environment changes, and don’t always work with interior scenes. I will explain how to get an AO pass that always works. For those of you who don't know what AO is, it's a method of creating soft shadows in corners where objects meet. It adds an extra sense of reality.

Ambient Occlusion Pass for interior without windows



Create a new mental ray shader. Insert the Ambient/Reflective Occlusion map into the diffuse slot, and put a value in the max distance of the AO map.


In your render settings under the Processing tab turn on Material Override and just click and drag the AO material into the blank material slot under Material Override. Now all of your materials in your scene will use this AO material, even though they still have their own shaders applied to them. Before you render, turn off FG, GI and turn off your exposure. If you don't do this you will get a black rendering. All of these settings will not be lost.


straight render pass before AO is added



Final composite of AO and beauty pass combined


The nice thing about this process is you don't have to turn off or delete any lights in the scene, and you still keep all of your materials intact. When you are done rendering the AO pass just turn back on FG, GI, and your exposure...all of your settings will still remain. Also don't forget to disable the Override Material before you go back to rendering your beauty pass.

2008-04-02

Why does my animation flicker?

It seems like alot of folks on the forums are asking this question. Often when using low GI and Final Gather settings, an animation will flicker because the solution is not refined enough. To have a smooth animation you have to crank up your settings high enough to have similar results for each frame. Problem is you will have extremely long render times. This is my attempt at explaining how to create smooth animations with low indirect illumination settings in Max 2008.


common problem with low GI and Final Gather settings


Here's a quick step-by-step, but if you read further I have exhausted each of these steps in detail.

•Turn on Photon Map, use Read/Write File, then render
•Turn on Final Gather, use Read/Write File
•Lower samples to 1/64 - 1/64
•Render active time segment at every 10 frames
•Turn on final gather Read Only (FG Freeze)
•Increase samples to 1 - 16
•Turn on Save File for Render Output
•Render active time segment at every 1 frame


First we calculate the photon map (PM). When calculating the PM it's a good practice to have final gather (FG) off to see the pure PM results. To save your PM click on the [...] button, and if you are rendering on a renderfarm, be sure to save your PM in a location that the farm has access to (your network). Also be sure "Read/Write File" is checked.



Now go ahead and render a single frame. Mental ray will calculate the PM first, save it to the location you specified, then renders your scene. Very important to note: now the second time you render, mental ray will not re-calculate the PM, but rather read the already calculated PM from the file location you specified because you have "Read/Write File" checked. The PM is scene based rather than view/camera based. This means that when the PM is calculated it is calculating the entire scene (much like radiosity). The great thing about the PM, is that once it is calculated, a rendering can be done from any view using that same PM...wonderful for animations!



Now that we have our PM calculated, we're now going to move onto FG. Unlike the PM, FG is view/camera based. This means that when a FG map is calculated the information in the map is only of that viewing angle. So if you wanted to see both sides of an object, you would need at least 2 FG maps. This is very bad news for animations. Because every frame in an animation is different, you would need a new FG map for that frame. But we have a work around for this that I will get to.




For now:
•under FG check "Enable Final Gather"
•for the Preset choose Draft
•under Final Gather Map click on the [...] button, and choose a location to save the FG map.

Be sure "Read/Write File" is checked and "Read Only" is not checked.



Now to get back to our problem of needing different FG maps for every frame. Instead of creating a FG map for every frame, I create a FG map for a range of frames. For example, if my animation is 100 frames long, I will render every 10 frames creating a FG map for only those 10 frames. Then with that combined FG map, will go back and render every frame. Here's how to do this:



Make sure FG Map is checked on. Then in the Renderer tab, lower your samples to 1/64 - 1/64. We are doing this, because we are not concerned with the actual rendering, but just the calculation of the FG map. In the Common tab, change your Time Output to Active Time Segment, and under Every Nth Frame change it to 10.




Now click Render. You will get a warning that pops up telling you that you are rendering a sequence without saving the images to a location. That's ok, because we are just interested in FG at this point. So click Yes. Now the animation will render every 10th frame. Because we have "Read/Write File" checked and do not have "Read Only" checked, every time FG for a frame is calculated it is added to the previous FG map. After all 10 frames render, you now have a single FG map for your animation sequence.



Now go back to Indirect Illumination tab, and under Final Gather Map check "Read Only". Now when you render, it will not add to your already created FG map, but just read the one that it's locating to. Also increase your samples back up to something reasonable (1-16), and change your "Every Nth Frame" back to 1. Also be sure to set your Render Output to save to a file location.

That's it. Click render and enjoy!



Animation using PM and FG from file



Now it will start the rendering right away without calculating any indirect illumination. Even though the solution for PM and FG are low, it's not that noticeable. The noise will be even less noticeable when texture are added. Note: this technique doesn't work well for secondary animation (animation with moving objects or characters).

2008-03-20

Why don't my caustics in mental ray render?

There are just a few settings to get caustics to render properly in mental ray. But if they aren’t on, you’ll never get caustics. So how do you get caustics to work in mr?


Think about caustics in reality:

•You have to have a object that reflects

•You can’t get reflections without a light source, so you need a light in your scene




So with these in mind let’s look at the settings:

•Put a light in your scene.

•If you’re using the A&D material, be sure to make it reflective. If it doesn’t reflect it won’t create your caustics.

•To create the actual caustics effect, in the render settings, under caustics and GI, be sure Enable under caustics and GI is checked. It’s not enough to have Enable under caustics. Mental Ray actually uses photons to fake the caustics, that’s why caustics render so quickly in mr.

•Ok, so you’ve got your light source, your shiny object, and caustics are on, but when you render still no caustics effect.




•Right click on your object that you want to cast caustics, and select Object Properties. Go to the mental ray tab. Notice that Generate Caustics is not checked. Turn it on. By default mr has this turned off for all objects, because it is assuming that they aren’t creating caustics. If this was on for every object and you had caustics on in your render settings, it would be very costly, so this is done as a precaution. That’s it!


Note: if you are using transparent materials to generate caustics, check the advanced options in you’re A&D shader and use Refract light and generate Caustics effect.

2008-03-15

Frosted images on glass

I probably should have titled this Image Maps in 3D, but I'm demonstrating one particular example of frosted glass. Before I get into this example, I do want to explain image maps.



All images are the same in 3D. They have different intensity values in different locations across the image. It's all about intensity. Once you understand this concept in any 3d software program, you can master materials. Essentially 3ds max reads black as being 0% and white being 100%. Everything grey is in between depending on how grey they are. This works for any slot in your material that allows a map to be read for it's value. By default they have numerical values, but that will apply to the entire material. If there is a pattern that you want the values to follow...well that's when you use an image map.



If this image were plugged into the opacity slot, then it would be an opacity map. All of the black areas would be 0% opaque, and all of the white areas would be 100% opaque. If it were plugged into the reflection slot then it would be a reflection map, and all of the black areas would be 0% reflective and all of the white areas would be....you get the idea.



In this example for frosted glass, I had to ask "what is it that makes the glass look frosted?" The major difference between frosted glass and regular glass is that you can't see through frosted glass like you can regular. Why can't you see through the frosted glass if it's made out of the same material? That's because light scatters differently. In the A&D material, refraction is what controls the transparency, and glossiness is what controls how refraction is scattered. So that's where I plugged my map into.











Sometimes you can plug the map in straight. But in this case to get the most control of your colors, I used a Mix map, then plugged my image into the mix amount. This way I can make sure that the only intensity values used for glossiness will be white and black.

If you created your image map, and screwed up by reversing the black and whites, this is also a good way to switch the blacks with the whites.

So now my whites have a glossiness of 1.0 (pure refraction), and black has a glossiness of 0.0 (no refraction), and it gives me that frosted glass look!

2008-03-08

Chromatic Aberration

I've been itching to finally say something about this one. If a 3D rendering looks life-like, most likely it has this phenomenon somewhere in the rendering. Chromatic Aberration (CA) occurs any time light refracts from a lens in such a way to disperse colors. This is most obvious in high contrast areas like the image below.

Photograph of Disney Concert Hall



You can simulate this effect in max 2008 with mental ray by using the mia_lens_bokeh shader, and an image map with red, green and blue. Plug the image map into the custom bokeh map. The downside to using an image map is that it really slows down the Arch / DOF Bokeh shader. You will also have to change the samples from 4 to at least 8. I typically use a minimum of 64 samples for my final renders. Note that DOF is what causes CA, so you have to have some blur to get this effect...even if it's a very small amount.








These were some tests I did to compare a rendering with and without CA. The difference is very small, but it makes it that much closer to what a camera is really doing.

There are also ways to do this in Photoshop after rendering. Plug-ins like PTLens are great at creating or fixing CA.

2008-03-01

Bokeh Effect

This is a phenomenon familiar to photographers and is one that I have been obsessed with over the last couple of days. Just recently I have tried to emulate the bokeh effect in my renderings. Simply put, this occurs when an object is out of focus, and a point of light happens to be much brighter than the surrounding points.

There is a very easy way to do this using Max 2008. There is actually a mia_lens_bokeh shader that Autodesk has developed. It’s one of the hidden shaders in architectural_max.mi file, and is useful for creating this type of depth of field as well as other effects such as chromatic aberration. You can unhide the shader by opening architectural_max.mi in a text editor and where you see mia_lens_bokeh, put a # in front of where it says "hidden". Next time you run Max you will see this shader when you click on Lens shader in your render settings. Remember to drag it into the material editor (instance) to control the properties.

The depth of field in this example was quite extreme, but I was trying to demonstrate the effect. It is important to note that this effect doesn’t work if Enable is checked under Multi-Pass Effect on your camera. In other words, let the shader on the lens do the DOF work not the camera. It will also render faster. If you have DOF on, in your camera settings, the bokeh lens shader just works on-top of this…blurring the image too much. To get the blades to show, I had to crank up my sampling to 64.