09.07.2015 Views

RealFlow Maya Plug‐in

RealFlow Maya Plug‐in

RealFlow Maya Plug‐in

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>RealFlow</strong> Particles in <strong>Maya</strong>This section covers the part of the plug‐in which handles sequences of particle BIN files.BIN ImportPressing the “Import BIN sequence” button in the toolbar will ask the user to select a BIN file. After thisis done, the plug‐in will try to auto‐detect the name format and frame padding used for the given filename and will display a dialog box which allows setting the options for the emitter which will be created.Figure 7: Particle import options.You can adjust the name format or padding here if the initial guess made by the code is not correct. Theplug‐in will extract the file prefix based on the format and padding selection. Note that if you choose aninvalid format or padding (i.e. the file name cannot be reconstructed using your settings) the dialog willdisplay an error message in the “Prefix” field, as in the example below:Figure 8: The file name cannot be reconstructed using the name_#.ext format because it uses a dot, not an underscore.


Figure 9: New emitter AE interface.Changed attributesThe options for suppressing certain channels from the BIN files (e.g. mass, normals, viscosity etc.) havebeen removed because they didn’t provide any performance gains. Everything is loaded now and sent tothe particle shape.


The “load sequence”, “use range” and “clip to range” attributes have been changed from integer arraysto boolean arrays.The “rfPosition” and “rfVelocity” output channels have been removed because they have native <strong>Maya</strong>equivalents (the “position” and “velocity” attributes on the particle shape node).Performance and stability improvementsThe particle loader is two times faster than the old plug‐in, resulting in better interactivity when workingwith large numbers of particles.The code is around 5 times shorter so it’s easier to maintain. It makes no explicit dynamic memoryallocations, resulting in better stability in low memory situations.Backwards compatibilityExisting scenes should work without changes with the new plug‐in. Make sure that the realflow.mll pluginis loaded before opening a scene with emitters created by the old plug‐in (the best way to do this is toset realflow.mll to auto‐load in the plug‐in manager). Also make sure that you remove theRealflowParticler.mll file from the <strong>Maya</strong> plug‐ins directory, otherwise <strong>Maya</strong> will try to load it when youopen the existing scene.<strong>Maya</strong> will show a warning dialog when you load an existing scene with this plug‐in. It is safe to ignorethis warning. If you simply close the dialog box and re‐save the scene the nodes will be converted to theformat used in the new plug‐in and you won’t receive any more warnings the next time you open thefile.Figure 10: Warning dialog when loading old scenes.Sometimes when loading old scenes the new plug‐in fails to remove the existing particles beforeemitting new ones for the current frame. To fix this just change the current time so that the existingparticles are cleared and a fresh set is created and then save the scene. You only need to do this onceafter you open an old scene.


BIN ExportAny <strong>Maya</strong> particle system can be exported as a sequence of BIN files and loaded in <strong>RealFlow</strong>. As with theSD exporter, the BIN export options can be made persistent so that subsequent exports can beperformed with a single button click.Figure 11: BIN particle export options.You can add several <strong>Maya</strong> emitters to the “Particle Nodes” list and they will all be exported as a singleemitter to <strong>RealFlow</strong>.MEL SupportYou can export particles as a BIN sequence using the following syntax:realflow –exportBIN –useSettingsNodeOr, to specify options manually:realflow –exportBIN –path export_directory –prefix file_prefix –node emitter_node_name


The -node flag can appear several times if you wish to include more than one <strong>Maya</strong> emitter.The following flags can be used to specify extra options:• -nameFormat N, where N is 0 for “name.#.bin”, 1 for “name#.bin”, 2 for “name.bin.#”, 3for “name_#.bin”. The default is “name#.bin”.• -padding N, where N is the number of digits used for the frame number. The default is 5.• -particleType N, where N is 0 for gas, 1 for liquid, 2 for dumb, 3 for elastics, 4 forcustom. The default is “dumb”.• -startFrame specifies the first frame to export. The default is 1.• -endFrame specifies the last frame to export. The default is 24.• -usePlaybackRange is used to export the currently active playback range. If you use thisflag, -startFrame and -endFrame are ignored.• -frameOffset can be used to offset the exported sequence relative to the <strong>Maya</strong> time. Forexample specifying an offset of ‐10 will cause frame 11 in <strong>Maya</strong> to be exported as file0001.bin.Progress reportingThe main <strong>Maya</strong> progress bar is used to display the status of the BIN export operation. The export can becanceled at any time by pressing the ESC key.Figure 12: Progress bar for BIN particle export.


If you wish to lengthen the motion blur, the <strong>RealFlow</strong> mesh node has a “Motion Blur Multiplier”attribute. Use this instead of increasing the shutter angle or speed to prevent the problems caused byvarying mesh topology.RealflowMesh node attributesThe Attribute Editor interface for the RealflowMesh node has been rewritten.Figure 14: RealflowMesh Attribute Editor.The new interface shows controls for the file name format, a new way of managing clip/cull cubes, andcheckboxes which determine how fluid weights are exposed to <strong>Maya</strong> and mental ray®. Note that the old


BIN mesh node had two LOD parameters, one for view and one for render. The render LOD factor hasbeen removed since it only worked with the <strong>Maya</strong> Software renderer.PerformanceThe new BIN mesh node is roughly 50% faster than the old plug‐in.


