sibarrick Posted April 9, 2006 Share Posted April 9, 2006 Hi, I came across this rather funky displacement shader written by Ivan DeWolf IDGloop And tried to convert it to vex /* Converted from PRMan IDGloop by Ivan DeWolf displacement bounds can be computed with the following wildly complex formula: 10*magnitude/freq */ #pragma hint rest hidden #define VPOW(v,a,b) \ ##v.x = pow(##a.x,##b.x); \ ##v.y = pow(##a.y,##b.y); \ ##v.z = pow(##a.y,##b.y); displace d_gloop( float freq = 5; float magnitude = .2; vector rest = 0; ) { vector overdist = .1; vector stepsize = magnitude/freq; float numsteps = 20; vector Psh; if (isbound("rest")) Psh = rest*freq; else Psh = wo_space(P)*freq; float i; //vector dPduN = normalize(vtransform("object",dPdu)); //vector dPdvN = normalize(vtransform("object",dPdv)); //hopefully correctly converted to Houdini derivs vector dPduN = normalize(wo_vspace(dPds/Du(s))); vector dPdvN = normalize(wo_vspace(dPdt/Dv(t))); vector Pou = Psh + (dPduN*overdist);/*P Over a distance in U*/ vector Pov = Psh + (dPdvN*overdist); /*noise function at the point, over in u, and over in v*/ float nz = noise(Psh)-.5; float nzou = noise(Pou)-.5; float nzov = noise(Pov)-.5; float chu = (nz - nzou);/*change in noise value in u*/ float chv = (nz - nzov); /*init deflected derivatives*/ vector DdPdu = dPduN; vector DdPdv = dPdvN; vector step=0; VPOW(step,DdPdu, DdPdv); /*where it all happens*/ for(i=1;i<numsteps;i=i+1){ P -= ow_space(step)*nz*stepsize; DdPdu = normalize(DdPdu+(step*chu)); DdPdv = normalize(DdPdv+(step*chv)); VPOW(step,DdPdu,DdPdv); } /* wash your hands after displacing P*/ N = normalize(computenormal(P)); } but it doesn't look the same as Ivan's version Ivans Mine Any ideas on where I've gone wrong, or is this a limitation of Houdini derivatives? Quote Link to comment Share on other sites More sharing options...
old school Posted April 10, 2006 Share Posted April 10, 2006 The quality of the SHOP preview is probably not high enough. Try applying the displacement SHOP to some real geometry and render with Mantra. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted April 10, 2006 Author Share Posted April 10, 2006 First thing I thought of, you don't want to see what that produced, polygon hell, spikes everywhere, it scared me. I did wonder if I misinterpreted some of the renderman code. Is ^ = pow(x,y) in mantra? for example Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted April 10, 2006 Share Posted April 10, 2006 First thing I thought of, you don't want to see what that produced, polygon hell, spikes everywhere, it scared me.I did wonder if I misinterpreted some of the renderman code. Is ^ = pow(x,y) in mantra? for example 26402[/snapback] Hey Simon, Do you have the original PRan code kicking around? (the renderman.org link is no more ) I would suspect a translation error more than the derivatives... Oh, and no, the ^ operator in RSL stands for the cross product, so it is equivalent to Mantra's cross() function. (and the '.' operator is used for the dot product). Quote Link to comment Share on other sites More sharing options...
sibarrick Posted April 10, 2006 Author Share Posted April 10, 2006 Man that's crazy, it was there only yesterday..... must have just downloaded it before it expired. I have it at home but you may have nailed it with the cross product thing. That makes way more sense than power, I couldn't get my head around how that could work, so I bet that's the answer. It's just about the only other bit of the code I had to change. Cheers! Quote Link to comment Share on other sites More sharing options...
sibarrick Posted April 10, 2006 Author Share Posted April 10, 2006 Yup that did it. changing pow to cross sorted it. /* Converted from PRMan IDGloop by Ivan DeWolf displacement bounds can be computed with the following wildly complex formula: 10*magnitude/freq */ #pragma hint rest hidden #pragma range stretch -1 1 #pragma range squish -.3 .3 displace d_gloop( float freq = 5; float magnitude = .2; float squish = 0; float stretch = -1; vector rest = 0; ) { vector overdist = .1; vector stepsize = magnitude/freq*.5; float numsteps = 40; vector Psh; if (isbound("rest")) Psh = rest*freq; else Psh = wo_space(P)*freq; float i; //vector dPduN = normalize(vtransform("object",dPdu)); //vector dPdvN = normalize(vtransform("object",dPdv)); //hopefully correctly converted to Houdini derivs vector dPduN = normalize(wo_vspace(dPds/Du(s))); vector dPdvN = normalize(wo_vspace(dPdt/Dv(t))); vector Pou = Psh + (dPduN*overdist);/*P Over a distance in U*/ vector Pov = Psh + (dPdvN*overdist); /*noise function at the point, over in u, and over in v*/ float nz = noise(Psh)-.5; float nzou = noise(Pou)-.5; float nzov = noise(Pov)-.5; float chu = (nz - nzou);/*change in noise value in u*/ float chv = (nz - nzov); /*init deflected derivatives*/ vector DdPdu = dPduN; vector DdPdv = dPdvN; vector step = cross(DdPdu, DdPdv); /*where it all happens*/ for(i=1;i<numsteps;i=i+1){ P -= ow_vspace(step)*-(squish+(nz*stretch))*stepsize; DdPdu = normalize(DdPdu+(step*chu)); DdPdv = normalize(DdPdv+(step*chv)); step = cross(DdPdu,DdPdv); } /* wash your hands after displacing P*/ N = normalize(computenormal(P)); } cheers! Quote Link to comment Share on other sites More sharing options...
grasshopper Posted April 10, 2006 Share Posted April 10, 2006 Funnily enough I came across this shader a few years back and went through the same steps of converting it to vex. Well, actually I converted to VOPs with some inline vex. It seems like you have solved your problems but I can look for the old hip file and post if you like. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted April 11, 2006 Author Share Posted April 11, 2006 It's ok it's all working now, and I'm doing almost the same thing converting to Vops. I'm actually trying to split it into two so that I can plug any noise function I like into it. By the way I can still use that link at home which is really weird, because when I tried it at work I got the expired message like Mario.... Quote Link to comment Share on other sites More sharing options...
Mario Marengo Posted April 11, 2006 Share Posted April 11, 2006 By the way I can still use that link at home which is really weird, because when I tried it at work I got the expired message like Mario.... 26439[/snapback] Maybe you're seeing a cached version at home... I still get a dead page. But I paid our Martian friends a visit, and noticed that they've kindly made those shaders available to all, here. Thanks Ivan! Too bad about renderman.org though (used to visit there often) -- anyone know if this is a permanent loss? Cheers! Quote Link to comment Share on other sites More sharing options...
sibarrick Posted April 11, 2006 Author Share Posted April 11, 2006 Cool. It's such a good way to do organic displacements, since I got it for free if I get the generalised solution working I'll post it up. Quote Link to comment Share on other sites More sharing options...
peliosis Posted May 6, 2006 Share Posted May 6, 2006 Cool. It's such a good way to do organic displacements, since I got it for free if I get the generalised solution working I'll post it up. 26447[/snapback] Hello Simon, are you going to make a vop version, I can't read the code with too much understanding yet, would be great to be able to put different nodes to drive the displacement. I'm learning vex but very very slowly. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted May 6, 2006 Author Share Posted May 6, 2006 I have made one but it's in a non-commercial hip file at the moment, I was planning to convert it to a commercial version. Here it is though as is.... IDGloop.zip not fully tested, use at your own risk.... Quote Link to comment Share on other sites More sharing options...
peliosis Posted May 6, 2006 Share Posted May 6, 2006 I have made one but it's in a non-commercial hip file at the moment, I was planning to convert it to a commercial version.Here it is though as is.... IDGloop.zip not fully tested, use at your own risk.... 27292[/snapback] Thanks a lot. I'm fully nc so it doesn't matter:) There are some speckles but it's an amazing effect. Are all this ultra deeply complex nested vop layouts the vop copy of these few lines of code above???? If yes I think the code would be easier to uderstand and study:) Quote Link to comment Share on other sites More sharing options...
sibarrick Posted May 6, 2006 Author Share Posted May 6, 2006 Thanks a lot.I'm fully nc so it doesn't matter:) There are some speckles but it's an amazing effect. Are all this ultra deeply complex nested vop layouts the vop copy of these few lines of code above???? If yes I think the code would be easier to uderstand and study:) 27298[/snapback] Yup, that's the problem with converting code to vops. Although I could have made a vop out of code..... but that's another story. And yes it's a good idea to learn the code, it's often quicker. Vops are fun for experimenting with however. The speckles might be removed if you turn up displacement bounds and shading quality. As I say I never tested it. Quote Link to comment Share on other sites More sharing options...
peliosis Posted July 22, 2006 Share Posted July 22, 2006 I'm not sure but probably nobody noticed that this shader was already converted to vex by martian tools and is there in codex as renderman rewrites. Quote Link to comment Share on other sites More sharing options...
sibarrick Posted July 22, 2006 Author Share Posted July 22, 2006 I'm not sure but probably nobody noticed that this shader was already converted to vex by martian tools and is there in codex as renderman rewrites. Yeah I knew that, this was a different thing, I split the code in half so I could use it with any function I wanted not just the hard coded noise function. Quote Link to comment Share on other sites More sharing options...
peliosis Posted July 22, 2006 Share Posted July 22, 2006 Ooops, ok, please excuse me then. Quote Link to comment Share on other sites More sharing options...
ivan Posted July 27, 2006 Share Posted July 27, 2006 seems fine from here... the gloop version on the RMR actually has a bug in it; it computes the noise in camera space. But the basic idea is valid. (btw- this shader was developed to render the fire in the movie "end of days", it works pretty good for gasball explosions...) Maybe you're seeing a cached version at home... I still get a dead page. But I paid our Martian friends a visit, and noticed that they've kindly made those shaders available to all, here. Thanks Ivan! Too bad about renderman.org though (used to visit there often) -- anyone know if this is a permanent loss? Cheers! Quote Link to comment Share on other sites More sharing options...
MADjestic Posted August 11, 2006 Share Posted August 11, 2006 It seems that the link to martian labs rmshaders has changed to link 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.