Posted by Duncan Brinsmead, 21 February 2012 12:00 pm
The trail of a torpedo is tricky to do because it combines fluid dynamics, surface and volume rendering as well as fog and light scattering. The technique used in the above Maya scene is to have one fluid that renders both as a volume and a surface mesh. The overall underwater fog was done with a second non-dynamic fluid.
The first step was to create a 3d fluid with an emitter. The emitter was then modified to be a cylindrical volume that emits both density and speed( see "fluidEmitter1" in the scene). The speed emission simulates the thrust of the propeller using "Along Axis", while a little bit of "Around Axis" simulates the rotational effect. Turbulence on the emitter is also used with a relatively fast speed setting. Fluid dropoff is disabled so emission is uniform within the volume. Motion streak is enabled so that as the torpedo moves the emission does not strobe or form bands. The translation of the emitter was then animated ( the torpedo was parented to the emitter, but one could easily have done it the other way round). To better handle high speed thrust the substeps on the fluid node was increased. (although in this case it probably would be OK with lower substeps than were used)
Auto resize is enabled on the fluid to make things more efficient. All boundaries are set to "None" and the resize margin set to 2 to help keep boundaries from affecting the solve. High detail solve combined with density noise helps to provide detail in the flow without needing too high a fluid resolution. One then needs to do trial and error to determine good emission rate, density dissipation, density noise, and density buoyancy. I also added a little velocity noise.
In order to get specular highlights I created a mesh from the fluid using "Modify: Convert: Fluid To Polyons". This initially enables "intermediateObject" on the fluid shape node, which keeps it from rendering. However in this case the effect of the volume combined with the surface is desired so navigate to you fluid shape and turn off intermediate object to make it visible again. On the fluid you may wish to lower the mesh resolution to make things faster and keep the poly count low. Also the surface threshold on the fluid should be adjusted carefully for the best effect (which will depend on the transparency of your fluid). One needs to assign a shader with specular highlights that is totally or very transparent("blinn1" in this scene). On the fluid shape you should enable visible in reflections/refractions in the render options(this is on by default for most other nodes, but is off on fluids for render speed). In order to add detail a volumeNoise bump map was applied .I would avoid enabling refractions on the shader as it is hard to integrate this well with the volume fluid render.
On the fluid selfShadow was enabled and realLights was turned off( is simpler and a bit faster to render ), using the internal direction light. The direction was set to ( 0,1,0 ) to model the overhead lighting. Ambient brightness was set quite high. One needs to carefully adjust the transparency along with shadow opacity, light and ambient brightness and color.
For the underwater fog effect I used a second, non-dynamic fluid (i.e. one with everything in contents methods set to OFF). I tried to get some of the scattered light effect off of the bubbles by creating a large fluid for the fog parented to the main bubble emitter. (see fluidShape2, under fluid1:fluidEmitter1) If you want to see this fluid you can set "Shaded Display" to "As Render" on fluidShape2. The color ramp input is set to center gradient and the color at the very center is light blue quickly falling off to dark blue. The transparency of this fluid is slightly tinted blue which is important for the colors of objects in the fog( in addition to the color ramp value). Opacity input is simply set to constant, with the right hand opacity ramp indice lowered to a desired opacity. Again real lights is turned off, and with shadows off there is no shadowing of this fluid. One might try using a stationary fog fluid illuminated by a moving light that has fast decay instead of moving it with the torpedo as was done in this scene. You could use the built in point light on the fluid or perhaps a linked linear light. Note that because this fluid was so large I needed to increase the shading quality on it to properly capture the color gradient. Otherwise the transparent outmesh of the fluid used for specular highlights became visible. This is because the integration of volume spans through the fluid is different for a single span than two spans( a transparent surface splits a span) when the shading quality is not high enough to fully resolve the shading inside the fluid. As with the bubble fluid, enable "visible in refractions".
To further fake the scattering of light from the bubbles into the water I added a tiny amount of shader glow on the bubble fluid. In general always turn off auto-exposure on the shaderGlow node(in hypershade) then hand adjust the glow and halo intensity... usually you need to lower them a lot. This avoid flicker during animation. As well set the shaderGlow quality to a high value( like 20).
Finally I added the sub and collided it with the bubble fluid (select sub and fluid then do "fluid: make collide"). In order to create a little blast in the tube at launch I animated the density pressure up for the first few frames. I also animated higher substeps to allow fast motion.
I just rendered this sequence without first caching the fluid, but it is safer generally to cache first then render and usually important if you are rendering on a farm.
Something that might be nice to add might be a bit of depth of field, slightly blurring things in the distance. Motion blur would also help, but might not be needed if there was depth blurring.
One might also add some floating particles for debris or fine bubbles and perhaps use the fluid as a field on the particles, setting conserve near zero on the particle shape. Use cloud type particles for better render integration with the fluids. Note that in some cases to get good render integration of the particles with the fluids you may need to enable "Volume Samples Override" and set volume samples on the fluid shapes.
Perhaps using real lights and incorporating a directional light with raytraced shadows could also help: At launch it is noticable that the fluid is bright inside the launch tube, where it should be shadowed by the sub. If you need to use many lights it is a good idea to link lights to your fluid, as many lights will wash out the shading if they don't have raytraced shadows, or be slow to render if they do.
Please only report comments that are spam or abusive.