How to apply color gradient change on a fluid such as in the following figure? The method should be capable to apply to all frames in the animation automatically. Consider it as simulation of being heated gradually in some specified locations.

enter image description here

Here is our result based on accepted answer: using procedural texture. Indeed, the answer is perfect for this question.

enter image description here

One side comment is that as also mentioned in the answer, the color is not attached to the fluid so as you see the color of drop is changing as it moves. This could be our other question in other post.

enter image description here


If you want the color to stay in one place, you could use a Procedural gradient texture.

From the wiki on procedural textures:

Procedural textures are textures that are defined mathematically. They are generally relatively simple to use, because they don't need to be mapped in a special way - which doesn't mean that procedural textures can't become very complex.

This works for fluid simulations because the procedural texture exists in 3D space, so UV unwrapping is unnecessary.


Here is a node setup for cycles which uses a Gradient texture node to mix the colors used by the shader.

You can scale and translate the texture with the Mapping node. Note that it may be more intuitive to use the Texture option (added in 2.69). This will apply transforms directly to the texture:

enter image description here


example render

Blender Internal:

To do this in BI, create a new material and set the type to blend, then set the mapping coordinates to Global.

enter image description here

The texture can be scaled and translated with the Offset and Size settings in Texture > Mapping (Note that these values control the mapping of the texture, and not the position texture itself. One way to think of it is setting the size of the mesh to match the texture.

An alternative to using the mapping node or the offset and size settings is adjusting the texture space in Object Data > Texture space (ShiftT). Note that you will need to use a Texture coordinate vector for this to affect anything.

If you want the texture to move with the animation you can use either animate the mapping or texture space coordinates, or use an empty object to define the texture space.

Note that if you want the color to be attached to the liquid, using procedural gradient may be too limiting.

  • $\begingroup$ Thanks for nice answer. We considered your proposal and found it working well as shown in the update part in the question. We accepted and thanked your answer. We are now more interested in the very last sentence of your answer: "...color to be attached to the liquid...", would you recommend to ask this as another post? as it is very interesting to us to know how. $\endgroup$
    – Developer
    Dec 10 '13 at 4:54
  • 2
    $\begingroup$ @Developer Thanks :) And yes. I think that is a very good question, and it should be in a separate post if end up asking it. Asking more than one question per post is discouraged. $\endgroup$
    – gandalf3
    Dec 10 '13 at 6:59
  • $\begingroup$ Therefore the new post can be found at this link. $\endgroup$
    – Developer
    Dec 10 '13 at 7:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.