Posts filed under 'Tutorial'

Optimizing Multiple Huge Maya/Mental Ray Displacements

Recently I’ve been working on some R&D for stereo 3D environments and pipeline issues.

One big issue is that cheats that you become accustomed to in production such as projections and bump maps break in an awful lot of circumstances when viewed in stereo, so very fine displacements will come in quite handy.

Since ZBrush 3.5 (and earlier if you knew how to break Multi-Displace’s cryptic code), it’s quite easy to generate single channel gray (1×32 bit) displacements instead of traditional (3×32 bit) maps… essentially giving you the same amount of detail in 1/3 the disk space and network throughput overhead… and RAM overhead if the entire texture needs to remain in memory.

PRMan in Maya handles single channel gray float TIFFs just fine, but Mental Ray (as of Maya 2010) doesn’t. The old swiss army knife imf_copy won’t recognize the files either to convert them to another friendly format, such as .map if you’re having RAM issues.

More after the break…

Long story short, I realized that I’m creating an enormous RAM and network bottleneck when working with multiple 8k displacements in a single scene, and the problem gets multiplied with the more render nodes that you’re using.

Example: 1×32 8k displacement = ~263mb while a 3×32 8k displacement = ~787mb. If you think about the implications there, it doesn’t take many of those maps to bring your RAM and network down to a crawl.

Why don’t we just combine huge displacement maps 3 at a time: one map per RGB channel of a 3×32 .tiff? That gives us most of the benefits of using the much smaller grayscale maps: smaller disk & ram footprint, significantly faster network spools, and the exact same quality. It just takes a few minutes to set this up.

Open 3 different displacement maps (all at the same resolution). One by one, copy it and paste into a single channel of a new 32-bit per channel RGB Photoshop file. You do this my clicking on your channels palette then clicking on each channel individually.

Once you’re done, save out the file as a 32-bit TIFF, uncompressed.

Now we come into Maya and build our network.

The idea is you take your single texture file node, shove it into a Luminance node per channel, and it’s in the format that the displacement shader and shading groups require.

splitdisplo.jpg

Click the image above to enlarge the an example network.

Basically given a file node, three luminance nodes and three displacement nodes in hypershade, hook them up like this:

(Texture)File1.outColorR -> Luminance1.valueR
(Texture)File1.outColorR -> Luminance1.valueG
(Texture)File1.outColorR -> Luminance1.valueB
Luminance1.outValue -> displacementShader1.displacement

Then set File1 color gain and color offset to 1 gain V,-0.5 in offset V (ZBrush 3.5) or 2.2 in gain V, -1.1 in offset V (Earlier ZBrush) by clicking on the color swatch next to the offsets, switching to HSV and entering a number. Yep, you’re setting the gain and offset on the color, not the alpha like usual.

Rinse and repeat with File1 G and B channels:

(Texture)File1.outColorG -> Luminance2.valueR
(Texture)File1.outColorG -> Luminance2.valueG
(Texture)File1.outColorG -> Luminance2.valueB
Luminance2.outValue -> displacementShader2.displacement

(Texture)File1.outColorB -> Luminance3.valueR
(Texture)File1.outColorB -> Luminance3.valueG
(Texture)File1.outColorB -> Luminance3.valueB
Luminance3.outValue -> displacementShader3.displacement

The other cool bit about this is that you can convert it into .map format and it still works, however .map format generally adds about 1/3 of the filesize as overhead when converting to a pyramid lookup. Depending on your file sizes vs. RAM vs. network throughput it may or may not be worth converting to .map.

Here’s an example scene using the tutorial setup, just with much smaller maps. Maya 2010 .ma format.

http://www.treyharrell.com/downloads/thDisplacementSplit.zip

I’m sure I’m not the first to use this particular technique, but it came in super handy tonight — it saved 4-5 minutes network spool per render slave — about 18 minutes total per frame — plus about 2gb RAM overhead on an R&D project.

2 comments January 5th, 2010

Renderman for Maya / Renderman Studio displacement hints

I’m about a month into using Renderman Studio v2, and I’d like to share a few random hints about how to get things working how you’d expect them to. This list is generally for people who are used to the mental ray/Maya way of doing things.

This first collection is about one of PRMan’s strongest points: displacements. It’s absurdly fast due to how the REYES architecture handles micropolygons, and it barely has any RAM footprint at all.

1. Object scale is incredibly important when working with displacements in RFM. Your displacement map is calculated in world space, so if you scale up your mesh in Maya, it’ll do weird things to a 32-bit displacement, and you’ll end up having to tune your alpha gain & offset to match the scaling ratio.

Freezing your transforms doesn’t work, because it’s reading the map in world space.

The proper way to fix this issue is to scale your mesh in Maya, freeze the transforms, export it out as an .obj, then import it at the lowest subdivision level into your sculpt, recalculate all your maps, then export the mesh again from ZBrush (UVs might smooth or shift, always re-export your .obj after calculating displacements).

