PDA

View Full Version : Zbrush3 to Maya 16bit Displacement map workaround



DeusEx
06-21-07, 02:32 AM
This method will give similar results as "multi displacement 2", when rendered in maya with mental ray. I developed this method while in the middle of a production and it worked on several charcter elements (models) perfectly.

Warning! If you try this method on the models which come with Z3 (Demo head etc..) without first preparing it in maya it won't work. So follow the steps below.

So far I have found this method will work with any basemesh that comes from maya or created in Z3, provided that it has been properly prepared in maya prior to generating displacement.


*Note: You will need convertfile.bat, which automatically converts tif/targa/image files to .map files for mental ray, which can be found here:
http://www.datafilehost.com/download.php?file=3ec7a97e

**Model must have UVs assigned to it and normals must be set to face so that they are perpendicular to the surface pointing outward,
this process must be done in maya prior to creating displacement map in Z3.

*** If the model poly count isn't too high export the hi-rez from Z3 to prepare in maya, then re-import and reconstruct the subdiv levels.
Otherwise export the lo-rez obj, prepare in maya, re-import into Z3 and transfer the hi-rez details from the original model to the new model, using whichever technique suits the model (these techniques are covered in great detail on the pixologic site).

1. Prepare lowpoly model in maya, position model Yaxis up and Zaxis forward, assign UVs, freeze transformations,set normals to face, delete history and export.

2. Create displacement in zbrush3 and take note of the "Alpha Depth Factor"

3. Export the displacement Alpha and convert to .map file using "convertfile"
(drag and drop the displacement map file onto the convertfile and it will automatically place the .map file in the same folder)

4. In Maya set up displacement shader and mentalray approximation for Lowpoly model

5. Take the "Alpha Depth factor" number and divde by 10, then divide it by 3, then multiply by 2 this will give you the Alpha Gain
Take this number and divide it by -2 to give you the Alpha Offset (half and in negative)

e.g Alhpa Depth Factor = 4.455
4.455 / 10 = 0.4455
0.4455 / 3 = 0.1485
0.1485 * 2 = 0.297

0.297 / 2 = 0.1485

Alpha Gain = 0.297
Alpha Offset = -0.1485

Note: Make sure to turn on Alpha Is Luminance.

6. Alpha Gain acts as a multiplier for the displacement height. If the model needs to be scaled you can enter the scale factor to adjust the maps accordingly.
Multiply the Alpha Gain and Alpha Offset by the scale factor of the model.

for example, lets say the model is scaled by 13.745%
take the Alpha Gain and Alpha Offset and multiply it by the scale percentage

0.297 * 13.745 = 4.082
-0.1485 * 13.745 4 = -2.041

The new values are as follows
Alpha Gain = 4.082
Alpha Offset = -2.041


Zbrush3 settings for exporting lowest subdiv model

Preferences palette>Importexport
Turn off iFlipY and eFlipY
(do this step if the model is flipped in the Y axis when imported into maya)

Tool palette>Export
Make sure only Obj, Qud, Txr, and Mrg are on
(by default Grp is on instead of Mrg, switch them)

Zbrush3 settings for Displacement

Tool palette>Displacement
DPRes = (what you like,keep in mind a multiple of two will work best)
Turn on Adaptive, leave smoothUV off
Turn on Mode and then hit Create DispMap

Alpha palette
Select the alpha which is the displacement just created
Flip it in V, and export as filename.tiff

Maya settings for mental ray

In the Attribute Editor under File Attributes for the file texture node set Filter Type to Mipmap

Turn off Feature Displacement in the lowpoly models' shape node

Under the mentalraySubdivApprox node in the attribute editor select Spatial for the Approx Method,
set the Min Subdivions to 3 and the Max Subdivisions to 5

Set Length to 0.010 (a length of 0.10 will work as well)

Render!

I hope this is clear enough for all Z3 users to follow. I will eventually post a step by step tut with images, until then I will try to answer any questions that may arise. :tu:

