anupamd Posted August 26, 2011 Share Posted August 26, 2011 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 Quote Link to comment Share on other sites More sharing options...
Alanw Posted August 26, 2011 Share Posted August 26, 2011 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. Quote Link to comment Share on other sites More sharing options...
anupamd Posted August 27, 2011 Author Share Posted August 27, 2011 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. Quote Link to comment Share on other sites More sharing options...
Alanw Posted August 27, 2011 Share Posted August 27, 2011 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; } } Quote Link to comment Share on other sites More sharing options...
jim c Posted August 29, 2011 Share Posted August 29, 2011 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? Quote Link to comment Share on other sites More sharing options...
Alanw Posted August 29, 2011 Share Posted August 29, 2011 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 Quote Link to comment Share on other sites More sharing options...
jim c Posted August 29, 2011 Share Posted August 29, 2011 Oops, sorry about that. I didn't even realize that was possible. Quote Link to comment Share on other sites More sharing options...
Alanw Posted September 1, 2011 Share Posted September 1, 2011 (edited) 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. VOPS 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 September 1, 2011 by Alanw 1 Quote Link to comment Share on other sites More sharing options...
zoki Posted September 1, 2011 Share Posted September 1, 2011 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 Quote Link to comment Share on other sites More sharing options...
Alanw Posted September 2, 2011 Share Posted September 2, 2011 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 Quote Link to comment Share on other sites More sharing options...
zoki Posted September 2, 2011 Share Posted September 2, 2011 (edited) 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 Edited September 2, 2011 by zoki Quote Link to comment Share on other sites More sharing options...
Alanw Posted September 2, 2011 Share Posted September 2, 2011 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. Quote Link to comment Share on other sites More sharing options...
zoki Posted September 2, 2011 Share Posted September 2, 2011 (edited) 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 Edited September 2, 2011 by zoki Quote Link to comment Share on other sites More sharing options...
Alanw Posted September 2, 2011 Share Posted September 2, 2011 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. Quote Link to comment Share on other sites More sharing options...
anupamd Posted September 3, 2011 Author Share Posted September 3, 2011 (edited) 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. Edited September 3, 2011 by anupamd Quote Link to comment Share on other sites More sharing options...
anupamd Posted September 3, 2011 Author Share Posted September 3, 2011 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 Quote Link to comment Share on other sites More sharing options...
jim c Posted March 13, 2012 Share Posted March 13, 2012 Has anyone tried this out with the latest ZBrush since it can now export vector displacement maps? Quote Link to comment Share on other sites More sharing options...
jumper Posted August 16, 2012 Share Posted August 16, 2012 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 Quote Link to comment Share on other sites More sharing options...
jumper Posted August 16, 2012 Share Posted August 16, 2012 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 absoluteTangentDisp2.hip Quote Link to comment Share on other sites More sharing options...
bergj Posted August 27, 2012 Share Posted August 27, 2012 (edited) mudbox settings below Edited April 10, 2013 by bergj Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.