Jump to content

Use a pop array in vop sop or vex sop !!??


Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Thanks :ph34r:

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]));

}

////////////////////////////////////////////////////

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

It does work. :P 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.

post-15-1056504943.jpg

Link to comment
Share on other sites

Sorry for spamming :P

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 500

displacement ripple (float Km = 0.03, numwaves = 22, decay=22, hc=0;

Link to comment
Share on other sites

welcome your spamming. :D

Nice! it's walk! :rolleyes: 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.

Link to comment
Share on other sites

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 -w

use strict;

#Usage: declareMod.pl

Link to comment
Share on other sites

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