eXec
06-21-07, 12:37 PM
Hello, Can U show us some final renders of Yours with this method ??

Sorin
06-21-07, 01:45 PM
Thanks DeusEx !
Sound very good that you say.
Nice job!

DeusEx
06-21-07, 04:37 PM
Ok I will post renders, using the same settings in maya but displacements from Z2 multi displacement and Z3 for comparision.

eXec
06-21-07, 10:29 PM
that would be great :)

DeusEx
06-22-07, 02:57 AM
Here are the renders

DeusEx
06-22-07, 03:16 AM
The model after it was taken into Z2, had its subdiv level reconstructed, then rendered in maya with Alpha Gain = 2.2 and Alpha Offset = -1.1

A few things occured to me while doing the renders;

-The model from Z2 would not retain the exactly the same detail as in Z3.

-Multidisplacement exports RGB.tif and the default displacement from Z3 is indexed (which I could of changed in photoshop but I chose not to because the models I used originally had indexed maps)

-I am using the Demohead which I took into maya at its lowest level, gave it automatic UVs, postioned it, then exported to Z3 and subdivided it up to 6subdiv levels and applied a few simply stamps to.

When I get around to making a tut I will use one of my models. I posted the method because it worked for me and was a more organic (non linear) approach to using Z3 in a production environment.
I hope this helps you in acheving similar results.
:D

Jawabiscuit
07-06-07, 07:56 PM
I can't import into Maya .tif file after dragging and dropping onto convertfile.bat. What da dilly yo?

knekker
07-07-07, 01:20 AM
I've tried exporting the displacement map as Tif, PSD, BMP now and none of which has any effect on the filebatconverter. when it comes to creating a .map file.

For what it's worth, I just set my object from sub lvl 4 to 1, hit Cage, went into displacement settings, set the resolution to 2048*, put on adaptive, left intensity at zero and Mid Mode to 50.

Did i forget anything? =)

DeusEx
07-08-07, 09:56 PM
"I've tried exporting the displacement map as Tif, PSD, BMP now and none of which has any effect on the filebatconverter. when it comes to creating a .map file."

I use the .tif format Z3 exports (I also flip in V). The filebatconverter should be on your desktop (as an icon), open a window then go to where your displacement.tif file is and drag'n'drop, if everything is working automatically a displacement.map file will appear below your original file in the same location.

If this isn't the case try re-instaling the filebatconverter, or simply go to the webpage and ask its creator. So far its worked for me straight off the bat (pun intended)
If you like you can always convert the .tif file the old way through a dos prompt. (before you ask I'm not going to post that method)

"I can't import into Maya .tif file after dragging and dropping onto convertfile.bat. What da dilly yo?"

In (maya) the settings for the displacement file change the type to Mipmap, that is if you are using the converted .map file.
Personally as a rule of thumb I prefer using .tga (targa) in maya when I'm using mental ray instead of .tif because I find them faster and of a high quality (whether mental ray in maya prefers them over tifs' is debatable), but when exporting from Z3 I always use .tif and convert to .map files along with mental ray approximation (settings as above, I never use featured displacement in maya).
Sometimes I come across a scene where the approximation doesn't want to take, maybe to do with animation blend shapes or a dodgy scene or there being a fullmoon. For those problems I just dig through the scene until I solve it or import all references or make a new scene.

The settings I gave above in all of my tests in maya have worked on characters (with animation) and static objects.

If you want to send me the Z3 hi rez obj I will take a look at it and try to get it workn' in maya.

Cheers

knekker
07-09-07, 12:39 AM
Thanks to Aceala, I finally got the converting from .tif to .map working.

Im just wondering why the drag'n drop onto the fileconverter, only works for some people, where others have to go through this hack.

Anyway follow this linked thread, and go to the buttom of the page, download the zip then follow the instructions from there.

http://www.zbrushcentral.com/zbc/showthread.php?t=41980&highlight=convertfile.bat

