2007-11-05

More Hidden Gems: mia_envblur - glossy reflections of Environments

I thought initially I would title this post "Happiness is a Warm Gun", since it could have just as well have been the "black gun metal" tip, but I felt a more "searchable" name would be more useful...



Formulating The Problem



Glossy Reflections in computer graphics is always a headache, since it invariable involves multiple samples, which invariably involves grain. Interpolation helps, but interpolation isn't really working well for complex geometries, and can be "detectable" in animations (i.e. you can often "see" that something fishy is going on w. reflections, so I advice against using interpolated reflections in animations).

But, you say, I need to have my semi-glossy space robot/gunship/whatever and I need to animate it, and I have this really contrasty HDR environment it must reflect... I would need to turn up samples to crazy levels... the animation would never be finished! What can I do!?

The solution: mia_envblur



This shader is another "sort of hidden" (depending on which application you are running, it's hidden away in 3ds Max but not in Maya, and it's existence isn't really marketed heavily... ;) )

What does it do?



Well, the documentation explains this fairly clearly, but in short:

If you have some objects in a scene which largely reflects an environment map (this bit is important; mia_envblur really dosn't do anything useful for, say, an architectural interior where objects reflect other objects, it only does it's job for environment reflections) and your environment is high-contrast, you tend to get grain as a result. Witness here some spheres n' stuff reflecting the good old "Galileo's Tomb" probe from Paul Debevec:



Grusomely Grainy


This is clearly not satisfactory, the grain is very heavy, causing slow renders due to a lot of oversampling happening. We can turn up the sampling in the shaders and get something like this:



Borderline Better


This looks nicer indeed, but the render time was nearly ten times of the above! Not something you'd want to do for an extended animation. And it would still glitter and creep around. Not good.

So... enter mia_envblur. The shader is used to "wrap around" some existing environment shader, i.e. it takes some other environment shader, rasterizes it into an internal mipmap, and can perform intelligent filtered lookups in a special coordinate space which behaves very close to doing actual glossy lookups to that environment with a near-infinte amount of rays!



Soothingly Smooth!

This is much nicer looking, and the environment reflections are smooth (but object-to-object reflections still involve multi-sampling and can have some grain. A trick around that is to limit the reflection distance as mentioned in the manual).

To use mia_envblur, you must follow these steps:

  • Where your existing environment shader is connected, instead connect mia_envblur, and connect your original environment into it's environment input.
  • In your mia_material, turn on it's "single_env_sample" parameter. This is very important or you will gain neither speed nor quality (although you will get a little bit of smoothing, but not supersmoothing of the reflections)
  • Set the "resolution" high enough to resolve the details of your original environment.

As for the actual blur amount, you have two choices; Either you set a fixed amount of blur with the mia_envblur parameter Blur. But that is a bit boring... if you have different materials of different glossiness, you would need separate copies with different blur ammounts applies as environment maps to each materials... very tedious...!

Much better is to turn on the mia_material_blur parameter on!

This will drive the amount of blur from the glossiness setting of the mia_material. This works such, that mia_material "informs" the environment shader which glossiness is used for a certain environment lookup, and hence allows a single global copy of mia_envblur (applied in the global (camera) Environment slot) to follow the glossiness of multiple mia_materials, or even map-driven glossiness on a single material:



Very Visible Variable Varnishness


I can't stress enough how varying the glossiness with a map gives a nice feel of wear, tear and "fingerprintiness" of an object. And with mia_envblur you can do this without being ashamed and fear horrid render times.

Production Shaders?



Yes, mia_envblur works great together with the production shaders. Just "wrap" it around your mip_mirrorball shader, to do glossy lookups into it.



Perfect Production Partner


This spaceship (from TurboSquid) is mapped with a glossy reflection that is heavily varied (A whole "make a spaceship in the backyard" tutorial will probably appear later, if I find time).


Does it move?



Yes it does. Just a word of warning: be certain that the resolution parameter is set high enough to resolve all details in the environment you use. The "Gallileo" probe I use here has too many small lights in it for the default of "200" to be enough (this means the map is rasterized into a 200x200 pixel mipmap). But at 600 it works great. Also note that any non-glossy lookups into the environment map actually bypasses mia_envblur automatically, so these are looked up in the full resolution map!

See for yourself in this DivX test animation, which includes above spaceship hovering over my backyard, the above gun-metal-black battle robot (also from from TurboSquid) and some spheres, including my attempt to do a "gnarly cannon ball".

For the record, these renders also uses the photographic exposure and Lume "Glare" shader. The animations rendered at about 1 minute per frame (on a HP x6400 Quad Core)

Hope this helps your glossy-thing-renders!

/Z

2007-10-30

Production Shader Examples

So, who wants to know more about the production shaders? Raise of hands? (See the introductory post, if you missed that.)


OK, I don't have time for an extravagant essay right now, but what I did do is to put a set of examples online.

The example uses some geometry (in some cases, our friend "Robo" pictured here on the right) and shows how to use this together with the production shaders, both to introduce our geometry into various backgrounds, as well as using features like the motion blur and motion vector code.

General Overview



The Production library does a lot of things, but one of it's specialties is to help us to integrate a CG object into a photographic background, with the help of a photo of the background and a photo of a mirror ball taken at the same location in the same camera angle as the background photo. So, to play with that, we need a set of backgrounds, with matching mirror ball photos.

As luck would have it, I happen to have just that. (Amazing, innit?) ;)

