wildparky Posted June 16, 2003 Share Posted June 16, 2003 how can i use 'a POP vector array (hituv)' in 'SOP vop'? i need 'hituv array' in sop vop to merge all ripples. is there any other way to do this without using array ? sop h_ripple(){ int i; int npt; // all hit count vector hituv[]=0; // hituv array vector result=0; ..... ..... for(i=0;i<npt;i++){ float ri=ripple(s, t, hituv.x, hituv.y) result+=ri; } return result; } .... hituv_array.zip Quote Link to comment Share on other sites More sharing options...
wildparky Posted June 19, 2003 Author Share Posted June 19, 2003 How can I use arrays in VEX?.. Quote Link to comment Share on other sites More sharing options...
Wolfwood Posted June 19, 2003 Share Posted June 19, 2003 VEX doesn't support arrays, sorry. jim. Quote Link to comment Share on other sites More sharing options...
wildparky Posted June 23, 2003 Author Share Posted June 23, 2003 thanks WolfWood. then how do i use a pop array attribute ("mc"=hituv) in rman shader? plz confirm a ripple.sl & doarray.hip file what's wrong ? array.zip Quote Link to comment Share on other sites More sharing options...
Wolfwood Posted June 23, 2003 Share Posted June 23, 2003 VEX doesn't support arrays, however the RenderMan Shading Language does. There a lot of different ways to do rain drops. Each method has its advantages and disadvantages. In the past I've done it the following ways. 1.) Make a rain texture pass. This is probably the fastest technique, but it requires some time setting up. 2.) Pass all the rain drops points into the shader as a parameter, for example ..... #define MAXDROPS 600 surface rain( float numdrops = 1.0; point Droppos[MAXDROPS] = {point(0,0,0)}; float DropSize = 0.2; ) .... This will work but its not pretty. 3.) Save the particle positions out to a file then write a shader DSO to read the file. This method can handle LOTS of particles but requires some C coding. jim. Quote Link to comment Share on other sites More sharing options...
wildparky Posted June 24, 2003 Author Share Posted June 24, 2003 Thanks There is a array("mc")in the ribfile, but I can't use it in the shader mc[1]=> 0.1 0.5 0.5 in the ribfile, but printf("%f\n",mc[1])=> 0 0 0 in the shader. is shader code wrong ? /////// RIB FILE ////////// Declare "mc" "vertex point" Declare "hc" "constant float" NuPatch 4 4 [ 0 0 0 0 1 1 1 1] 0 1 4 4 [ 0 0 0 0 1 1 1 1] 0 1 "Pw" [ -0.5 0 -0.5 1 -0.166667 0 -0.5 1 0.166667 0 -0.5 1 0.5 0 -0.5 1 -0.5 0 -0.166667 1 -0.166667 0 -0.166667 1 0.166667 0 -0.166667 1 0.5 0 -0.166667 1 -0.5 0 0.166667 1 -0.166667 0 0.166667 1 0.166667 0 0.166667 1 0.5 0 0.166667 1 -0.5 0 0.5 1 -0.166667 0 0.5 1 0.166667 0 0.5 1 0.5 0 0.5 1] "mc" [ 0.1 0.5 0.5 0.182759 0.5 0.5 0.293103 0.5 0.5 0.403448 0.5 0.5 0.486207 0.5 0.5 0.596552 0.5 0.5 0.706897 0.5 0.5 0.817241 0.5 0.5 0.9 0.5 0.5 0.9 0.5 0.5 0.9 0.5 0.5 0.9 0.5 0.5 0.9 0.5 0.5 0.9 0.5 0.5 0.9 0.5 0.5 0.9 0.5 0.5 ] "hc" [ 25 ] ...... //////////// RMAN shader /////////// #define MAXHIT 100 displacement ripple (float Km = 0.03, numwaves = 22,decay=22, hc=0; point mc[MAXHIT]={point(0,0,0)}) { float amount=0; float i; for (i=1; i<hc; i+=1) { float hump, dist, sdist, tdist; sdist = s - xcomp(mc); //ripple s center tdist = t - ycomp(mc); //ripple t center dist = sqrt (sdist * sdist + tdist * tdist); hump = sin (dist*6.283185 * numwaves)*exp(dist*(-decay)); amount+=hump; } P = P - amount * Km * normalize (N); N = calculatenormal (P); printf("%f\n",xcomp(mc[1])); } //////////////////////////////////////////////////// Quote Link to comment Share on other sites More sharing options...
Wolfwood Posted June 24, 2003 Share Posted June 24, 2003 A couple of things, first You don't want to declare "mc" as a "vertex point" since that will cause the values to be interpolated based on the gprim's interpolation rules. It should be Declare "mc" "constant point". Make sure your array size is the same in both your shader and Declare statement. For example. In the RIB, Declare "mc" "constant point[100]" In the shader, #define MAXHIT 100 point mc[MAXHIT]={point(0,0,0)}) One thing to watch out for is the space in which your points ("mc") are in. Point parameters passed to shaders will be in "current" space, IIRC. You may need to either transform your points into "shader" space or you could take the easy road and define your points as the "color" type and not worry about what space changes. jim. Quote Link to comment Share on other sites More sharing options...
Wolfwood Posted June 24, 2003 Share Posted June 24, 2003 If you give me a full RIB file with all the camera stuff I can try to get your sample to work in BMRT. If its not too big you can post it here, otherwise it would be better to email it. jim. Quote Link to comment Share on other sites More sharing options...
wildparky Posted June 24, 2003 Author Share Posted June 24, 2003 thanks again here is a rib & hip aa.zip Quote Link to comment Share on other sites More sharing options...
edward Posted June 24, 2003 Share Posted June 24, 2003 just guessing here but why isn't it possible to create your hituv attribute and then pass that to your vex sop? Quote Link to comment Share on other sites More sharing options...
Wolfwood Posted June 25, 2003 Share Posted June 25, 2003 BMRT is being a pain and won't let me render. Try rendering these and tell me if it works. I made a few changes and noted them in caps. Edward: Ah... thats a good idea too. jim. ripple.zip Quote Link to comment Share on other sites More sharing options...
Wolfwood Posted June 25, 2003 Share Posted June 25, 2003 It does work. BMRT was being REALLY picky about the RIB. I can't output RIB from Houdini since I only have apprentice. Someone else will have to jump in here. You'll need to tell Houdini to output "mc" as a "constant point[some number]" You might need to have a little perl script go in and change it after you write out a RIB file. Or use the Post Include Script thing in the Object render dialog. jim. Quote Link to comment Share on other sites More sharing options...
Wolfwood Posted June 25, 2003 Share Posted June 25, 2003 Sorry for spamming All along I thought your mc was a actual point in space, but its actually the UV coordinates. I'm a tad slow. I would recommend declaring them as colors so you don't have to worry about transforming them. So your shader would look like this #define MAXHIT 500displacement ripple (float Km = 0.03, numwaves = 22, decay=22, hc=0; Quote Link to comment Share on other sites More sharing options...
wildparky Posted June 25, 2003 Author Share Posted June 25, 2003 welcome your spamming. Nice! it's walk! single rib i have to change sequence rib files("constant color[500]"). how do i tell Houdini to output "mc" as a "constant point[some number]" not edit rib but use the Post Include Script thing in the Object render dialog. Quote Link to comment Share on other sites More sharing options...
Wolfwood Posted June 25, 2003 Share Posted June 25, 2003 Sorry I can't help you on this one. I only have apprentice so I can't test Houdini's RIB output. Maybe someone else can jump in. jim. Quote Link to comment Share on other sites More sharing options...
Wolfwood Posted June 25, 2003 Share Posted June 25, 2003 Can't help with creating the output but maybe I can help with processing it. The following is a perl script that can act as a filter for RIB files. If you are on Linux you can use pipes. For your render command you could do something like declareMod.pl mc constant point 100 | prman On windows you could write out the ribs to disk then process each of them. on the command line type, for %i in (*.rib) do more %i | perl declareMod.pl mc constant point 100 | prman declareMod.pl #!/usr/bin/perl -wuse strict;#Usage: declareMod.pl Quote Link to comment Share on other sites More sharing options...
wildparky Posted June 25, 2003 Author Share Posted June 25, 2003 Thanks alot and edward 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.