Clip & cull cubesSpecially designated cubes can be used to clip a <strong>RealFlow</strong> mesh. Clip cubes remove the triangles whichare inside them, while cull cubes remove all the faces which are outside their volume.Figure 15: X‐Ray view of <strong>RealFlow</strong> mesh and clip cube. Left: the clip cube is off. Right: the clip cube is on and removes thefaces which fall inside it.Figure 16: X‐Ray view of <strong>RealFlow</strong> mesh and cull cube. Left: cull cube is off. Right: cull cube is on so it removes all the faceswhich are outside.Several improvements have been made to the clip/cull cubes: they now work when the <strong>RealFlow</strong> meshis transformed (rotated/translated/scaled), they can be rotated and they are managed from the<strong>RealFlow</strong> mesh Attribute Editor instead of relying on a naming convention.


To use the clip/cull lists in the AE, follow these steps:• Select the <strong>RealFlow</strong> mesh and display its Attribute Editor.• In the “List” menu of the AE window uncheck “Auto Load Selected Attributes”.• Select the cube that you wish to use.• Click “Add Selected” under the clip or cull cube list.Figure 17: "Auto Load Selected" must be off so that selecting the desired cube does not change the Attribute Editor.Visualizing fluid weightsIf a <strong>RealFlow</strong> mesh is computed from several fluids, the per‐vertex weight of each fluid can be visualizedin the <strong>Maya</strong> viewport using the Blind Data Editor. First, make sure “Fluid Weights as Blind Data” ischecked in the mesh AE. Then add the tag for the <strong>RealFlow</strong> weight data (123321) in the Blind DataEditor, set the mapping mode to “continuous”, assign colors for each fluid and click “Set Color”. Pleasenote that because of the varying topology of the <strong>RealFlow</strong> mesh, the colors will only be valid for theframe when the coloring was applied. To inspect another frame click “Remove Color”, set the time tothe new frame and click “Set Color” again.


Figure 18: Sample usage of the Blind Data Editor to visualize the weights for the fluids which interact to produce this mesh.The mental ray® melt shaderWe have added a mental ray® shader which can be used to combine several materials based on the fluidweights contained in a <strong>RealFlow</strong> mesh file. The shader is called “realflowMeltShaderMr” and it can befound in the “Materials” section of Hypershade when “Create mental ray Nodes” is selected, or in the“Assign New Material” menu which appears when right clicking on a mesh in the viewport.To use the shader, create as many input slots as there are fluids on the mesh and connect a material foreach fluid. The following image shows an example shading network for a mesh with two fluids:Figure 19: Sample shading network for two fluids.The Attribute Editor for the melt shader will show one rollup for each of the connected materials. Youcan use the AE to connect and disconnect inputs and to control the number of materials. The trashcanbutton can be used to remove a fluid material.


Figure 20: Melt shader Attribute Editor.The “melt index” attribute gives the user some control over the appearance of the parts of the meshwhere several fluids meet. A value of 0 will blend the material colors using the fluid weights exactly asthey are stored in the BIN file. Increasing the value towards 1 will exaggerate the weights, brighteningthe blend. Negative values will scale down the weights, so the result will be darker.Notes:• You need to connect shading group nodes as inputs, not material nodes directly. If you use theAttribute Editor to manage the connections and assign a material node as input (e.g. by dragginga Phong node from Hypershade to one of the material fields, or by using the checker button tocreate a new material), the plug‐in will automatically redirect the connection to the material’sshading group. However, if you set up the shading network manually in Hypershade, make sureyou use the “message” attribute of the shading group, not the material itself.• The melt shader will only function on BIN meshes because it requires per‐vertex fluid weights.• The “Export Fluid Weights For mental ray” attribute must be enabled on the BIN mesh.• The shader is not available in <strong>Maya</strong> 7.• The shader will not function if you disable the “export custom data” function of the mental raytranslator. This setting can be found in the mental ray render options under Translation ‐>Customization. The option is enabled by default.Advanced: using the fluid weights from other mental ray® shadersIf “Export Fluid Weights for mental ray” is enabled, the weights can be accessed from any mental rayshader. <strong>Maya</strong> exports them as extra texture spaces for the shape, so they are available in thetex_list array of the state structure.


To determine the indices which need to be used to access the weights, shader writers must search for amaya_vertexdata object in the mesh data (magic number 1298749048) and look for entries named“RfWeightsX”, where X is a number from 0 to the number of fluids minus one. The entries will containthe offsets which need to be applied to the tex_list array for each fluid. The weights have onecomponent, so they will be available in the x member of the tex_list entries.Advanced: obtaining fluid weights from 3 rd party plug­ins and renderersThere are two methods for reaching the fluid weights from a 3 rd party <strong>Maya</strong> plug‐in:• They are available as per‐vertex blind data on the mesh object. Use thepolyQueryBlindData MEL command or the MFnMesh::getDoubleBlindData() APIfunction to access them. For this to work, “Fluid Weights As Blind Data” must be checked in theAE of the mesh object.• When “Export Fluid Weights For mental ray” is enabled, the weights are attached to the objectas custom attributes of type “doubleArray”. One attribute is created for each fluid. Theattributes are called “miCustomTexRfWeightsX”, where “X” is the fluid number. The weights arestored per‐vertex, so the number of elements in each array equals the number of vertices of themesh.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!