DeuEx, thank you very much for replying, and also for posting this tutorial, it has been very helpfull.

cc909
07-30-07, 05:35 PM
DeusEx



So, I have a couple of quick questions.



First: I have been watching several Gnomon videos on the subject of exporting out Displacement maps and Bump maps. According to these DVD once you have exported out your Displacement and Bump maps you should bring them into Photoshop and convert these files from Grayscale Mode to a RGB Color Mode. Is this not the case now with Zbrush 3? Or is the file Mode converted to RGB when using the “Convertible File” plugin? Or doing this manually, using the DOS function?



Second: Also in the Gnomon videos they suggest also adding a Displacement Tesselation with the Mental Ray Approximation Editor? Is this not the case in the tutorial that you outlined?



I wanted to thank you in advanced for your tutorial. I have been pulling out my hair for the past few weeks trying to get my Maps to render out correctly. I have tried day after day and have been having little success getting my maps to render out correctly. My model will either render out completely but will not all of my details, or they will render out and parts of my mesh will be extremely bloated or sunken in. I have not yet tried your method but I am about to give it a shot!



Thanks again.



CC909

DeusEx
07-31-07, 05:04 PM
cc909

"According to these DVD once you have exported out your Displacement and Bump maps you should bring them into Photoshop and convert these files from Grayscale Mode to a RGB Color Mode. Is this not the case now with Zbrush 3? Or is the file Mode converted to RGB when using the “Convertible File” plugin? Or doing this manually, using the DOS function?"

Converting your maps to RGB is done in order to use three channels (RGB) for 32bit displacements, where as grayscale will only use the red channel. As far as I know Z3 will only export 16bit displacement maps (hopefully that will change once the disp exporter for Z3 is released).
You can however convert the Z3 disp map in photoshop but you must adjust your settings in photoshop otherwise the default photoshop settings will shift the values of your map resulting in "bloating" when you render.
I've read you can get more accurate results converting your map in "HDRIshop" (program) but a .map file will read faster in mental ray and I find is more accurate as you have more control over the tesselation.
If you need higher frequency (or as some people say lower frequency, think sound waves) detail use a normal map in conjunction with your displacement.
There is a tutorial on how to create a normal map in Z3 on ZC.

"Also in the Gnomon videos they suggest also adding a Displacement Tesselation with the Mental Ray Approximation Editor? Is this not the case in the tutorial that you outlined?"

Maya settings for mental ray

In the Attribute Editor under File Attributes for the file texture node set Filter Type to Mipmap

Turn off Feature Displacement in the lowpoly models' shape node

Under the mentalraySubdivApprox node in the attribute editor select Spatial for the Approx Method,
set the Min Subdivions to 3 and the Max Subdivisions to 5
(setting Min Subdivions to 4 and Max Subdivisions to 6 also works fine)
Set Length to 0.010 (a length of 0.10 will work as well)
The length setting determines the length of each edge (tessilation) at render time, therefore smaller numbers result in shorter edges and higher poly counts and longer render times.

Tip: in Z3 before you import or export your lowpoly model remember to disable the iFlipY and eFlipY settings underpreferences>import/export.
Also make sure the UVs are done properly (not automatic) and that the models normals are perpendicular to the surface.
I do this in maya.

Ok hope that helps
Cheers

cc909
07-31-07, 07:19 PM
DeusEx,





Thanks for the quick response time. However, I am still wondering. So, yes you need to convert your files over to RGB. Can you tell me how to properly adjust the files so my displacements will not cause any bloating upon my rendering? So, how do you go about this conversion? Do you yourself use Photoshop or HDRI software?



So, also you did not mention, If in fact I need to use both Types of Mentalray Subdiv Approx node. Displacement Tesselation and Subdivisions. Or is it only necessary to just use the Subdivision Attribute? Up until now I have been applying both. Is this not the right thing to do?



I really appreciate your help and expertise in this matter.



Sincerely,



CC909

