tangent vector displacement maps from Zbrush 4 R4

   9049   4   0
User Avatar
Member
24 posts
Joined: Feb. 2010
Offline
Hi,
Has anyone built a successful vop network for the above.
http://www.pixologic.com/docs/index.php/Vector_Displacement_Maps [pixologic.com]
You can generate a diagnostic test (obj exr and bmp) from zbrush … I can't upload it - its 17mb.
Any help would be much appreciated.
Thanks
Stephen
User Avatar
Member
24 posts
Joined: Feb. 2010
Offline
I found this link …
http://community.aqsis.org/2012/04/tangent-space-vector-displacement-shader.html [community.aqsis.org]
(thanks v_mulligan!)
This is renderman compliant 3delight shader … I just need to convert it to a vop network…
looking at the 3Delight code …

vector ndPdu = du*normalize(dPdu);
vector ndPdv = dv*normalize(dPdv);
vector diffs = normalize(Du(s)*ndPdu+ Dv(s)*ndPdv);
vector difft = normalize(Du(t)*ndPdu+ Dv(t)*ndPdv);

and the mantra renderman mappings page ..
http://odforce.net/wiki/index.php/MantraRenderManMappings [odforce.net]

I see du (rsl) translates as Du(s) in vex…. but there is also Du(s) in the 3Delight code above - is this the same as Du(s) in vex?
Thanks!
Stephen
User Avatar
Member
1 posts
Joined: May 2013
Offline
I have the same question as jumper.

The help “Transitioning between VEX and RSL” give some useful informatin, but it doesn't mention the Du(t) , Du(s) transition to vex. I tried to set the Shading Derivative VOP 's input to s for Du(s), but it seemed not right.

Does anybody give some directions?

thanks.
User Avatar
Member
8 posts
Joined: June 2008
Offline
I had some sucess doing it in VEX. (sorry no VOP)

Down the road, the main problem is, ZBrush has an akward way to generate those maps.. Mainly, in ZBrush, when you subdivde a mesh, it changes the level 0!

In Vex to calculate the tangents I used (import uvs into vector “uv”):

udir = normalize((Du(P)*Dv(uv.y)-Dv(P)*Du(uv.y)) / (Du(uv.x)*Dv(uv.y)-Dv(uv.x)*Du(uv.y)));
vdir = normalize(cross(normalize(N), udir));


The Vectors need to be in Object space:

vector Pobj = ptransform(“space:camera”, “spacebject”, P);
vector Nobj = normalize(ntransform(“space:current”, “spacebject”, normalize(N)));
vector udiro = normalize(vtransform(“space:current”, “spacebject”, udir));
vector vdiro = normalize(vtransform(“space:current”, “spacebject”, vdir));


Then you can basically add them together (vector “amount” is the zbrush map)

PobjNew = Pobj + amount.g * vdiro - amount.b * Nobj + amount.r * udiro;


Then convert Back “PobjNew” to current / camera space and recompute the normal

P = ptransform(“spacebject”,“space:camera”, PobjNew);
N = normalize(computenormal(P, normalize(N), Ng));


In ZBrush you must set Tangent FlipAndSwitch to 7

hope that helps a bit.
—-
twitter [twitter.com]
User Avatar
Member
17 posts
Joined: Nov. 2013
Offline
thanks alot danny

the code is working nice
  • Quick Links