How Are Texture Coordinates Used By A Fluid?

I’ve been wondering how the fluidShape makes use of the texture coordinates that are stored along with each cell in the fluid - if & how they could be used to influence the behavior of the built-in noise functions when the Coordinate Method attribute is set to Grid.

I should explain more about why I’m interested in this. I use Maya’s fluid effects to do volume rendering, but I don’t use Maya’s built-in fluid dynamics simulation; instead I’ve got a plugin that reads data from a precomputed simulation and writes that data to the fluid’s per-cell attributes (density, temperature, color, texture coordinates, etc). I want to use the values that get read into the texture coordinates to affect the noise parameters - noise amplitude, for example - so that the effect of the noise varies across the volume and according to the data that I read from the external simulation.

It’s just not apparent to me how to make a connection between the values stored in the texcoords and the noise parameters, or if such an association can even be made. I thought the texcoords might drive 3D textures that are mapped to the noise attributes - is that how they get used?

Thanks for any insight…

  • Alex

The texture coordinate grid is just like the density grid, but instead of density it contains UVW coordinates. These coordinates are initialized to a 0 to 1 range at the start of the animation and then the fluid simulation can propagate them across the fluid. These coordinates are used to access the built in 3D texture, so that the texture will flow with the fluid as it flows. The coordinate speed controls how fast the coordinates flow relative to the other attributes, like density. The texture will tend to quickly become streaked out as it flows, which can look unnatural. I don’t think the coordinate grid is what you are after, although you can directly set the coordinate grid values rather than relying on the simulation.

The following might work… you can texture any of the shading attributes of a fluid with a 3D texture, or a projective 2D texture. Because you wish to set a grid of values on the texture you could use a fluidTexture3D for this purpose.(i.e. texture the fluidShape.noiseAmplitude with a fluidTexture3d).

The big limitation with this technique is that the applied shading network texture is initially evaluated only on the outer box of the fluid shape, not within the ray span. You need to enable volumeSamplesOverride on the fluid shape then increase the volume samples. This will do a fixed set of samples in depth and you can jitter the depth location if desired. If your texturing function is detailed you may need a high volumeSamples level, which can get slow. However if you are just controlling the amplitude of the built in texture, rather than trying to do the full texturing this way then you will generally not need this to be prohibitively high.

Duncan