Jump to content

Vector Displacements revisited.


anupamd

Recommended Posts

I am going to re-vitalize the old vector displacement thread into a new thread as I strongly feel this issue is worth looking in to. Im finding very few shaders or actually no shaders available that can reliably take a map out of say mudbox or zbrush and render it correctly. Wayne Robson did a vector displacement shader for mentalray which was supposedly open source, (

) I was hoping to reverse engineer that code and adapt it for houdini, but sadly he has pulled the plugin and source from his site and cant find it anywhere on the net.

There was a shader that worked in H10 but not in H11.

(http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=15077&postdays=0&postorder=asc&start=25)

I fixed the shader so it uses compute-tan node insetad of the inline code before (see attached). The node does exactly the same thing as the inline code. There are no errors but, the shader does not work.

Attached is a zip of the hip file and my mudbox test object. Just extract a vector displacement map from Mudbox using the settings in the attached image.

I'd love to get the gears going on this and figure out a solution that works! Thoughts?

vector_displacement.rar

post-850-131435040457_thumb.jpg

Link to comment
Share on other sites

I am going to re-vitalize the old vector displacement thread into a new thread as I strongly feel this issue is worth looking in to. Im finding very few shaders or actually no shaders available that can reliably take a map out of say mudbox or zbrush and render it correctly. Wayne Robson did a vector displacement shader for mentalray which was supposedly open source, (

) I was hoping to reverse engineer that code and adapt it for houdini, but sadly he has pulled the plugin and source from his site and cant find it anywhere on the net.

There was a shader that worked in H10 but not in H11.

(http://www.sidefx.com/index.php?option=com_forum&Itemid=172&page=viewtopic&t=15077&postdays=0&postorder=asc&start=25)

I fixed the shader so it uses compute-tan node insetad of the inline code before (see attached). The node does exactly the same thing as the inline code. There are no errors but, the shader does not work.

Attached is a zip of the hip file and my mudbox test object. Just extract a vector displacement map from Mudbox using the settings in the attached image.

I'd love to get the gears going on this and figure out a solution that works! Thoughts?

I wrote a vector displacement shader for prman that you're welcome to dissect.

https://github.com/AlanWarren/demo-reel-shaders/blob/master/surface/aw_surface_std.sl

I've tested it with 32bit float ptex vector displacement maps generated in Mudbox using prman 16.1. (obj space). If you need any help let me know. Just take particular notice of the displacement method, and this header. https://github.com/AlanWarren/demo-reel-shaders/blob/master/include/aw_TexturingUtils.h aw_ptexDisplace() is the function I use for vector maps.

When I get some free time I'll try a vex port.

Link to comment
Share on other sites

Thank you Alanw, I will have to take a look at this and see if I get anywhere. I will let you know!

I wrote a vector displacement shader for prman that you're welcome to dissect.

https://github.com/AlanWarren/demo-reel-shaders/blob/master/surface/aw_surface_std.sl

I've tested it with 32bit float ptex vector displacement maps generated in Mudbox using prman 16.1. (obj space). If you need any help let me know. Just take particular notice of the displacement method, and this header. https://github.com/AlanWarren/demo-reel-shaders/blob/master/include/aw_TexturingUtils.h aw_ptexDisplace() is the function I use for vector maps.

When I get some free time I'll try a vex port.

Link to comment
Share on other sites

Thank you Alanw, I will have to take a look at this and see if I get anywhere. I will let you know!

Here's a more general code sample.


        public void displacement(output point P; output normal N) 
        {
            normal Nn  = normalize(N);
            normal Ngn = normalize(Ng);
            normal normalDelta = Nn - Ngn;

            point Po = transform("object", P);

            if (displacementmap !=  "" )
            {
                   color tmp = texture(displacementmap, s, t, "filter", "gaussian");

                   float referenceMag = length(vector "shader" (1,0,0));

                   Po = Po + (Km * normal(tmp[0],tmp[1],tmp[2]) * referenceMag);

                   P = transform("object", "current", Po);
                   N = normalize(calculatenormal(P)) + normalDelta;
            }
        }

Link to comment
Share on other sites

I'm using Houdini to render a character I made in zbrush and I'm just using the regular old basic displacement material. As far as I can tell it looks just like what zbrush outputs. Is it possible there's an issue with how you're generating the zb displacement map? Or maybe I'm not really understanding the issue?

Link to comment
Share on other sites

I'm using Houdini to render a character I made in zbrush and I'm just using the regular old basic displacement material. As far as I can tell it looks just like what zbrush outputs. Is it possible there's an issue with how you're generating the zb displacement map? Or maybe I'm not really understanding the issue?

He's referring to "Vector Displacements"

Check it out here.

http://wiki.polycount.com/VectorDisplacementMap

Link to comment
Share on other sites

I had some time to give this a shot in Mantra with the ear.ptx file floating around the net. There's really nothing to it for object space maps. If I can get my hands on a tangent space map I'll get it a shot, but that should only be necessary if the object you're rendering is deforming.

ear_vdisp.jpg

VOPS

obj_net.jpg

vop_net.jpg

VEX

/* written by Alan Warren
 * bluemoonshine@gmail.com
 *
 * description: shader with ptex vector displacement
 * 
 */

displace 
aw_vdisp_example( string vdisp_map = "" )

{
    vector Po = ptransform("space:current", "space:object", P);
    vector Nn = normalize(N);
    vector tmp;
    vector result;
    vector ptexcol;
    vector dispP, dispN;

    float uu = s;
    float vv = t;
    int fface = getprimid();
    float duu = Du(uu);
    float duv = Dv(uu);
    float dvu = Du(vv);
    float dvv = Dv(vv);

    ptexcol = ptexture(vdisp_map, fface, uu, vv, duu, duv, dvu, dvv,
           "filter", "gaussian", "lerp", 1,
           "width", 1, "blur", 0);

    tmp = Po + ptexcol;

    result = ptransform("space:object", "space:current", tmp);

    dispP = result;

    //dispP += dispN;
    dispN = computenormal(dispP, Nn, Ng);

    P = dispP;
    N = dispN;
}

Here's the Ear PTEX Vector Map

HTH

Alan

Edited by Alanw
  • Like 1
Link to comment
Share on other sites

great one Alan

thanks

I managed to get my ear fixed:)

