I’m been trying to assign 2 different vray shaders to different particles in a system. Its my understanding that frost has the ability to use mtl IDs to apply different shaders to different particles in the isomesh
I’ve got two events : a birth and then a spawn to a new event. Each event with a material static object set to ID 2 and ID 3. For some reason I get a No mtlIndex message from frost
I’ve been watching matt muller particles videos with frost.
00:41-00:49 seems to have what i’m after. looks like particles are spawning that have a different Mtl ID/ Shader . 00:03 - 00:10 also have something similar.
The message from Frost is indeed misleading, but it is working.
The Material rollout was meant to do two things: Control which Channel to use to control the Material assignment, and let you build your own Muti/Sub Material WHEN USING GEOMETRY MODE. The button does not get enabled when Frost is in any of the Metaball modes, because there are no source geometries distributed onto the particles to get materials from. Frost does not have (yet) the ability to grab the materials of the PFlow and build a Multi/Sub Material out of them - you have to do it yourself.
So here is what I did:
*I created a Standard Flow.
*I added a Split Amount and sent 50% of the particles to a second event.
*I added a Material Static to the first event and set it to generate ID 1 and show them in the Viewport. Assigned a red material to it.
*I did the same for the second event, but with ID 2. Assigned a green material to it.
*I created a Frost object from the PFlow
*In the Material rollout, I set it to “ID from MtlIndex Channel”
*In the material editor, I created a new Multi/Sub Material and dragged the red material to the first slot and the green to the second.
*I assigned this manually created material to the Frost object
RESULT: I got blobs in red or green depending on the MtlIndex of the respective particle.
If you were replacing each particle with a custom geometry object and you had multiple such geometry objects, each with its own material or set of sub-materials, using the button in the Materials rollout would have generated a single Multi-Material out of the materials of all geometry objects and assigned it to Frost automatically. This is illustrated in the second part of this rollout: thinkboxsoftware.com/frost-g … hing-mode/
I will update the documentation to explain this better. Right now, it is not obvious why the button is grayed out and why it appears that it is not working…
The alternative method would be to use a Mapping Channel to control a Blend Material. Assign a Mapping channel value like 0,0,0 to your particles and change it to 1,1,1 in the other event. Use a Vertex Color Map in the Blend Material’s third slot to control the blend amount of two materials of your choice. The result will be smoother blending instead of a abrupt change from face to face.
Could you explain how the second approach causes the shaders to blend? By setting the mapping channel to 0,0,0 in the first event and 1,1,1 in the other wouldn’t that just cause them jump abruptly from 0,0,0 to 1,1,1. I don’t see how the blend material is getting intermediary values from between the two mapping channel values. Thanks again Bobo!
It is Frost Magic
Here is the deal: In the image I posted above, I have 50% of the particles (red) in the first event with a mapping value of 0,0,0. The other 50% are already in the second event (green) with a value of 1,1,1. Frost takes the mapping values of each particle that influences the final mesh, and INTERPOLATES these values over the polygons. So if you have a vertex that is close to a particle with a value of 0,0,0, it will get that mapping value. If another vertex is close to a particle with a mapping value of 1,1,1, it will get that value. If a vertex is half-way between two particles, it is going to get a mapping value of around 0.5,0.5,0.5. On top of that, Max interpolates its mapping coordinates - look up “Barycentric Coordinates”. A texel in the center of a face will get 33% of each corner’s UVW value. A texel in the middle of an edge will get 50% of the edge’s values and so on. So if you evaluate a Vertex Color Map in the middle of an edge between a vertex with a value of 0,0,0 and another with a value 1,1,1, you are going to get something like 0.5,0.5,0.5 even if there is no actual vertex there. So both Frost and Max do the interpolation of values and you end up with SMOOTH transition if you control a Blend material using a Vertex Color Map.
On the other hand, MtlIndex values are Integers. Frost cannot perform any interpolation on them, so a whole face in the Frost mesh gets either the one or the other, depending on which particle has the highest influence. If you have 100 particles close to a face, the distance of the face to each particle produces some sort of weighting. The average of all influences of all particles is calculated and whatever comes out is assigned to the whole face, so you get abrupt changes. You can increase the mesh density to smooth it out a bit, but it will still be jagged.
Spoken like a poet! thanks for clearing that up. You answered my second questions about MtlIDs before even asking it.
On a side note. I’ve been meaning to pick up your particle script show DVDs. Are they still all that relevant with advent of box 3 and krakatoa around these days?
They are relevant if you intend to do either scripting in PFlow or work in Box #3. They don’t teach Box #3 directly, but the ideas presented in them are transferable. Box #3 is just a faster, more visual and usually more powerful way of doing particle scripting. If you don’t intend to do any PFlow scripting, then you might want to save your money for something else. CG-Academy stopped paying its authors a long time ago, so I have no financial interest in advertising these DVDs. They were useful and quite cool, but make sure you are not wasting your money on something you don’t absolutely need.
It seems that that MtlIndex channel exists only in the render particles. If you want to see the MtlIndex in the viewport, you can enable “Use Render Particles” in the Frost Meshing rollout.
We cannot access UV coordinates from TP directly because that info is stored in the particle meshes and not as particle data channels.
But I think you could provide a custom data channel per particle to define the blend value. The simplest way would be to define a channel called Color of type Color.
Krakatoa will automatically load this from TP as the Color channel. Then just drop a Vertex Color Map in a Blend Material and use channel 0 (Vertex Color channel of Max) to blend.
I suspect it would work with arbitrary custom channels from TP, but you would have to save the TP particles to PRT and save the custom channel to disk in the process, then use a KCM to copy your data channel into one of the 100 mapping channels.
Or define channels called Mapping2, Mapping3 of type Point3 in TP and try to use them directly. I haven’t tried this, so I could be wrong and it might not work. But the Color channel approach should work for sure.
I was successful “partially”, to blend two fluids sims from Real Flow by assigning an integer value of the materialID I am trying to use for each fluid and outputting that to MtlIndex output channel in Magma Flow editor.
However, the blend was quite sharp/abrupt as I used the Multi-Subobject material. While reading this thread, I have a question:
Is there a way we can create a UVW map for the Realflow .bin particles ?
As I am new to this Forum and I am learning this software , I would appreciate any explanation or a link to some thread where I can get answer of my questions.
As you noticed, since the Material Index is an integer, it is either/or. But what you could do is add a Krakatoa Channels Modifier (aka Magma Modifier in Krakatoa 2.0) on top of a PRT Loader that reads the BIN particles, copy the Integer value into the X component of a Vector and output as a Mapping channel.
Note that this works with the free Evaluation version of Krakatoa, so you don’t have to buy Krakatoa to use it with Frost.
Once you have copied the Integer into the Mapping channel, Frost will blend the values smoothly between vertices. If a bunch of particles have a value of 1 and then some neighbor particles have values of 0, vertices between these regions will have floating point values between 0.0 and 1.0, e.g. 0.5.
You can then use a Blend Material with the two desired materials, and a Vertex Color Map in the control slot set to use the same Mapping channel generated in the Magma modifier, and the two materials will be blended smoothly as described in previous posts in this thread.
Thanks for the fast reply and your time.
I read your post and retried the mapping procedure by adding a Krakatoa channel Modifier on top of the prt loader.
I used the same “MtlIndex” with value 1 as my input channel value , after converting it into vector by uing “tovector” node i used the out mapping channel to mapping 2. While doing this particle disappears. When I try to select the prt Loader in to my frost object an error dialog pops up stating that
“ERR: BuildMesh: append_code_segment() - Recieved a NULL fn ptr”
I didn’t understood the line where you are asking me to copy the integer value to X component of a vector, is it the same node “toVector” node?
First you convert the Integer to Float using ToFloat. Then you input the result into the first socket (X) if a ToVector (it has X,Y and Z). Set the Y and Z to 0.0 (in Magma 2, no need to do anything, they default to 0.0 already).
The error you got sounds like you were using Krakatoa 1.6.x and you did not convert the Integer to Float before feeding it into the ToFloat.
A little pain but it gets really nasty if I try to assign “Vertex Color Map” to Hair anf Fur’s density - it crash imitatively after make a render… I have just a second to take a shot:
Any suggestion? LOL
Are you saying you are assigning Vertex Color Map to the actual Hair&Fur modifier’s Density slot?
I just tried that and it did not crash (in Default Scanline).
If that’s what you mean, it is not our bug, right? I have no ideas for a workaround, Max Hair and Fur is what it is…