After that, reimport it into Maya (make sure you check “Merge UVs” under the export options!). This way ZBrush is calculating your displacements at actual scale, and you can use the magic numbers: alpha gain of 2.2, offset of -1.1 on your map. Remember to turn off quadratic filtering on your image as it softens your displacements.

Note: Alpha gain / offset of 2.2 / -1.1 are for versions of ZBrush prior to 3.5. From 3.5 on, use 1 / -0.5.

2. Your shading rate affects how much of the displacement map is actually used, and you have to set this multiple places depending on your scene setup (subsurface render passes, renderradiosity render passes as well as the “quality” tab under render globals). In general, you can think of a “1″ setting for shading rate as production quality, but it’s possible to go higher (more on this below).

Worth clarifying that you don’t necessarily need to set this to the *same* value if you’re, say, doing an environment light with color bleeding. There’s a strong possiblity that a 64-sampled renderradiosity map will look totally fine and have enough detail with a sample rate of 20(!!!) and save you a ton of map calculation time.

3. Is your displacement, hair or other micro-detailed feature not sharp enough? Try cranking your sample rate all the way down to .1. — zero isn’t an option, it’ll set it to 1 automatically.

4. Getting weird blobby surface artifacts when rendering displacements (or subsurface effects)? It’s likely due to PRman’s credo of avoiding raytracing at all costs.

What you’re seeing is the result of your pointclouds or raytraced shadows being calculated against your un-displaced model, then just the points that invoke raytracing are comped over your render, and unless you force Renderman to calculate displacements against everything, you’ll end up with an ugly, blobby, posterized mess.

Click on your object, then go to the attribute editor and manage attributes. You need to add a “trace displacements” attribute to your object. (Attributes->Renderman->Manage Attributes).

Be aware, however, that if you’re using lots of rays (for raytraced shadows, for instance) that each of those rays is getting calculated a bunch of times and it can all add up in your render times.

5. While not strictly a displacement tip, it applies due to the way “trace displacements” is handled: when doing pointcloud passes for environment lights (RenderRadiosity etc), make damned sure that raytracing is disabled for your pointcloud passes or your render will quite likely never complete in your lifetime.

6. Getting a ghost of your mesh’s wireframe when using displacements and raytraced shadows? The fix is the same as tip #3 — turn your shading rate way way way down. Generally .1 is the magic setting to fix this. If you’re using other passes (subsurface, radiosity etc) make sure to set your sample rate there as well if you’re seeing artifacts on those passes as they preview render. This is a brute-force fix that looks good without tweaking any other settings.

There’s another method to fix this issue that isn’t quite so brute force: adjust your trace bias up by small amounts until the self-shadowing (that’s what those ghosts are) go away. Render times will likely be much quicker with this method, but shadows won’t likely be quite as detailed or accurate.

7. Magic numbers for 32-bit ZBrush displacements in Slim:

Assuming you’re using a combine node:

Do displacement: checked
Use shading normals: checked
Base: -0.50
Kb: 2.2

Note: Base / Kb of -0.50 / 2.2 are for versions of ZBrush prior to 3.5. From 3.5 on, use -0.50 / 1

Add a bump, make it an image file with 0 filter, set to a value of 1.

Pretty much the same thing as Maya… the math’s the same, even if the numbers are different, so it might trip some folks up.

More hints to come in the not-too-distant future.

7 comments September 1st, 2009

Video Tutorial: Recreating a damaged sculpt and texturing in ZBrush with New Topology & UVs

I think most people that have used ZBrush have gotten something really cool (or at least promising) sculpted out, and had either lower levels of subdivision get corrupt, or have your geometry get mangled… either through a crappy basemesh that you used to get up and running quickly, or invisible bad topology on a mesh that you tweaked point by point.

In this case, I was just noodling a concept from a stock basemesh that had terrible topology and I ended up losing my lowest sub-d levels at a pretty early stage. The model and texturing aren’t the greatest, but they’re not meant to be. They’re meant to be fast exercises to help arrive at a final product faster.

The following video is a half-hour step-by-step walkthrough of how you can find yourself in that situation, and how to recover your detail on a clean mesh.

Strictly speaking, the workflow is a retopology technique, but I’d never seen it applied to imported meshes with new UVs, and I’d definitely never seen recovery of polypaint/texturing info from a mucked up model.

http://www.treyharrell.com/tutes-2009/medretopo-pt1/ 

Approximately 30 minutes, embedded Flash video @ 800×600

Add comment February 11th, 2009

Resynch time on WinXP (including x64) at reboot

I love being able to triple boot Linux, MacOS X and WinXP x64 on my main Mac for 3D & web development work, however Windows handles time zone offsets differently from every other OS out there — so when you reboot into Windows, you’re looking at a 4-5 hour difference (EDT currently).

