Jump to content

Coloring of Particles using im3d


thor

Recommended Posts

Hi there, i have some likely basic question concerning the coloring of particles. Basically I want to do the following, change color / opacity values for the shading on a perParticle basis.

I create a particle setup and let's assume the particles move pretty the way i want to. I've followed the tutorials on how to setup the 3D Texture Generator and if I understand this right, the idea here is the following, the metaballs are no more than spheres with a density falloff and the 3dtex generator simply writes an volumetric density texture for me based on the particles, metaball settings etc. Unfortunally this texture holds no information on the actual particles anymore --> i couldn't write create shading networks to drive the color based on the particle attributes (e.g. drive the color based on the per particle speed, age etc.). Is there a "classic" trick, to do such things similar on how you can create these things with sprites / streaks particle output types ?! Or does it require a seperate volumetric texture / shader for each particle.

I'd really love to avoid doing so, since i guess with self-shadowing etc. rendertimes would rise dramatically and it would require small particles to avoid those obvious particle blobs.

One idea i had so far was to use CHOPs to drive the Weight value of the metaballs on a per metaball basis (if this is possible) --> creating volumetric 'density' textures that represent rather things such as Speed, Acceleration of the particles and use these volumetric textures in turn with a ramp or something similar to drive the color. Thanks for any help on this

<_< plz excuse my english

Link to comment
Share on other sites

Thanks, I expected there would be an easier solution to this. I'm pretty new to houdini and I'm used to Maya, which generally seems to have premade solutions for most standard problems.

So far, it seems to me that in order to keep the progammers at sidefx focusing on the main features they expect the users to do all the smaller codework. Luckily VEX is pretty staight forward and the documentation on it isn't too bad either :)

Link to comment
Share on other sites

  • 7 months later...

hey edward

edward  Posted May 15 2004, 09:07 AM - If you create your own IMG3D shader then you can pump out a 3D colour channel as well in addition to density information.

how can i write out more than one channel to a i3d file ?

or a shader that does that so i can hack out a solution from.

thanks in advance

all the best

aracid :blink:

Link to comment
Share on other sites

  • 3 weeks later...
In your IMG3D shader, you just need to export your parameter and write to it ... same as a SOP (for attributes) or Surface VEX shader (for deep rasters).

15733[/snapback]

Hmmmm...I'm using "export" and I'm still only getting density. Using 'i3dinfo' says one channel. No error message. This is v7.0.214 I believe.

Link to comment
Share on other sites

It's not enough to just export the parameter. You have to actually write to it as well ... :) I've attached a trivial example.

16100[/snapback]

Hmmm, okay, it looks like the only difference in your example is in making the exported parameter a top level parameter rather than defined down in the VEX code for the shader. I was looking at Jason's example in the "blend_attribute" i3d shader part of his i3d coding tutorial. Jason, you might want to update this!

Whenever I'm stuck I constantly look at these since the docs and example code provided aren't always, um, helpful (or there). I'm hoping he'll do one on point clouds soon :D

[update]

I just tested it and moving the export up did the trick. Sweet.

...into () and out of {}...

Link to comment
Share on other sites

Err, seems I'm having a bit of trouble with this.

OK, I'm using the Metaball Attribute VOP inside a Point Loop to import the color attributes from my particles. I export the parameter and then I go ahead and generate the i3d file.

In my fog shader (which is just the VEX 3D Texture Fog shader brought into VOPs) I import the variable using the Texture 3D VOP. The problem is when I render I only get blended colors in my fog. For example if I have yellow and blue particles I end up with green fog. I think I'm missing something in the Point Loop, just not sure what...

Link to comment
Share on other sites

Err, seems I'm having a bit of trouble with this.

OK, I'm using the Metaball Attribute VOP inside a Point Loop to import the color attributes from my particles. I export the parameter and then I go ahead and generate the i3d file.

In my fog shader (which is just the VEX 3D Texture Fog shader brought into VOPs) I import the variable using the Texture 3D VOP. The problem is when I render I only get blended colors in my fog. For example if I have yellow and blue particles I end up with green fog. I think I'm missing something in the Point Loop, just not sure what...

16162[/snapback]

So you're doing the loop for points, but how are you coming up with the final color? You should, possibly, off the top of my head so I could be dead wrong, find the particle/blobby contributing the most density to "P" and then use its color. Hmmm...looks like that's what Jason's example in the i3d tutorial is doing.

Looking at Jason's code in the tutorial he's only exporting the blended color though the export needs to happen up top between () rather than between {}.

I'm tired.

Link to comment
Share on other sites

OK, I've read Jason's shader writing tutorials and the introductory VEX stuff in the online help. It explained a lot, but this code below is still kicking my ass.

#pragma hint blended_color hidden

image3d

blend_attribute (

              export vector  blended_color=0;

              )

{

float  d = 0, max = 0;

vector clr = 0;

forpoints( P )

{

  d = mdensity(P);  //get density of metaball

  if (d > max)

  {

    clr = mattrib("Cd", P); //get the unblended color attribute

    max = d;

  }

  blended_color = d * mattrib("Cd", P); // blend based on density

}

density = max;

}

To get the blended color I need to multiply the mdensity (once it's been "maximized"?) by our color attribute. Fair enough. How is the line "if (d > max)" used in VOPs? So confuuuuused. :wacko:

Link to comment
Share on other sites

OK, I've read Jason's shader writing tutorials and the introductory VEX stuff in the online help. It explained a lot, but this code below is still kicking my ass.

To get the blended color I need to multiply the mdensity (once it's been "maximized"?) by our color attribute. Fair enough. How is the line "if (d > max)" used in VOPs? So confuuuuused.  :wacko:

16282[/snapback]

Oh my, that code doesn't look right - did I even test it?? Does it work as advertised? Its been a long time since I wrote an i3d shader and I'm not sure about the clr=mattrib() line at all. Looks like I was trying to do a simple max() and blend in the point color based on that, or something. It looks like the shader could be restructured a bit to use max() instead.

Sorry for the confusion! I'll look at it again tomorrow...

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