cannedmushrooms
08-01-07, 08:00 AM
Convert a file only works well on RGB documents.
Follow these steps
1. goto your color setting inside photoshop and put a check mark in the following boxes
step-1.jpg (javascript:zb_insimg('64768','step-1.jpg',1,0))
2.open the document and choose leave color alone
3. goto Image/Mode/RGB
4. save as a tif

When you drag it on the convertfile.bat It will now convert correctly.

It worked good in Z2 because the Disp Exporter Plugin exports RGB Not Grayscale;)

cc909
08-01-07, 04:12 PM
Cannedumushrooms:



Thank you very much for the information you provide. I am wondering will this also work well on Displacement maps that are being exported out from Zbrush 3? Is there a plugin for Z3. The same plugin that you mentioned for Z2?



Thanks again.



CC909

cannedmushrooms
08-01-07, 04:50 PM
Yes the displacement menu under the tool menu will produce the alpha then you save it and do the photoshop trick to it. Then save and drag onto convertfile.bat.
This will work with both Z2 and Z3



Now the Disp Exporter Plugin
Located here
http://www.pixologic.com/zbrush/downloadcenter/#disex
only works with Z2. And it handles 16 and 32 bit disp maps. The only difference is you do not need photoshop in order to convert them to RGB. You can simply click and drag it on convertfile.bat and away you go.
There is a small hack to get it to work with Z3 somwhere on the forum. Please note that it does not work too good.!




Z3 will have the plugin somwhere in the turn of the next century Give or take a few lunar cycles. Until then hope the 16 bit maps will get you by;)

Of course you could always follow this video and use Z2 to make the alpha
http://www.houseoftutorials.net/z3/z3toz2.wmv

If you dont have Z2
Everyone that does not have Z2 and bought Z3, I would be so on the phone saying "I want Z2 I bought Z3" ASAP!!!
Its much better for making all your maps and its easy to convert stuff from Z3

DeusEx
08-01-07, 05:41 PM
Here is a WIP model I have applied my workaround to using the same settings in Maya (mental ray) but changing the .map file from Grayscale 16bit (straight from Z3) and then converting to .map, and using the photoshop adjusted RGB then convert to .map technique.

The aim was to trial my method using the RGB photoshop trick.
The settings I used in photoshop were as "cannedmushrooms" provided but the results are a severe bloating in the render, where as the grayscale worked fine.

In the spirit of sportsmanship I will venture that my method does work with the RGB converted disp.map files.

However I will add using an RGB file for displacement in maya ( without the equivilant Dispexporter plugin for Z3 which Z2 had) has never in my opinion given satisfactory/accurate results and leads to a painful experience.

I answer to your question;
"So, also you did not mention, If in fact I need to use both Types of Mentalray Subdiv Approx node. Displacement Tesselation and Subdivisions. Or is it only necessary to just use the Subdivision Attribute? Up until now I have been applying both. Is this not the right thing to do?"

You only need to use the Subdiv Approx node, which is what I use.
If you really want to use both you can, which may result in a higher quality displacement (render) but would be overkill considering for such fine detail a normal map would be fine and save you time and optimise CPU performance.

The first image is the Z3 high rez model

The second is a maya render using my method

The third is a maya render using my method but substituting the grayscale for the RGB

Note: The artifacts around the shoulders are due to the sculpt in Z3 (transpose tool) not related to maya, after all its a WIP.

Hope this helps and fuels more debate
Cheers

cannedmushrooms
08-01-07, 08:43 PM
Also You only have to convert to a MAP if you have a 32bit 16 bit will render as a tif. But when it all comes down to it the less you fiddle with your maps in the conversion process the better they will turn out.
Only reason I had him do the photoshop trick was because he was having trouble with the convertfile.bat
lol guess I should have mentioned that gem huh;)

