Particle size based on texture?

   2170   9   2
User Avatar
Member
60 posts
Joined: 11月 2015
Offline
Hi all.

I'm having good results using the flip solver and particles, using density to drive them mainly.

Now I can't seem to figure out how to vary the size of the particles based on a colored texture. So all the particles have a unique size based on the colors in the texture. And the colors from the texture would be represented in the particles.

As always, thank you for your advice. Such a great community.

T
User Avatar
Member
191 posts
Joined: 10月 2018
Offline
You could transfer uvs to your flip particles then use the Attribute from Map SOP to get the color from the texture. Then you can modify the pscale from the color attribute.
User Avatar
Member
310 posts
Joined: 7月 2012
Offline
Have you figured out getting particles to inherit the color of the texture yet, and maintain it through the sim yet? If you have got that, then you should be able to vary pscale according to color, and that should work. The hard part is making sure the color is transferred through the sim, which usually involves UVs.
User Avatar
Member
60 posts
Joined: 11月 2015
Offline
Well the challenge right now is getting the UVs to transfer properly. I'm using a UV Texture after by box geo that is generating the particles. But no matter what option I choose in the texture, the image still only transfers as stripes. I see the actual image colors are in there, but it's not UVing onto the box. It's just the image, but stretched improperly.

I can get that stripped color pattern onto the flip solver using the Attribute Map node. And in my Redshift shader I'm using the RS Point Attribute.

However, that's where I'm stuck. How would I vary the size of the particles based on the color texture. I assume it's an Attribute Wrangle/VEX. But no not sure what that would be.

Thanks for your help!

T
User Avatar
Member
191 posts
Joined: 10月 2018
Offline
It depends how you want to use the color, if you want one channel or all channels, etc. You can use a wrangle or vop to do it. This vex snippet will take the red color and fit the pscale from 0.01 to 0.1:

f@pscale = fit(v@Cd.x, 0, 1, 0.01, 0.1);

You can also take the color and put it in a ramp to remap the pscale as well.
User Avatar
Member
60 posts
Joined: 11月 2015
Offline
Thanks. I’ll give this a try.

T
User Avatar
Member
60 posts
Joined: 11月 2015
Offline
I have figured out how to have the colors of the particles from the color image. Using Attribute Map. And maintained throughout the sim.

Still haven't been able to vary the size of the particles based on the colors in the image. I see the VEX for varying the size of ONE color.

But how would the particles be sized based on the color info from the texture?

Thanks. T
User Avatar
Member
191 posts
Joined: 10月 2018
Offline
How do you want them to control the size? By brightness? By saturation?
User Avatar
Member
60 posts
Joined: 11月 2015
Offline
I think the hue. The color value.

All RGB values would have a slightly different size, between .1-1.

I think I have a good idea of how to do it. But I'd love other ideas. Thx!
User Avatar
Member
191 posts
Joined: 10月 2018
Offline
You could use the rgbtohsv vex function or in a vop to get the hue value. I tend to put values through a remap ramp so I can tweak it if I want.

vector HSV = rgbtohsv(v@Cd);
f@pscale = chramp("remap", HSV.x);

Using that code you can have your ramp flags go from 0.1-1
Edited by krueger - 2019年2月11日 21:37:02
  • Quick Links