Saturday 25 August 2012

Blending Fluids

Blend in between two fluids done in Autodesk 3Ds Max,KCM,Krakatoa,Frost,RealFLow. Everything is rendered in VRay and COmposited in Nuke.




The main motive behind this animation was to learn KCM in 3Ds Max and have a basic understanding of Vertex based color mapping, besides this following were the artists which inspired me to create this animation:
Carlos Grury Santos
Yuval Kolton

UV and Textures:

Textures are Unwrapped in 3DS MAx and are painted in Adobe Photoshop.
juiceBoxDiffuse
box_Unwrap



juiceBoxSpec





leaf_Unwrap




spec



diffuse_front
sub_Surf















bump
















The Process:

First of all we need two fluids from any fluid simulation Application, I used Real Flow with a very basic set-up.
The important thing however, is to make sure that following channels are exported so that they can be referenced and manipulated later, channels are:
Age,
Lifespan(optional),
Velocity(optional),
Vorticity(optional),
Everything is optional except age, (hehe) as we will use "AGE" channel and tell 3Ds max to start blending or changing the color of particle stream after some specified value( which we will decide later) is reached.

Ok , now in max we will use Krakatoa Magma Flow to read channels.

I did a bit of research regarding "how to" process a bit and found following resources quite useful:
http://www.thinkboxsoftware.com/frost-data-channel-interpolat/
http://www.thinkboxsoftware.com/frost-meshing-modes/
http://www.thinkboxsoftware.com/frost-combining-frost-and-krak/

http://forums.thinkboxsoftware.com/viewtopic.php?f=89&t=6177

Following steps are what I used to create the animation, but certainly they aren't the only way of doing a fluid blend, as krakatoa with KCM and Frost are quite powerful for any creative solution.
One can find some useful tips and tricks of how to use Krakatoa,KCM and Frost together on THinkBox website:


Step1:
 I loaded particle streams in their respective Krakatoa's Prt Loaders.
       Think box Frost was used to mesh out these particles and frost's mesh-output was used  to render the scene, and using more than one Prt-Loader for particle stream inside Frost was giving artifacts.
So, the idea was to use a single PrtLoader for meshing but the question that popped up was how to distinguish two particle streams inside a single PrtLoader?

                                                                                   
Figure1
Here is the snapshot of assigning manual Material IDs for one of the two particle streams so they can be distinguished later when used, with a single PrtLoader inside Frost for Meshing.(with an Integer with some value that matches the material ID in the material editor).
                                 
I used Age input and connected it to "MXSFloat" , without which I was getting the following error.                                                                                                           

Figure2






Figure3











Lastly, all channels shown in the figure3 were written out by using Partitioning inside Krakatoa.







Step2:
    I loaded the particle stream written out in a new PrtLoader and used the MtlIndex as my input channel to distinguish particle streams(as shown in Fig4).
The output of the Figure 4 will be used in the Blend material by Vertex colour map to blend material color values where these particles streams will come in contact to each other.
Figure4


One can change the MXSFloat Channel back in to the Age channel or same can be used in the process.


I changed it back to Age with int32 data Type.


Step3:
 Now to Blend these particles into a new color or new material, I used Age as the input channel and normalized it with the value shown in Figure 5.

The normalized output is a checked against each particle's age in the particle stream depending on whether they are equal or less than the normalized value, they will have an output of  0 or 1 which is used in the Second input or the Green Channel.

Figure 5
As shown in the Figure 5 the output MXSInteger from Step2 is used in the Vector Node's first input or Red Channel after being converted to a Float value.

Now the output of this vector node is written out one of  the Mapping channels provided by KCM( in my case it's Mapping channel 5).




Material Configuration:

Red color channel of Mapping Channel 5 output is used by the vertex map in the third slot of the Blend Material (figure 6) to interpolate in between the two float values 0 and 1 for the two particle streams. This will try to interpolate between the colors of two materials in the Blend material slot.
Figure 6


The interpolated values will be touch darker as they will be in between 0 and 1.










Figure 7




Finally to convert this intermediate blend into the final material , I used a second Blend Material (Figure7) which had the Blend material from the Previous step in the first slot and a third material in the second slot. Selection between the first and second material is done on the basis of the Green Channel values (decided by the Normalized Age output) of the Mapping Channel 5.




Finally I added the PrtLoader in the Frost and meshed it out with the final Blend material Assigned to the Frost. In order to see the Blend in the viewport one has to turn on the Vertex Channel Display  with  Vertex Colour  selected from the drop Down and  Shaded  button pressed for the Object Properties of the Frost Mesh.
Here are the out puts in the viewport:

Particle Blend:


Frost_Blend:







More on Fluid blend using frost and Krakatoa can be found in the Forum shown Below:


http://forums.thinkboxsoftware.com/viewforum.php?f=89














bump