But I will post a couple really cool sample scenes that you can look at.
This one is sort of my prize collection
Link: Here (http://www.houseoftutorials.net/nolinking/displace.zip)

And this one has a Grey Scale and RGB 16bit Z3(which isnt the best at making disp) same settings for everything else, you will find no change with the rgb or grey. in the render.
Link: Here (http://www.houseoftutorials.net/nolinking/displace2.zip)


Of course theres like a million factors that make great disp. Scale of model, Uniform Polys, Uv Smoothing, Edges, Texture Resolution. So theres also a million ways to screw them up I guess my point is;)

BTW those are ma files in the zips so if you dont have maya 8.5 open the ma file in notepad and change the version number and it will open in older mayas.
7.0 Sucks really bad compared to 8.0 or 8.5 you will get flustrated very fast with disp testing in 7.0

fornet.jpg

Mitul Kawa
08-02-07, 08:53 AM
hello der can u plz help me!!
i wanna know how 2 download displacement maps...
i mean where can i find them....
ur erly reply will b Greatful...

sadicus
08-02-07, 10:25 AM
"7.0 Sucks really bad compared to 8.0 or 8.5 you will get flustrated very fast with disp testing in 7.0"

:qu: Why is that? Are there new improved Mental Ray Displacement Algorithms?



BTW good work on all the tutorials, their funny and educational.:tu:
:qu: Will you be doing more for DOOM3?

cannedmushrooms
08-02-07, 10:51 AM
You make displacement maps Mitul Kawa (http://209.132.96.165/zbc/member.php?u=88892) in Zbrush tool/displacement menu.

Mental Ray 3.5 Core is used in maya 8.0 But I also see a little change on the Aprox editor in 8.0 Which is in charge of sub. dividing the mesh based on the whites of the map.

As far as doom3 Its been a little nightmare trying to keep it fully working in maya 8.5. When doing doom3 stuff it really likes maya 5.0. I'm currently also looking for a new game engine that is not as hard to code for students. I have no problems with it but its a huge learning curve for students in the class. I found Unreal engine is working a little better but I cant make monsters as easy as I did in Doom3. So I either get great running maps or Very cool monsters that are hard to code. Hopefully as soon as Unreal 2007 hits the market that will all change;)
If you are looking for more tutorials I found
www.3dbuzz.com (http://www.3dbuzz.com/) has alot of info on doom3 and unreal engine

Sooner or later I have to do a 16 week course on game engines and modding. But I'm stalling a little till unreal 2007 hits the market.

DeusEx
08-02-07, 09:01 PM
Hi Canned Mushrooms,
I looked at your tuts and have to say I'm impressed with your dedication to educating the masses :tu:
I really apperciate all the time people spend on free online tuts as I taught myself 3D and found online resources extremly valuable.
When I got some time I'm going to go through them, can never know too much, plus its good to know different workflows than what you get comfortable with.

Thanks for posting your maya "skull" scene, I couldn't help myself so I set off a render with your settings and ooouuuch!
It took 25mins and 37sec!
I assume you used "feature displacement" instead of a MR Subdiv Approx node so as to use the RGB disp map (which BTW worked fine) also I thought this because you had "Alpha is luminence" turned off.

I took your skull obj into Z3 to use as a base mesh for my own sculpt, reason being I couldn't replicate your high rez details from your displacement map, so I made my own with a similar level of detail so I could compare renders in maya.

I do not intend this as a comparison of anatomical correctness, as you can see from my quick sculpt there is alot missing.
I just wanted to compare render times and my skull took 30sec to render with the same MR settings except for of course the disp method.

The first image is the lowpoly
The second is the Z3 high rez sculpt
The third is the maya MR comparison
Note: I didn't render both at the same time, I rendered seperately and combined them in photoshop.

I work in a medium sized post production studio and I need to keep render times per frame under 10mins which is where I developed my disp method.
However for personal projects that doesn't matter, if you got the ram to spare. ;)

P.s I would like to post my maya scene for you to look at but can't figure out how to do that, the zipped.rar file gets rejected :cry:

Any suggestions?


Cheers

cc909
08-02-07, 11:02 PM
DeusEx:



One way for you to be able to transmit files over the net is to use a free site called http://files-upload.com (http://files-upload.com/) You are able to set up a free account that you are able to post up to 1GB of files that you can then post a link to the files you have uploaded. It works well.. I have been using it for some time. The best method of using this site is to use an FTP program. The one I use most often is CuteFTP Pro. A great little program that you can get if you look around of it. By Using an FTP program you are able to upload the files much faster and much more reliable.





I hope this helps you out.





CC909.





By the way thanks again for all of the information you provided me in the past few day. I have not had the chance to try this method yet. But I am planning on giving it a try over the weekend.

cannedmushrooms
08-02-07, 11:33 PM
LOL deux ya forgot they moved feature displacement in Maya 8.5 so I glanced over it without a second thought you are right it was left on.

I'll post a newly updated render here in a min or so.
I Like this thread;) its like the devil went down to georgia displacement map style.

That was a long render, Longer than normal. but wow 25mins? gees. Do you have any satellites set up?

This one should render faster now that feature is not fighting aprox sub D.

For those new to Maya 8.5 heres where they moved feature Displacement.

feature.jpg

feature2.jpg

final-render2.jpg

To download the Scene go Here (http://www.houseoftutorials.net/nolinking/displace3.zip)
wouldnt mind getting a Time on the new render Deux just to compare
rendertime.jpg
and yes the normal map is pure Z3 (twoinks fiddle string)

cannedmushrooms
08-03-07, 01:34 AM
And only because I got tired of seeing the sewing circle threads about " I cant make a decent normal map in Z3" this ones for you baby. Thanks deus your calc works good I tweaked it a little but not much its not a calc I can write down. I just sorta feel it out. Alpha gain=Bloat Alpha offset = Suck
See sorta lame but hey it works;)
disp4.jpg
Render time 2min :35 sec

So deux is the alpha offset screwy because Z3 has a new Grey or somthing you think? Because ya it defiently falls short when you use the /2 - formula

New scene Here (http://www.houseoftutorials.net/nolinking/displace4.zip)

DeusEx
08-06-07, 08:13 PM
Cheers cc909!
I will check it out and hopefully be able to post a link to my scene file, also I will re-render that scene minus the featured displacement for ya mushrooms.
won't be for a few days though.
BTW my calculations were by trial and error, which has been approx 98-99% accurate for my work, when you need hardcore detail, i.e HD geometry or xtreme close ups, upping the MR Subdiv approx beyond what I outlined, sends render times go through the roof so normal maps a go-go :lol:

"So deux is the alpha offset screwy because Z3 has a new Grey or somthing you think? Because ya it defiently falls short when you use the /2 - formula"
Not sure? I have a feeling it might actually be something in maya, which would explain why the Z2 multidisp exporter worked so well at fixing the displacement down.

"I Like this thread;) its like the devil went down to georgia displacement map style."
I totally agree, just one question, what do you mean? :D

Cheers

cannedmushrooms
08-06-07, 09:50 PM
Oak ridge boys sings this song about a kid that will loss his soul if he doesnt beat the the devil in a fiddle playing match. My nerd humor used rendering displacement maps and ya come to think about it heeh wow I need to get out more;)
Anyway I went the way of playing with SSS in MAYA. Now that Zbrush has so many ways to transfer a image to a 3d model. After watching and reading about 24 tuts of people that all had different opinions and with a little help from my own noggen I came up with these.

The one on the left sucks but its a simple setup
the other two are more complex shaders
ssseffect.jpg

prajapati-darshan
10-17-07, 11:08 PM
hi
i am using max9 and z brush 2.
i am a first time user and its exteremly fine software.
i read ur article n found it to be very very helpful.
i think calculation regarding Alhpa Depth Factor can be made easier.
simply devide it by 15
e.g Alhpa Depth Factor = 4.455
4.455 / 10 = 0.4455
0.4455 / 3 = 0.1485
0.1485 * 2 = 0.297


or 4.455/15 = 0.297

i guess it will be more easier.