These backgrounds are available in this backgrounds.zip file. Please download that and unzip before downloading any of the demos scenes (I also apologize for not having time to put Robo into any of the Maya scenes, but he was out at a party the day I made those file and didn't come home until late....)

In a hurry?



If you don't want to read, but play play play, you can go directly to this directory and you will find the files.

Examples for 3ds Max 2008



The 3ds Max demo scenes are sort of "all in one" demos, demonstrating a scene using the mip_matteshadow, mip_rayswitch_environment, mip_cameramap and mip_mirrorball to put a CG object into a real background as described in the PDF docs.


The file robot-1.max puts Robo in my back yard, robot-2.max puts him on my dining room table, robot-3.max on a window ledge, robot-4.max out in a gravel pit (how absolutely charming place to hang out) and finally robot-5.max on my dining room table but at night, and some alien globules has landed...



They all work pretty much the same, i.e. the same settings only swapping in different backgrounds and mirror ball photos from the backgrounds.zip file.

The exception is the file robot-4-alpha.max which demonstrates how to do the same as robot-4.max does, but set up for external compositing (see more details below in the Maya section).


Examples for Maya 2008




The examples for Maya are more "single task" examples, and demonstrates one thing at a time.

mip_matteshadow1.ma and mip_matteshadow2.ma both demonstrate how to put a set of CG objects into a real background, using the exact same techniques as for 3ds Max above:



The file mip_matteshadow2b.ma demonstrate the same scene as mip_matteshadow2 but set up for external compositing (what is called "Best of Both Worlds" in the manual).

To recap from the manual briefly: In the normal mode (when you composite directly in the rendering and get a final picture including the background right out of the renderer, you use mip_cameramap in the background slot of your mip_matteshadow material, and in your global environment (in the Camera in Maya, in the "Environment" dialog in 3ds Max) you put in a mip_rayswitch_environment, which is being fed the same mip_cameramap into it's background slot, but into it's environment slot it is being fed a mip_mirrorball.

To do the "Best of Both Worlds" mode (to get proper alpha for external compositing, and not see the background photo in the rendering - but yet see its effects, its bounce light, its lighting, its reflections, etc. - one need to do a couple of changes from the above setup:


  • In the global Environment should still be a mip_rayswitch_environment as before, the only difference is that instead of putting mip_cameramap into it's background slot, you put transparent black (0 0 0 0).

    The trick in Maya is that you cannot put an alpha value into a color slot. We can cheat this by using the mib_color_alpha from the base shaders, and set its multiplier to 0.0.

  • In the background slot of your mip_matteshadow you used to have a mip_cameramap with your background. What you do instead, is to put in another mip_rayswitch_environment, and into it's environment slot (important, yes, the environment and NOT the background!) you put back the mip_cameramap with your background photo, and in it's background slot you again put transparent black (using same trick as above).


Having done this (as is already is set up in the mip_matteshadow2b.ma example) you will get this rendering:



This image contains all the reflections of the forest, the bounce light from the forest, the reflection of the environment from the mirror ball... but doesn't actually contain the background itself.

However, it has an alpha channel that looks like this...



...which as you see contains all the shadows. So compositing this image directly on top of the background in a compositing application, will give you the same result as the full image above, except with greater control of color balance etc. in post.

Maya in Motion



There is three further example files for Maya:

mip_motionblur.ma, which demonstrates the motion blur, and mip_motionvector.ma and mip_motionvector2.ma who both demonstrate how to output motion vectors.


I know these are rudimentary examples, but the day only has 48 hours... ;)

To quote the Governator: "I'll be bak".

/Z

Making Better Metal with mia_material

When using the Arch&Design (mia_material) in the various products, the manual mentions that to make metal, one should enable the "refl_is_metal" switch (shown here from the 3ds Max UI, but it's available in all products):


Metal Mode


When one does so, the color of the metal comes from the diffuse color swatch. However, most people stop there, and get a very dull looking material, and wonder "what wen't wrong?".

Well, not reading the rest of the manual is what went wrong ;)

Just kidding. Anyway, just turning on the "metal" mode doesn't make it look magically like metal. It looks more metal-ish but there is one more thing to do, take care of the BRDF curve.

When metal mode is on, the reflectivity (and the BRDF curve) drives the balance between traditional "diffuse" shading and reflective "metallic" shading. So if your reflectivity is zero, or you are at an angle where the BRDF curve is very low, you will be seeing mostly plain old diffuse shading, i.e. not very "metal" looking.

So what needs to be done is to pump up the Reflectivity value (probably to 1.0), and modify the BRDF curve to contain more reflectivity.

The default BRDF curve only contains a 0 degree reflectivity of 0.2, which isn't really very "metallic looking". One could change this to a higher value like so: (UI from 3ds Max shown, but exists in all products):



Making Metal More Metallic


This works pretty nicely, and most metals can be done this way. But still, it may look a tad "off" in how the reflectivity depends on angle.

Well, then we try the fresnel mode.

"What" I hear you yell, "Fresnel" is for dielectrics... transparent stuff... like water, glass and such. It is based on the Index Of Refraction. Metals aren't transparent, they can't refract stuff! O'le Zap's gone completely bonkers now!

Well... actually... no. Metals are indeed not refractive, and are indeed not dielectrics (meaning, electrical insulators). They are Conductors, and for some baroque reason these are also considered to have an "Index of Refraction".

Now, don't ask me how on earth someone came up with the idea of refractive metals or how this is actually calculated... I didn't write the laws of Physics (I just abuse them) so just trust me it's there.... and these values are high. Not your average "1.3" ish like for water, but values like "25" or "50".

So, if you turn on the Fresnel reflection mode and put in an IOR of 50 you get something like this (Again UI from 3ds Max coz it has the neat curve):


Mysterious Metal Magic


As you see from the quirky curve, the angular dependency of the metallic reflection is... odd. But when rendering this, the metal just looks a tad more... well... metallic:

Gold in the Sun

The above is a gold material under Sun&Sky lighting. It looks "ok", but not great.. why is that? Well, our visual perception of metals come largely from the reflections. While a totally empty sky is "ok" as reflection, it's not more than just "ok"... it looks dull. (But a photo of metal in a completely cloudless desert would look about as dull).

Lets try with reflecting the good o'le "Kitchen.hdr" environment:

Gold in the Kitchen

There, exactly the same material, only reflecting something "interesting". (And yes, a tad of Glare on top, and using the Photographic exposure... so sue me ;) )

Hope this helps in the quest for More Metallic Metals.

/Z

2007-10-26

Production Shaders: "Hidden Treasures" of 2008

May I present to you, the "production" shader library.



What? Where? Production shaders?
Well, here's the story:

The Hidden Shaders


If you have installed 3ds Max or Maya 2008, you will have obtained mental ray 3.6, and with mental ray 3.6 comes the production shader library.

However, in neither of Max or Maya are these shaders exposed by default to the end user. They are hidden, and therefore "unsupported".

Still, they are there, and they can be used. But to do so, one must first "unhide" the shaders.

Why "hidden"


Simple matter of resources of Quality Assurance at Autodesk. The shaders has not gone through enough torture - yet - to be signed off by QA as "officially supported". But that's where you, my adventurous mental ray addict, come in! Consider this an extremely public beta, if you will....

How do I "unhide" them?


Unhide instructions for 3ds Max 2008 are here

Unhide instructions for Maya 2008 are here

What are they


The production shader library is a set of tools, some simple, some complex, to aid in doing production rendering, i.e. in a visual effects context.

There are two basic categories of shaders:

Simple
First we have the simple utilities like applying a gamma to a color, or giving different results for different "ray types" (reflection rays, transparency rays etc.). These shaders are very simple, and you probably have found similar shaders online before. These shaders are not better than those other shaders that do the same thing, they are simply a standard set that now ship with all products. I.e. "mip_rayswitch" isn't terribly different to Control Studio's "ctrl_rays", but you don't have to install anything to use it.

Advanced
Then we have the more complex shaders, such as the 2.5d motion blur shader, or the matte/shadow/reflection system used to cast shadows (and reflections) off of a stand-in object in your scene, for integrating CG objects into a background plate.

A lot of examples of the mip_matteshadow and other production shaders are available as a small demo movie constructed for siggraph, it's available as YouTube as well as WMV, QuickTime and DivX versions.


What do they do?


The main intent is to simplify the workflow of compositing CG objects into background plates, and other visual-effects related tasks that one may run in to on a daily basis.

In some cases they exist to give a simple workflow to a simple thing. For example, the mip_cameramap is a simple camera mapping shader that simply projects back an image from the render camera (and only that camera) "into" the scene 3-dimensionally (unlike, say, mib_lookup_background, Max's "Screen" mapping, or similar).

There are more complex "camera projection" shaders out there both for Maya and Max that can do similar jobs, but at a slightly higher effort. Again, the logic here is to provide the simple tool that can do the job, and if you need the more advanced feature, use the more advanced feature.

Similarily, the mip_mirrorball shader is for a simple unwrap of a mirror ball into an environment map when taken from the same camera angle as the background plate. For anything more advanced you would probably have to unwrap the mirror ball image in some unwrapping software and apply as a spherical map... or maybe you are a high-end user that uses SpherOn cameras and don't even use mirror balls... then ignore this shader, use your more powerful tools.


Mark my words, I will be posting quite a lot on the topic in the months to come, but meanwhile you can read the PDF documentation. In Max, the names of the shaders will appear slightly different than in the manual, but you can figure that our rather quickly, I hope.

That's all I have time for for for now:

Stay tuned to future blog posts on the subject.

/Z

2007-10-25

Max 2008: Physical Camera with DOF and motion blur

So, does anyone want a Physical Camera for mental ray in 3ds Max 2008? Read on...



The Photographic Exposure Control (mia_exposure_photographic) gives you values in f-stops and shutter speeds like in a real camera. However, it only applies to the exposure of the image (i.e. the brightness, basically).

In a real camera, the above mentioned parameters affect the depth of field and the motion blur of the camera.

This isn't supported out-of-the-box - the exposure control really only deals with the exposure.

A second thing is that the exposure knobs being "camera oriented", but they are not ON the actual Camera object. Whereas it would make more sense if these parameters "lived" in the UI of the Camera.

To try to solve these issues, I wrote a little "proof of concept" script to test out what such a UI would perhaps look like. It's very clumsy in many ways and an ugly hack, because it's just a "scriptable plugin", and scriptable plugins has a ton of limitations in max.

First of all, a scriptable plugin can only extend an existing object, not make a "new" one. Secondly, scriptable camera can only extend the "free" camera due to technical limitations of MaxScript (well, the MaxScript docs tell me so anyway), but most people "want" to use a "Target" camera.

Due to this limitation, the camera always gets created in "Free" mode, but after it has been created, you can switch it to "Target" mode. Ugly, but... livable.


How to use this plugin hack



1. Download this plugin and save into the "plugins" directory under your 3ds Max main directory.

2. Now, either restart max, or just load the plugin manually as well from the MaxScript menu.

3. Now, under your "cameras" you have a new "mr Camera" item.

4. Insert it - unfortunately always comes in as a "Free Camera". The UI at this point will look like the old camera.

5. Go to the "Modify" tab to see the "new" UI.

6. Play, rejoice, etc.

Remember, this is an ugly unsupported quick hack. The "mr Camera" simply "feeds" other existing plugins with value (mr Photographic Exposure, mental ray Depth of Field, motion blur, etc.) and doesn't really "do" anything by itself.

And it probably has more bugs than you can shake a stick at... but is provided here "for fun".

Enjoy.

/Z

2007-10-23

"What he said"


I love when people save me time. One guy who saves me time sometimes is Jeff Patton. He has another mental ray Blog an sometimes he reads my mind, and magically write things that I intend to post, saving me the time to actually post it.

Just now, for example, Jeff posted a tip on how you can use the portal lights as light cards. Quite useful, and quite an intended "additional feature" of the portal lights, albeit perhaps a tad under-documented....

Another cool mental ray Blog (more slanted towards Maya) is DJX blog with a lot of cool tips.

I'll add these blogs to my link list on the right, methinks....

/Z

3ds Max 2008 released: Some Known Issues

Or "Why do my brand new 3ds Max 2008 render black when I choose a mental ray render preset"?



3ds Max 2008 has been released, and as always, some things sneak in the wasn't really intended in the final version.

Here, a "minor edit" to the rendering presets became less minor than was intended;

Since 3ds Max 2008 contains the new mr Photographic Exposure control, the rendering presets (y'know, the ones down at the bottom of the render dialog) for daylight was supposed to be changed from the old Log exposure to the new Photographic exposure set for "sunny day" lighting.

The problem? That this was done.... but by accident all mental ray render presets got this setting.

Yes, even the "plain old" settings got, by mistake, a setting suitable for a superbright sunny day enabled:



The setting accidentally put in


But a sunny day can easily be lit by 100000 lux. And your average interior surely is not. So out of the box, starting up max and putting in some photometric lights (try to use the photometric lights as often as possible, btw) you would get a really dark scene.

And even worse, putting in some non-photometric scene would yield a pretty much completely BLACK scene. Why?

Well, the new mr Photographic Exposure Control has a 2nd feature; The feature of treating any "oldschool" value as real, physical cd/m^2 values (if you wonder about what a "candela per square meter" is, go back to the "Gnomes and Basketballs" post).



The Units Setting


This means that if an "oldschool" light of the arbitrary intensity value "1.0" shines perpendicular to a white (100% reflective) lambertian surface (i.e. plain old white diffuse thingamabob), this will emit light that is interpreted as 1 cd/m^2.

Now that is really really really really REALLY really dark.

I.e. turning on max, loading a mental ray render preset, and putting in and oldschool "Omni" light gives you a black render. Not good.

The fix? Easy.

Do one of three things:

Either:

1: Turn it off altogether

Hit "8" to bring up the "Environment/Effects" dialog and do as follows:


Exposure Control Turned Off


By simply turning off the exposure control, you are back to a "known" behavior. However the exposure control is really neat and gives very nice images... so I don't really recommend that method!


2: Use the exposure controls "non physical" mode


Exposure Control in "Non Physical" mode


This is better; it still gives you all the nice image control of crushing blacks, taming highlights, camera vignetting and saturation controls, but it uses a fixed unity gain, i.e. the intensity of the pixels does not change (except it applies a gamma correction if the 3ds Max gamma is disabled, if the 3ds Max gamma is enabled, that gamma is used).

However, it is not perfect just because of the fact that you lack any control over exposure; the "non physical mode" is locked to unity gain with no control over it.

There is, however, a third variant:

3: Use the exposure control with an EV=0.0


Exposure Control with an EV of 0.0


It so happens that when using the "oldschool pixels equal cd/m^2 mode" (pictured above) the EV value of zero (0.0) is very close to the "unity gain" mode set by the "Non Physical" mode. But you can change it up or down to re-expose the scene.

So for a scene lit completely with "oldschool" lights (non photometric), that is the easiest setting with the greatest control.


A further note on the units / physical scale



Now if you have an old scene with a blend of photometric and non-photometric lights, you may want to revert to the old behavior of using the "physical scale" setting, which exists in the old Logarithmic exposure control.



Using a "Physical Scale" like in the past



In this mode you cannot use the "EV=0" setting, you probably need to pick one of the "indoor" presets, or just play with the EV until you get a "nice" image, because this means that now an oldschool light of intensity "1.0" will equate to an illuminance of ~1500 lux when perpendicular to a surface, so an exposure "suitable" for that amount of light must be used.


Hope this helps!


/Z

2007-10-14

Yer in a "Heap" of trouble now: Avoiding random crashes in Maya/Max due to running out of Windows resources!




Note; This tip has nothing to do with mental ray at all, but since the issue I describe tend to manifest on Maya when opening the mental ray control panel (due to the sheer number of tiny windows w. subwindows) I mention it here.


Have you ever run, for example, Maya (on Windows XP or earlier - Vista works better here) with a ton of other programs running, and tried to open a particularily complex AE template for some shader, to find the application go "plop" and disappear?

While there are any number of probable causes, I was debugging a particular case and actually found the cause, and it was sometihng I never really suspected, and is pretty non-obvious. And doesn't have anything whatsoever to do with mental ray, as I said above.

So what's up?



Back in the day of 16 bit Windows 3.0, running out of "window handles" (each window on screen has a "handle", like an identifier, used by the operating system to keep track of it) was extremely common, and every Windows user recognized the symptoms... windows wouldn't open, or buttons/texts would be missing from dialogs, or windows opened as only borders, or a strange "placeholder text version" of dialogs popped up.... whatever.

You'd think that a "modern" operating system wouldn't have a limit on the number of windows it could have opened, right? With multipled gigabytes of RAM, this shouldn't be an issue... right?

Well... think again. ;)

First of all the number of possible handles is apparently - still - limited to a 16 bit number (that's 65536 possible handles). But the real limit doesn't lie there, coz that's plenty. The real limit lies in the fact that each "window handle" also implies a memory allocation of a special data structure, that lives in a special memory area called the "desktop heap". And this memory area is small. As a matter of fact, by default, on XP (32 AND 64 bits) ... it's 3 megabytes!!!! Thankfully, on Vista it's larger, so Vista users do not need to do anything (except cry over all the other issues with Vista.... but that's for another blog day...)

Practically, this means that at around a few thousand windows (or other handles), things start failing.

Now, the user interface in Max, Maya and XSI are "windowed" UI's. This means that each control in each dialog is considered a "window" (from the point of view of the operating system). And sub-dialogs, little rollouts, etc. are all subwindows, with controls sub-sub-windows, and buttons can be sub-sub-sub-sub-windows, etc.

Anyone who has seen a compelex Max dialog box or Maya UI, and consider that counting every single little box, control, and thing, you'll find that that's a lot of windows. Maya easily consumes a couple of thousand handles all on it's own. (You can see this by telling your task managers "processes" tab to display the "GDI OBJECTS" column)

(Incidentally, this issue is known by Microsoft, to the extent that they try to write their software "windowless", i.e. when you run, say, Internet Exploder, each little thing on the webpage is not a separate window from the OS's point of view, precicely because of this problem!)

All is lost! The Sky Is Falling! Or?



Not at all.

See, the cool thing is that you can set up the size of the "desktop heap" by fiddling with the registry.

However, there are two things to consider when doing this, one fairly benign, and one less so.

The benign issue is that the "desktop heap" actually comes out of a larger memory area called the "Session View" (don't you just love these names?). And the size of the "Session View" is also limited (to 48Mb by default). Which is again adjustable, but that in turn lives in Kernel address space, which also is limited... to another, larger, value. And so on. You get the idea.

So the point is, you can increase the "desktop heap" size by editing the registry, but you can't just do it willy nilly and put in any old value, because you will get other problems, of running out of "Session View" space.

What I did was to up it from 3Mb to 4Mb, and the problems I had pretty much went away immediately.

The second, less benign issue, is that this is a really hairy registry location, and a horribly convoluted registry key, which actually contains a long string of some 200 characters where you have to change one thing in the middle, and the problem is the fact that doint it wrong can turn your PC into a brick.

Let me repeat that: Doing the registry edit INCORRECTLY CAN TURN YOUR PC INTO A BRICK. A DOORSTOP. A BOAT ANCHOR. MKAY!!??

So proceed with caution!

So what do I do?



Well, first of all, be aware of the above. I will take no responsibility for you turning your machine to scrap metal by a clumsy registry edit. Really. Proceed at your own risk, your own peril, and totally on your own responsibility. If you work at a studio, and the machine is not your own, talk to the TD or machine responsible person, point him to this webpage, and let him do it.

Okay?

Made that clear?

If things blow up, do not come crying to me. I warned you. Ok? Good.


The registry key in question is (and if you don't know how to edit the registry, you probably shouldn't be trying this...):


HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Session Manager\SubSystems\Windows


The default value of this key is something like this


%SystemRoot%\system32\csrss.exe ObjectDirectory=\Windows
SharedSection=1024,3072,512 Windows=On SubSystemType=Windows
ServerDll=basesrv,1 ServerDll=winsrv:UserServerDllInitialization,3
ServerDll=winsrv:ConServerDllInitialization,2 ProfileControl=Off
MaxRequestThreads=16


...except it's all in one gargantuan long line, requiring you to scroll horizontally. See that "SharedSection" thing in there? After it it says "1024,3072,512"? Well, the 3072 in the middle, that's the "3 megabytes" we are talking about. 4 megabytes is 4 * 1024, i.e. 4096. So what we want to do is change "3072" to "4096".

Having done that, and rebooted, you should be gold.

More information about the desktop heap can be found here, or using, well, Google.

/Z

2007-10-12

Maya: No Alpha channel on mia_material(_x)?

This must rank as the "most frequently asked question ever". (And consequently, the worst use of Google ever, apparently, since CGTalk alone has more threads on the topic than you can shake a stick at).

The problem: You render stuff in Maya, using mia_material(_x) - or any other "mental ray" shader - but you find that those pixels containing that shader has no alpha. What gives?

The reality is that Maya has a very peculiar notion of Alpha... because the Maya software renderer actually has true three-colored "transparency", so transparency gets passed around separately in the most... odd... ways ;)

Hence, to get the Maya system to "understand" a standard shader that uses alpha, you need to check this here little checkbox:



Then, life should be more fun again!

/Z

2007-10-09

Hot Fuzz: Hair Revisited

In a previous post I briefly mentioned hair. People started to wonder about the details of that, so:

If you render hair w. Raytrace shadows and using the normal raytracer, it works.. but takes a while:



Whereas if one enables the Fast Rasterizer, and use Detail Shadow Maps, it can be both nicer looking and faster:



So the question then is... where do I turn this on?

I admit some things can be hard to find, and sometimes they are renamed in the UI of a particular application... for example, the mental ray detail shadow maps are actually not named "detail shadow maps" in 3DS max, they are named "Transparent Shadows". You find them here:



In Maya, however, they have their proper name and are found here:



However, Maya has "special" shadow settings for Hair and Fur one may need to watch out for.

Turning on the "Fast Rasterizer" is easier since it has it's proper name in most applications. Max:



And Maya:



Hope this helps with the "Fuzzy sidekick" rendering. Note that the Rasterizer is great for motion blur and fuzzy stuff, but can be suboptimal when involving many raytraced effects (glossy reflections, etc.)

/Z

2007-10-01

Maya's default shadow settings

Clickeroo

No too long ago I wrote about Maya and shadows.

There is another "issue" related to Maya and shadows; the default shadow trace depth on Maya is 1 (called "Ray Depth Limit" in the lights "Raytrace Shadows" panel). This means that even after one bounce (like a reflection in a mirror, or behind a pane of glass) you suddenly do not have shadows any more! This can hugely impact any quality interior GI render, and you can get all sorts of issues caused by this.

NOTE: A common misconception is that the Maya "Ray Depth Limit" on the ray traced shadows is how many surfaces the shadow rays penetrate. This is not so!.

This image is rendered with the "Ray Depth Limit" of 1:



Notice how the light still gladly penetrates 3 blue glass blocks (6 surfaces in total) and still generates a shadow? Yet when viewed through the single red glass block, the view as seen trough it suddenly is completely shadow-less!

Whereas if we turn up the "Ray Depth Limit" to 3, and the "Shadows" depth to 3 in the mental ray render globals (yes, you must change both!) you get:



Another demonstration of this can be found here

So, in conclusion

Make sure to take a look at Maya's shadow settings, making sure to look at

- shadow trace depth (note this must be set on the light (defaults to 1) as well as in the mental ray render globals (defaults to 2))

- "Low" area light samples (defaults to 2x2) and the "High Sample Limit". However the "High Sample Limit" defaults to 0, which turns OFF the "low area light sampling" mode. This is "good" quality wise (you never actually get the "low area sampling") it precludes a particular mia_material(_x) optimization (it tries to control this from the material, driven by importance, but it cannot do so if it is set to 0). I suggest you turn it up to 4. You can generally keep your "low" sampling at 2x2 when you are using the mia_material, but when using other materials, this may be something to watch out for, since they will strictly adhere to the "depth" setting rather than the relative ray importance, like mia_material(_x) does it.

/Z

2007-09-28

Famous mental ray myths...

Rusty Teapots Unite

There is a lot of misinformation out in the world, misunderstandings that gets repeated and turn into "truths" over time.

I ran into a couple of those at EUE and frankly, I had no idea they were so widespread. So from now on, any time I run into these I'm gonna make a post about it.... here's a collection:

You should always use the mental ray shaders, not the built in max/maya/xsi/whatever...



This myth is both true and false at the same time.

The reality is, there are a ton of "mental ray" shaders, from the very old and very primitive "base" shader library (danger) to very new and very modern "architectural" and "production" shader libraries.

So - yes - if there is a brand new shader that comes directly from mental images that does X, and your embedded application may have some other shader that claims to do X as well, then most likely picking the "mental ray" one is better.

But if there is some ancient shader, from the mists of pre-cambrium, that has a "mental ray" variant, and your application has something that looks as nice, is better integrated, etc.... use that in your application

As an example: The base shader library contains a set of shaders like mib_illum_phong, mib_illum_blinn etc.... never use those! Those are the simplest, most primitive shaders. Avoid!

Much rather than anything "mib_illum_blinn" use the Maya "Blinn" or the 3ds max "Standard" material in "Blinn" mode, or whatever. But even better, use the mental ray mia_material (Arch&Design in max). This is new, mental ray optimized, and we try to integrate it as much as possible into each app.

The old rusty mib_illum_* shaders will have all sorts of issues, interface poorly with the product (no render elements/channel support, no support for diffuse/specular switches on the lights, etc.), handle indirect illumination incorrectly, and so on.

Your apps own integrated materials are mental ray translations of the applications software-renderers material to the "best possible" mental ray counterpart. Your apps own materials are the one most guaranteed to interface with the app's own "features", such as specual switches on light, render channels, whatnot.

And then the mia_material(_x) ("Arch&Design") which we try to make as a "top of the line" thing, and we really try to integrate with as many of the applications own feature as humanly possible.


If it doesn't say "mental ray" dont use it



Similar to above, people have gotten the idea that if a feature doesn't explicitly say "mental ray" or "mr" on it, it is directly unsuitable for use with mental ray.

While this may happen in some odd cases, most of the time, most application features are actually quite well integrated with mental ray.

One of the most scary thing I heard at EUE was someone who asked "You can't use the 3ds max photometric lights with mental ray, right?".

I almost fell off my chair. If you want to render anything even remotely physically correct you should always use the photometric lights. But this guy had been misled by some other lights in the non-photometric category having "mr" in the name.

The reality is that those lights (The "mr Omni" and "mr Spot") are simply lights supporting things that do not exist at all in the other 3ds max lights.

All 3ds max lights are "mental ray lights" when you render with mental ray. Those two simply expose things that only mental ray can do. This does not mean the others "don't work" with mental ray, or that others are "unsuitable" for mental ray.

(Of course, in the case of max lights, what actually is unsupported in mental ray is the 3ds max "trick" to do "area shadows" on any given light, you instead have to make it a real area light. Hence the "extra" light types, although one could argue that perhaps this distinction could have been hidden away from the user in some other way. Alas, water under the bridge....)

So: Please use the photometric lights!

Never use Shadow Maps



This "myth" is the truest of them all. Yes, most of the time you really shouldn't use shadow maps with mental ray (you should use area lights). As a matter of fact I think at least 3ds max ships with shadow maps globally disabled in the mental ray render globals.... this is simply to get around the fact that max lights actually default to shadow maps.

However, there is a couple of cases where you should use shadow maps. And not just any shadow maps - the mental ray detail shadow maps: Hair. Fur.

Yes - any time you want to render hair, that's the time you whip out the rasterizer and detail shadow maps. Not for an architectural interior, but for your fuzzy sidekick in your space drama!


mental ray is slow



Actually mental ray is very fast, if you do things correctly. If you don't do things correctly it - as well as any other renderer - can be very slow.

First of all - suboptimal defaults. If an application ships with a default final gather setting of 500 rays, a way too low spatial oversampling contrast of 0.002 (which makes very little sense), and the default number of motion blur samples set to "19" when "5" is quite enough, of course it will appear slow.

Fixing all those settings can speed it up an order of magnitude.

But yes, I always get this "PRMan displaces faster" stuff. Of course it does.... until you actually trace a ray.

You see, PRMan lives in mindset where raytracing is so slow that you avoid it like the plague. So it uses a completely different method to render things (the REYES engine) which micro-dices things and spits the micro-polygons into subpixels then into pixels. The very nature of this algorithm gives you displacement practically "for free". Coz they work one micro-poly at the time, and never have to keep a single thing in memory.

A raytracer on the other hand (I alost said "a real renderer" *grin*) would out of necessity need to keep all those poly- and micro-polys in memory to have to intersect rays against. So not only do they need to be created, stored in memory, an accelleration structure must be built to speed up the ray intersections. All taking - yes - more time and complexity than dinking away one micropoly at the time and throwing the results over your shoulder when you are done.

The thing is that in PRMan, if you try to shoot a ray, it too has to do all those things. So the minute you actually shoot a single ray in some .sl shader, *grind*, PRMan has to do what mental ray always does.... and the comparasion suddenly isn't so much in favour of PRMan any more.

Since I am of the opinion that there exists no interesting shading that doesn't involve raytracing, I find the fact that "yes, PRMan can be faster with raytracing off" a completely academic opinion of no practical value (but of course, all speed-tests are run like that, naturally.... *sigh*). I am wholly uninterested in oldschool dinky-toys rendering in a fisher-price universe of reflection maps and reflective occlusion (a trick invented solely to "avoid tracing rays". And of course they build their reflective occlusion maps with mental ray... LOL)



Alas, that's all I have time for today.... more later.


/Z

2007-09-10

Sitting in the Shade with Maya... mia_material shadow shading.



Hello guys and gals.

Just a quick heads-up.

It's come to my attention that there is a performance issue with the "segment" shadow mode and the mia_material shadow shader. It's fine for transparent objects (i.e. it does the job it's "supposed to do").

However, for opaque objects, it is actually doing a bunch of unnecessary work, especially in "Segment" shadow mode - which is the default mode in Maya.

The workaround is very simple; don't use the shadow shader for opaque objects.

Normally, you would use the same instance of mia_material in your surface, shadow and photon slots. Well, if your material is opaque, simply don't put it in the shadow slot. This could gain you some performance.

/Z

(In Max this isn't an issue, since first of all, "segment" shadow mode isn't the default, and secondly, the UI frontend actually does the above already, i.e. it doesn't assign the shadow shader at all to opaque objects.)

2007-08-29

Speaking at "End User Event", Sept 13-14, Netherlands



I'll be one of the speakers at the EUE in Utrecht (25 minutes by direct train from Amsterdam Schiphol Airport). I'll be talking about the new shaders and other mental ray 3.6 stuff.

More info, registration instructions and schedule on eue.3dstudio.eu

Also speaking will be Ted Boardman, Rune Spaans, Jamie Gwilliam, and a truckload of more people.

Pop over if you want to see some fun stuff or just have a word or three. I've been known to talk a word... or three. ;)

/Z

EDIT: Fixed links. Silly me.

2007-08-27

Doing BIG renders in Maya

Since I wrote the below post "Doing BIG renders in max 9" I have been drowned in the question "so how about Maya"?

Well, this is most easily done from your command line, i.e. your windows command line.

Basically, if you want to render the scene "lion.mb" to a 5000x3000 pixel image, you can do that in tiles or stripes or whatever, from the command line. For example you can split it into five 1000x3000 pixel renders that you save in "c:\foo" directory, like so:

render -x 5000 -y 3000 -reg 0 999 0 3000 -rd c:\foo -im part1 lion.mb
render -x 5000 -y 3000 -reg 1000 1999 0 3000 -rd c:\foo -im part2 lion.mb
render -x 5000 -y 3000 -reg 2000 2999 0 3000 -rd c:\foo -im part3 lion.mb
render -x 5000 -y 3000 -reg 3000 3999 0 3000 -rd c:\foo -im part4 lion.mb
render -x 5000 -y 3000 -reg 4000 4999 0 3000 -rd c:\foo -im part5 lion.mb


Again, remember, if you are doing FG, to avoid seams between the parts, follow the procedure outlined in the original post, i.e. in brief, speaking "Maya language"

  • Reduce Resolution
  • Render to finalgather file by setting Rebuild to "On" and specify a filename
  • Set the finalgather file to "Freeze"
  • Do the actual renders

/Z

Random Dancing Robots - The Post SigGRAPH Post



Phew!

Never did I know attending SigGRAPH would make me so busy I wouldn't have time to make a post post SigGRAPH! Oh well, now I finally take five minutes to post a post.

First, I like to remind everyone of the mental ray wiki over at mymentalray.com, which is really taking off with the good help of Martin Breidt, especially his "mental ray cookbook" section.

Secondly, SigGRAPH was a blast, although I missed much due to, as always, lots of meetings. One of the funniest events happened when some random straggler (apparently not completely awake) wandered into one of our meetings and grabbed a coffee and sat down.... after some investigation we figured out the guy was in the wrong room.... he staggered out mumbling "at least I got free coffee". He had no pants on, for some reason. ;)


Thirdly, I can finally talk about mental ray 3.6 and the new toys that come with it. As shown in various posted demos, there are some new architectural stuff, like the portal lights, which allows a really quick set up for perfect quality skylight coming in through small windows.... as well as other things.



Also included is my own little "baby", the production shader library. I promise that you'll read a lot more about that in this blog as things get released. A lot.

For now, you'll have to make do with watching random dancing robots.




But hey, random dancing robots never hurt anyone, did they? Thought so.



/Z

2007-08-02

SIGGRAPH 2007

Hello all.

I'm going to SigGRAPH 2007 conference in San Diego.

I made a twitter account which I'll try to keep updated with my "whereabouts" so that anyone wanting to run into me knows approximately where I am. Be warned, I'm pretty filled up schedule-wise, but there are gaps....

There will also be some nifty posts here, methinks... stay tuned.... *grin*


/Z

Photo Sharing and Video Hosting at Photobucket

2007-06-27

Nice Water with mia_material (Arch&Design)

I was asked how to do more "realistic" water using the Arch&Design (mia_material) shader, since the available presets we ship is only for a surface, i.e. it does the reflections, but you can't actually see into the water, like thus:



The intent for the preset is for nice quick ocean surfaces and similar. What it really shows you, is that water really doesn't have much color, it simply reflects the physical mental ray sky...

Anyway, what to do about seeing "into" the water?

The simple fix is to simply turn "transparency" up. If we turn it up to 1.0
and set a transparency color of "watery blue" we get the following result:



While this is nice, it isn't very realistic. Note how there is a very sharp transition from air to "underwater" which looks strange.

The reason for this is that we used a transparency color, and as the manual says, intensity changes "at the surface of a solid" isn't really what reality does.

If we change our transparency color back to white, and instead turn on the refraction "Color at Max Distance" (refr_falloff_on) and set the distance (refr_falloff_distance) to the depth of the pool, then enable the "Color at Max Distance" (refr_falloff_color_on) and set that color (refr_falloff_color) to the same "watery blue", we will get this result:



Now, the color at the bottom of the pool (at the designated depth) is pretty much the same, but it fades towards that color, rather than immediately hitting it at the surface.

This is nice, but now we have the opposite problem; the surface is nigh invisible.

So we can dial in a compromise. First of all, crank up your "Diffuse" to 1.0. Why? Because the energy conservation will only give as much "diffuse" as there is NOT transparency.

We used to have a diffuse of 0.1 in the original water preset. Now we have "replaced" this with transparency (since transparency is 1.0). But the water preset really uses the "diffuse" to simulate a bit of scattering in the water (see how the very top image is a bit greenish, and you can actually see the shadow "on" the water). So to get the same "look" you can set the diffuse to 1.0, and the transparency down to about 0.9 ... that leaves (1.0-0.9)*Diffuse amount of diffuse.... = 0.1 -ish.

This gives a wee bit of surface back (there is a bit of transition, that then goes darker by depth, which is both better than the hard transition in image 2, and the non-existent one in image 3), plus we actually see slightly (but just slightly) how the pool edge casts a shadow on the water.



Now, of course, a pool needs caustics.

Make sure your water surface is set to "generate caustics" both in the instance properties, and that the material is set to "use refractive caustics" (do_refractive_caustics=1) and that caustics is on in the render options.

One "trick" to quickly get nice and "sharp" caustics is to lower the number of interpolated photons. Interpolating more yields a more "smeared" caustics look - picking a lesser number of photons is a quick-and-dirty way to "sharp" caustics, but at a fairly low quality. (The non-dirty solution is to send in mo' photons).

I used only 5 (!) photons in the lookup for this render:



Of course, we are just using a bump map for surface detail, if we add an actually ripple to the surface, it looks a wee bit more realistic:



...and finally, the "round corners" shader is an ideal way to give that little "surface tension fillet" that water does around submerged objects:



I hope this is useful for your next pool render. ;)

/Z