Apple’s Boot Camp drivers handle resynching the time automatically, but they don’t work with WinXP 64 (only Vista x64), so I’ve hacked together a quick .bat script that’s intended to be placed in your Startup Items folder (under the start menu).

It includes two longish pauses: the first because sometimes the startup items get invoked before the network card initializes (silly Windows). The second is so that you can read the result if the script fails before the shell window auto closes.

At any rate, just paste the following into Notepad and save as timesynch.bat in your Start Menu startup items (C:\Documents and Settings\All Users\Programs\Startup\)

@ECHO OFF
ECHO Preparing to resynch time to Internet time server ...
TIMEOUT 10
w32tm /resync
ECHO Execution complete ...
TIMEOUT 5

Add comment September 26th, 2008

Windows Doesn’t Need Your Permission to Continue

Now, fully one year after the launch of Windows Vista, heading into SP1 territory, Microsoft still hasn’t provided an easy means of turning off UAC (the “Windows Needs Your Permission to Continue” nags — User Account Control).

It’s not recommended to do this in all cases (because of viruses and malware), but if you’re good about your own usage habits — you don’t install unknown software from torrents or P2P, you don’t click every attachment in an email from an untrusted source — then read below for a step-by-step instruction on how to turn the obnoxious feature off.

As I mentioned in my rant about the preview release of Vista, I like the concept of Windows trying to protect you from yourself. I’ve spent entirely too much time cleaning malware off of other people’s machines to truly believe that all users are trainable to adopt good security practices.

That said, Vista nags the user entirely too often, and the messages all look identical. Within a day of using it, you have muscle reflex conditioned to dismiss the messages before reading them, just from hearing the “bloop” prompt, so I don’t believe it’s actually protecting many people at all due to its intrusiveness. MS has trained users to dismiss the messages without reading.

If you follow these steps, I’d strongly recommend creating a second, non-administrative account on your machine for day to day use. Only log into the administrative account to install software.

How to disable UAC (Windows Needs Your Permission to Continue)

1. Click Start Menu

2. Type MSCONFIG in the search box and hit return

3. Go to the Tools tab

4. Click “Disable UAC”

5. Reboot your machine

Vista UAC Control

Add comment February 27th, 2008

Growl for me!

picture-1.pngAs a bleeding-heart Macophile at heart, I’ve become really intrigued with Growl notifications. Growl is a cool little system (similar to Twitter, I’ve been told) that allows applications and system events to display Caller ID style messages on your Mac.

My usual Maya workflow is Maya/3D work on my Win/Linux boxes, and my other work (coding, design, illustration) I do on my Macs. I was thinking it would be nice for Maya on any render machine to send a growl render notifications to my main workstation, keeping me from having to bring various machines out of sleep / change KVM settings etc to see if batch renders have completed.

After a little bit of investigation, I discovered Netgrowl by Rui Carmo, which is a python framework for sending Growl notifications over a network.

In a leap of logic, I realized… Maya has Python integration now, but with a little bit of Googling I should be able to hack it to work, and I have.

Read on to download the script and learn how to use it.

Continue Reading 1 comment June 9th, 2007

Godzilla WIP/Tutorial - Day 5 (Detailing in Zbrush)

I’ve got a confession to make: I held off recording today’s session in anticipation
of the release of ZBrush 3. Now that I had a day or so to play with it, I’ve
learned a few tricks that will speed up the surface detailing process.

Continue on to read today’s entry and watch two sculpting videos.

Continue Reading Add comment May 18th, 2007

Godzilla WIP/Tutorial - Day 4 (Initial Sculpt)

As much as I know everyone must love reading my ramblings about random subjects,
I’m not sure I can write particularly lucidly about sculpting in Zbrush. It’s
a very organic process where you add a little here, take a little from there,
push, pull, tumble etc.

At any rate, I decided to play with Camtasia and record my initial sculpt
session. It’s the full hour-ish session from beginning to end, compressed to
about 15 minutes runtime.

Continue Reading Add comment May 6th, 2007

Godzilla WIP/Tutorial - Day 3 (Final Massing, Geometry Tweaks, Finalize Base Mesh)

So Where We?

When we last left off, we were ready to take our mesh into Zbrush for the first time.
What Zbrush (or Mudbox, if you’re so inclined) will allow you to do is get
the massing of your parts pretty close, very quickly. We’ll then head back
into Maya & get the head sculpt polished and work on some trouble spots on
the mesh.

Continue reading for part 3 in this series.

Continue Reading 3 comments May 5th, 2007

Godzilla WIP/Tutorial - Day 2 (UVing in Maya)

After putting together the first day’s basemesh, I thought it prudent to absorb
a little more reference material that wasn’t toy-based.

Are you thinking what I’m thinking? Godzilla Movie Marathon!

Read on for my UV layout session, and a little discussion about the finer points of understanding your character before finalizing your model and rigging.

Continue Reading 2 comments May 3rd, 2007

Previous Posts




Global

Categories

RSS CGTalk Maya Feed

RSS Slashdot