I jsut get this error

Unable to get VEX code from:

opdef:/Shop/vectorD?DisplacementVexCode

I am not sure what I did wrong

as I am not a programer

it renders ok though

is there a chance to see your hip

post-757-131491396453_thumb.jpg

Link to comment
Share on other sites

great one Alan

thanks

I managed to get my ear fixed:)

I jsut get this error

Unable to get VEX code from:

opdef:/Shop/vectorD?DisplacementVexCode

I am not sure what I did wrong

as I am not a programer

it renders ok though

is there a chance to see your hip

Here's a hip. I don't see any warnings or errors on my end.

HIP Archive

Link to comment
Share on other sites

great alan thanks

mine is working fine

i just nee to see what i did wrong as I am not too good with vex

I tried creating new ptx files from mudbox and cant get them to work with this setup

also fules from here dont seem to work

http://ptex.us/samples.html

The files from Disney work fine for me. They're not vector, or displacement maps though so you will need to change your vop network. If you add a ptexture vop to the Mantra Surface material it should work out. Just plug it in where the diffuseColor vop is going now.

For Mudbox, you must select "Object Space" in the map export window. Otherwise they will not work with this setup.

Link to comment
Share on other sites

ah is it object space because they say always absolute for other app

anyway great stuff ptex

thanks alan

ok this pic is from mbox sculpt through alan's setup all working great

except i had to change filtering quite high in mbox and displ bound increased bigger than displ amount in h

post-757-131497499091_thumb.jpg

Edited by zoki
Link to comment
Share on other sites

ah is it object space because they say always absolute for other app

anyway great stuff ptex

thanks alan

ok this pic is from mbox sculpt through alan's setup all working great

except i had to change filtering quite high in mbox and displ bound increased bigger than displ amount in h

Mantra also has a parameter you can add to your geometry called Redice displacements that might help in this case.

Object space maps render faster than absolute tangent maps, but they will not work on deforming geometry. (moving point positions). They do work with animated objects though.

Link to comment
Share on other sites

Alan awesome! This works great, I made a VOPs version of the shader as Im not quite vex savvy yet. Here are my test results.

The one thing that Im trying to figure out is that the displacement does not seem to work on a generic mesh (just a grid). I have to export the low-rez mesh form mudbox (fbx) and only then it works. If I try it on a standard grid, things get wierd. Im guessing the reason why is because ptex cares about the face primitive ID order so if the primID of the face is missmatched you will have issues.

I'll try to roll a version of the shader that just uses 32bit tiffs instead of ptex which hopefully will solve the primID issue.

post-850-131502853461_thumb.jpg

Edited by anupamd
Link to comment
Share on other sites

Ok, made a version with works with 32bit TIFFs. Also just converted Alan's VEX code to a VOP net (pretty trivial), kinda bruit forced into the standard displacement shader too so I can get textures and all the other stuff with it.

I suppose for those who are more familiar with VOPS over Vex this might be useful to you. Big thanks again to Alan for sorting this all out.

vectorDisplace3_VOPS.hip

Link to comment
Share on other sites

  • 6 months later...
  • 5 months later...

Hi,

Has anyone tried making a vop network for absolute tangent vector dsiplacements from Mudbox. I am not sure what absolute means...

I found this for 3Delight and maps from Zbrush....

http://community.aqsis.org/2012/04/tangent-space-vector-displacement-shader.html

not even sure if this would help.

Would be great to have something like this in vops for mantra....

Cheers

S

Link to comment
Share on other sites

Hi,

I am trying to get absolute tangent vector displacements to work in mantra, ideally in vops.

Here are some renders ...

highResMeshDispBakedIn.jpg a render of a high res mesh with the displacement baked into the mesh.

objectVectorDisp.jpg - object vector displacement - (this an example from anupamd's post) It matches closely the high res mesh above (apart from the edges where I did a bounding box delete on the two geos) - This works!

absoluteVectorDisp.jpg this does not match the above and is my attempt at a tangent based displacement.

Can anyone take a look at my attempt at a mantra vop network for absolute tangent vector displacements and tell me what I am doing wrong?

I found this...

http://community.aqsis.org/2012/04/tangent-space-vector-displacement-shader.html

Which is for 3Delight and zbrush ... not sure how to translate it to vops or even if this is the solution. It seems to be a lot more complicated than my solution too.

I have uploaded the hip file with shaders... If someone could take a look. Unfortunately the displacemnet maps were huge so I couldn't include these...

Thanks

s

post-5443-13451372111_thumb.jpg

post-5443-134513722614_thumb.jpg

post-5443-134513723982_thumb.jpg

absoluteTangentDisp2.hip

Link to comment
Share on other sites

  • 2 weeks later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...