Dynamic Paint (Like 3dsMax/Blender/C4D)


#21

Doing a little research on UV mapping and what you spoke of, I don’t think this one is set up correctly, which is what may be causing the issues. Would there be a quick way of fixing this or am I going to need to do some serious research?

Let me know! Thanks for all the help.

Edit: Hey! that was actually easier then I thought. All I had to do was press up on my keyboard after selecting the UV. It works now! AWESOME!!


#22

cool im glad you figured it out…in most cases dynamics engines only understand 0 to 1 uv space.
Have fun


#23

Bringing this thread back from the dead here. I have a pretty good system in place now, but my last hurdle is that how can I get this to work with multiple colors?

Since the particles paint alpha maps, and I’m using a layered texture that will show solid color underneath the texture layer it only allows for one color to be painted.

For example, say I wanted to have another emitter on the right side of this model that painted red and not blue, how would I go about doing this?


#24

Is there some reason you cant use a fileTexture instead of a solid color?

David


#25

I could, but my problem would still be the same.

Since I’m looking to create a dynamic solution that paints the object based on the color of particles that hit the object think I would need something that would say… enable “texture blue” if the particles meet that flag or “texture red” if the particles meet that flag, or something like that at least.

Here’s an example of what I can’t do with my current system, because I’m just using a single color in a layered texture that is based off a simple alpha map.

https://www.youtube.com/watch?v=czYugUWVbEQ


#26

Yes, I suspected that was what you were looking for, but just wanted to be sure. Have you looked at the way the SOuP attribute transfer methods? There are some examples on the website that show transferring color and other attributes from particles to mesh colors.

David


#27

Yeh, SOuP doesn’t really fit the bill here although at first it seems like it world.

I’ve worked with some people that have a pretty deep understanding on this roadblock and it becomes super complicated. I haven’t been able to find a solution with it yet.

Another issue is that SOuP is very complex and simply doesn’t have enough documentation for someone who is newish to Maya like myself.


#28

For multiple colors you would need to enable the color grid on the fluid and have multiple particles systems… one for each color you want to emit.

If you really needed to have a variable color per particle then you could could get the collision uv inside a particle expression then use setFluidAttr to set the color of the fluid texture at that uv value. You can get the index of the 2d fluid to use in the setFluidAttr call by multiplying the u * xResolution and v * yResolution.


#29

For my situation I would be fine with a different emitter for each color… but when I’m saying color, what I really mean is texture/material. I’m just using a solid color in my test.

I at least can’t see why yet I would need to have a variable color per each particle.

As always Duncan, thanks a ton. I’ll give this a try in a few days and report back.


#30

Re-reading your post I’m a bit confused actually. I’m not trying to color the particles themselves (Which it seems like what you instructed in your post)

I’m trying to make the separate particles emitters color an objects texture differently based on what ones particles makes contact with the object (Or to be more accurate dynamically paint a texture/materiel ontop of another).

I want them be able to “color” the object based on the particle that hits it, because as of now they just write an alpha map. The problem with this is that it can only dynamically create one color (Or texture, Which would be whatever one I have under the alpha in my layered texture)

I posted this before, but here’s what I’d like to achieve.
https://www.youtube.com/watch?v=czYugUWVbEQ
(Notice how the colors overlap each other at the end)


#31

By variable color per particle I just mean that each particle might represent a different paint color, though as I mentioned it is harder if you want the particles to simply represent any color( for example basing the color on particle speed ). If you only need a few colors then you can use a different emitter for each color( each using a different particle system ). If all you wanted was color then simply using the color settings on the emitter and mapping the fluids out color should work.(that would work for the animation example in your last post)

However it sounds like you want to have the different particles paint shaders or textures, not simply color. You could do this by again having multiple fluid emitters, each with its own particle system. Based on the fluids out color you could then blend between the particular shaders or textures with a shading network. One could instead use a different fluid node for each color and use the fluid out alphas for blending. The exact shading network method though would really depend on the desired result. Note that if you want to blend shaders one can take the out colors of shaders and blend them then plug the result into a surface shader.(just as if they were textures).

If you wanted different textures where there were different colors in the fluid you could use an HSV remap node and then map indices on the remap node with the different textures that would correspond to a particular hue value. (ramp indices can be textured, which is an easy way to blend between different textures)


#32

Ah I see, thanks for breaking that down for me. I see what you’re saying. Going to be trying this out soon!


#33

Okay, so hopefully this is a pretty simple problem, but I am once again a bit lost. I hope everything I’m about to say makes sense.

My emitter is just a particle emitter, not a fluidemitter since it wasn’t created by the fluid2dtexture container.

Because of that I have no “Fluid Attributes” section on my emitter, so I have no way to adding color output to my particles. Am I missing something simple here? I can post the scene if it would help.

Everything your saying makes a lot of sense, but I’m not sure how to go about doing it in my situation since I’m not using fluid emitters, just a particle emitter that emits density because of the expression I have within it (right?).
Thanks!


#34

Sorry… I was thinking you were directly emitting into the fluid from the particles using a fluid emitter(it is sometime hard to keep track in these long threads). However I assume you are using a runtime particle expression that does setFluidAttr. In that case you can simply set the fluid color per particle… no need for multiple emitters. You need to have some way of tagging the color you want to emit on the particles.

If you want you could use multiple particle emitters then on the particle emitter enable inheritColor and set the emitter color. With nParticles make sure the colorInput is constant and create an rgbPP channel for the color by hand, if you don’t already have one. It should then get the emitter color values. You can then use the rgbPP in your expression to set the fluid color attribute using setFluidAttr.


