Jump to content


Vector Displacements revisited.


  • Please log in to reply
20 replies to this topic

#1 anupamd

anupamd

    Initiate

  • Members
  • PipPip
  • 102 posts
  • Joined: 29-March 05

Posted 26 August 2011 - 01:25 AM

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.co...er=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?

Attached Thumbnails

  • Capture.JPG

Attached Files



#2 Alanw

Alanw

    Initiate

  • Members
  • PipPip
  • 173 posts
  • Joined: 22-October 07
  • Name:Alan Warren

Posted 26 August 2011 - 11:52 AM

View Postanupamd, on 26 August 2011 - 01:25 AM, said:

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.co...er=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/A..._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/A...w_ptexDisplace() is the function I use for vector maps.

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

#3 anupamd

anupamd

    Initiate

  • Members
  • PipPip
  • 102 posts
  • Joined: 29-March 05

Posted 26 August 2011 - 11:51 PM

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


View PostAlanw, on 26 August 2011 - 11:52 AM, said:

I wrote a vector displacement shader for prman that you're welcome to dissect.
https://github.com/A..._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/A...w_ptexDisplace() is the function I use for vector maps.

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


#4 Alanw

Alanw

    Initiate

  • Members
  • PipPip
  • 173 posts
  • Joined: 22-October 07
  • Name:Alan Warren

Posted 27 August 2011 - 07:05 AM

View Postanupamd, on 26 August 2011 - 11:51 PM, said:

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;
			}
		}



#5 jim c

jim c

    Illusionist

  • Members
  • PipPipPip
  • 385 posts
  • Joined: 01-November 08
  • Name:Jim Crafton

Posted 29 August 2011 - 12:58 PM

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?

#6 Alanw

Alanw

    Initiate

  • Members
  • PipPip
  • 173 posts
  • Joined: 22-October 07
  • Name:Alan Warren

Posted 29 August 2011 - 01:50 PM

View Postjim c, on 29 August 2011 - 12:58 PM, said:

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.polycoun...DisplacementMap

#7 jim c

jim c

    Illusionist

  • Members
  • PipPipPip
  • 385 posts
  • Joined: 01-November 08
  • Name:Jim Crafton

Posted 29 August 2011 - 03:31 PM

Oops, sorry about that. I didn't even realize that was possible.

#8 Alanw

Alanw

    Initiate

  • Members
  • PipPip
  • 173 posts
  • Joined: 22-October 07
  • Name:Alan Warren

Posted 01 September 2011 - 10:06 AM

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.

Posted Image

VOPS
Posted Image
Posted Image

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, 01 September 2011 - 12:27 PM.


#9 zoki

zoki

    Illusionist

  • Members
  • PipPipPip
  • 266 posts
  • Joined: 16-November 04

Posted 01 September 2011 - 01:52 PM

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

Attached Thumbnails

  • ear.jpg


#10 Alanw

Alanw

    Initiate

  • Members
  • PipPip
  • 173 posts
  • Joined: 22-October 07
  • Name:Alan Warren

Posted 01 September 2011 - 06:13 PM

View Postzoki, on 01 September 2011 - 01:52 PM, said:

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

#11 zoki

zoki

    Illusionist

  • Members
  • PipPipPip
  • 266 posts
  • Joined: 16-November 04

Posted 01 September 2011 - 11:15 PM

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 by zoki, 02 September 2011 - 02:54 AM.


#12 Alanw

Alanw

    Initiate

  • Members
  • PipPip
  • 173 posts
  • Joined: 22-October 07
  • Name:Alan Warren

Posted 02 September 2011 - 05:34 AM

View Postzoki, on 01 September 2011 - 11:15 PM, said:

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.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users