#35

Okay cool, so I was able to enable to rgbPP attribute and set the particle color to red an enable inherit color, which is reflected in the viewport propertly.

When it comes to creating a script I’m not sure how to do that, would you mind giving me a bit a guidance? Here’s what I have so far. It’s all based off your scripts (Or more like are exactly your scripts)


//Creating alpha map
float $u = particleShape1.collisionU;
float $v = particleShape1.collisionV;
float $emitRate = 0.5;
if( $u != -1.0 && $v != -1.0 ){
float $rx = fluidTexture2DShape1.resolutionW;
float $ry = fluidTexture2DShape1.resolutionH;
int $xi = $u * ($rx-1);
int $yi = $v * ($ry-1);
setFluidAttr -at "density" -ad -fv $emitRate -xi $xi -yi $yi fluidTexture2DShape1;
}

//Creating color
float $u = particleShape1.collisionU;
float $v = particleShape1.collisionV;
float $emitRate = 0.5;
if( $u != -1.0 && $v != -1.0 ){
float $rx = fluidTexture2DShape2.resolutionW;
float $ry = fluidTexture2DShape2.resolutionH;
int $xi = $u * ($rx-1);
int $yi = $v * ($ry-1);
setFluidAttr -at "density" -ad -fv $emitRate -xi $xi -yi $yi fluidTexture2DShape2;
}

I know that I need to create “color” also in the setFluidAttr, but I seem to be having issues. Mostly because I really don’t know how.

Also when you say to check and see if colorInput is constant, I’m not sure what you mean by that. I’ve never created color like this before so thanks for being so patient with me.


#36

You should be able to add something like the following to set the color on the fluid:
vector $rgb = rgbPP;

setFluidAttr -at “color” -vv ($rgb.x) ($rgb.y) ($rgb.z) -xi $xi -yi $yi fluidTexture2DShape1;

Color is a 3 channel value so needs to be set as a vector value(vv). Also you probably don’t want to do an add like the density set did… this just sets the color. If you wanted to do some kind of softness to the emission you could do things like use getFluidAttr to get the currently color value then blend in the particle color with that before setting it.

In terms of the colorInput attribute on nParticles the way these ramp attributes work is that there is an equivalent internalColorRamp output attribute on the nParticleShape. When one sets the input to something other than OFF (or the case of the color CONSTANT) then it automatically creates the per particle attribute like rgbPP, opacityPP, etc and connects from this rampOutput to that attribute. These graph connections are sort of hidden in that they are between attributes on the same node. If you want to set rgbPP in an expression it will already have a connection from the color ramp output( if one has the color input set to something like age), so you won’t be able to set it. Also if you set the input to Constant it then breaks the connection and deletes the rgbPP attribute( so you need to create it by hand again to set in an expression ).

Sorry if this is confusing. Note that it is possible to actually combine the ramp outputs with expressions if desired. Lets say you are currently using the age input for the color ramp. If you break the connection from the internalColorRamp to the rgbPP (you can right mouse over it under per particle attrs in the attribute editor for the nParticleShape and break the connection), you can then use the internalColorRamp inside the expression, similar to using other particle attributes. So you could for example multiply the ramp value by 2 in your expression(or by some user attribute) before setting rgbPP from it. You could also use the ramp this way to drive something other than rgbPP, like velocity.


#37

Okay, so I had to read thru this a couple times and I’m trying my hardest to get and understanding of this. I did a bit of research too, but I am still having no color emit thru my particles.

For me to understand this completely you might have to go into a bit more detail. I have a lot of questions, but I’m going to try to keep things as brief as possible since you’ve already spent to much time with me on this I feel like a jerk to keep asking things.

From what I’m gathering, the simplest sense all I should need to take is to add

vector $rgb = rgbPP;

setFluidAttr -at "color" -vv ($rgb.x) ($rgb.y) ($rgb.z) -xi $xi -yi $yi fluidTexture2DShape1;

And remove the density emitter from my current script and it should emit color where the particles make contact on my object. It should look something like this: (Simple enough?)

float $u = particleShape1.collisionU;
float $v = particleShape1.collisionV;
float $emitRate = 0.5;
if( $u != -1.0 && $v != -1.0 ){
float $rx = fluidTexture2DShape1.resolutionW;
float $ry = fluidTexture2DShape1.resolutionH;
int $xi = $u * ($rx-1);
int $yi = $v * ($ry-1);
vector $rgb = rgbPP;
setFluidAttr -at "color"  -vv ($rgb.x) ($rgb.y) ($rgb.z) -xi $xi -yi $yi fluidTexture2DShape1;
}

rgbPP should be getting it’s value (color information?) from particle color I’ve set in the “Texture Emission Attributes” (which is red). I’ve also enabled inherit color on my nParticle as well.

My next questions from from just my lack of understanding Maya:

You mention colorInput as an attribute for nParticles, but where/what is this? Under the “Per Particle (Array) Attributes” there is no colorInput here, value to be added, or anywhere that I can see under the Attribute Editor for my emitter. This goes for rampOutput and other attributes you’ve mentioned. Maybe I don’t fully understand what qualify and an attribute and how to access and edit the information within them.

Thanks again for working thru this with me, during my research I am having trouble finding anything that closely relates to what I’m doing that’s accessible to a beginner, but I’m not having much luck!