2

Please forgive my ignorance in the area, but does anyone know how to go about exporting a maya fluid so that it is importable into three.js?

I'm new to Maya and I just made my first model to a game I'm making, see below:

enter image description here

The afterburner effect from the endgine are created with Maya fluids. I have no problem exporting the aircraft, and weapons, but I have no idea how to use the fluid in a three.js game. I've done hours of research trying to find any information on this topic without avail. Any references or assistance would be greatly appreciated!

EDIT: Here is an update to the steps I'm taking and the errors I'm receiving. Really hope this is meaningful and solvable. I can't find any good information online in relation to these errors.

Step 1: Modify > Convert > Fluid to Polygons ( all works as expected ) Step 2: Select created geometry > Edit > Keys > Bake Simulation, screenshot of options below. ( all works as expected )

enter image description here

Step 3: Select the generated geometry from the Fluid to Polygons step, select my fluidShape2 in the hypershader and perform Hypershade Edit > Convert to File Texture (Maya Software) ( does not work as expected, get an error )

Here is a screenshot of hypershader and polygons:

enter image description here

Here is the error Maya spits out :

// Error: file: /Applications/Autodesk/maya2017/Maya.app/Contents/scripts/others/copyConvertSolidTx.mel line 93: Cannot convert a texture connected to initialShadingGroup

To me it seems like the fluidShape2 node in the hypershader is not actually a shader and the created polygons are really assigned lambert1. I'm not really sure though considering I started using Maya last week.

EDIT #2:

Ok so here is a screenshot showing the fluidShape set as the surface material.

enter image description here

Here is a screenshot of the fluid shading attributes.

enter image description here

As you can see the color is black and the only illumination for this object is that which it produces. It is not lit from outside sources at all.

Cast / Receive shadows are unchecked in Render Stats as well.

Question: Is there any way to bake incandesces?

EDIT #3:

After following your 10 step program, I am having the same results I did previously. Here are screenshots to show before and after. A green plane has been added behind the flame to show it easier in it's second state.

As a fluid:

enter image description here

As polygons with 10 steps applied:

enter image description here

Here is attribute editor:

enter image description here

And here is the material applied through hypershader:

enter image description here

I repeated the 10 steps you gave me several times with the same results each time.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Kyle Richardson
  • 5,567
  • 3
  • 17
  • 40
  • I've added step-by-step instruction to my answer. – Andy Jazz Jun 29 '17 at 18:51
  • I don't know if it is Maya 2017 specific, but MMB dragging the fluidShape onto the surface shader of initialShadingGroup was not working. It does work if you assign a new Blinn material to the produced polygons and then link your fluidShape to the attributes of the Blinn material that you wish to affect. – Kyle Richardson Jun 30 '17 at 18:53
  • Try other method if the current one doesn't work. Maybe you need to assign a new shader to the mesh (Lambert2), or disable Arnold Renderer module. – Andy Jazz Jun 30 '17 at 18:58
  • Blinn shader has a specularity, Lambert doesn't. – Andy Jazz Jun 30 '17 at 19:01

1 Answers1

1

Before exporting you need to convert fluid to polygons.

Here's a MEL script for testing. Run it in Script Editor.

// opening nuke explosion example 
file -import -type "mayaAscii" -ignoreVersion -ra true -mergeNamespacesOnClash false -namespace "Nuke" -options "v=0;" -pr "/Applications/Autodesk/maya2016.5/Maya.app/Contents/Examples/FX/Fluid_Examples/Explosions/Nuke.ma" ;

// selecting fluid container
select -r Nuke:fluid ;

// converting fluid to polygons
fluidToPoly ;

// changing mesh resolution under shapeNode/outputMesh tab in Attribute Editor
setAttr "Nuke:fluidShape.meshResolution" 3 ; 

To convert fluids to polygons via menu, select fluid container and choose:

ModifyConvertFluid to Polygons

then select Shape node's tab in Attribute Editor and change Mesh Resolution in Output Mesh area.

Look at useful information on exporting: Three.js Maya Export

When conversion is done, default Maya shader (Lambert1) is assigned to new poly mesh. You have to reassign your fluid texture to new poly mesh. For this, open Hypershade and MMB-drag-and-drop fluid texture to Surface Material slot of poly mesh.

enter image description here enter image description here enter image description here

Remember: if you've got animation in your scene you need to bake it before export using:

EditKeysBake Simulation

bakeResults -simulation true -t "1:100" -sampleBy 1 -disableImplicitControl true -preserveOutsideKeys true -sparseAnimCurveBake false -removeBakedAttributeFromLayer false -removeBakedAnimFromLayer false -bakeOnOverrideLayer false -minimizeRotation true -controlPoints false -shape true {"nurbsSphere1"} ;

You don't need any type of curve interpolation (linear or bezier), just baked key on every frame. You can export animation via FBX or ABC file formats. There's additional method to export animated mesh as OBJ sequence: Free OBJ Sequences Import/Export.

Also, If you have any problems with exporting the light, bake the light and its shadows in object's texture. The better way for you to export animation and textures on per vertex basis.

enter image description here

STEP-BY-STEP INSTRUCTION:

  1. Select a fluid container and apply Modify–Convert–FluidToPolygons. You'll see in Viewport a polygonal Object with Lambert1 shader.

  2. Select FluidObject in Outliner, then in AE (Attribute Editor) change Mesh Resolution and Mesh Smoothing Iterations (for example 0.5 and 2 respectively) in fluidShape–Output Mesh area.

  3. After that select PolyObject in Outliner and choose tab with its initialShadingGroup in AE.

  4. Open Windows–RenderingEditors–Hypershade, select FluidTexture and assign it using MMB-drag-and-drop to Surface Material Slot in initialShadingGroup of PolyObject in AE.

  5. Create Spot Light in the scene. Run test Render. You'll see a lit Poly.

  6. To change Transparency, Opacity or Incandescence just select PolyObject in Outliner and in AE go to fluidShape tab and choose Shading area.

  7. Bake a Light (and Shadows if needed) using Arnold Renderer properties in Maya 2017 or Mental Ray properties in Maya 2016 and earlier.

  8. To output a Poly Mesh from Maya you need to select mesh and apply a command Edit–Keys–BakeSimulation.

  9. To export a sequence of textures for every frame you need to select a FluidTexture in Hypershade and apply to it Edit–RenderTextureRange (you have to assign a frame range for exported texture sequence, for example 1-200, as well as file format, for example TIFF)

  10. Export OBJ sequence.

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • thank you very much for the detailed response! I will follow your advice and come mark answer as accepted once implemented. Though it already feels right :) Thank you again! – Kyle Richardson Jun 28 '17 at 14:56
  • Ok so when I convert fluid to polygons it connects an "InitialShadingGroup" to the created polygon. When I try to bake in the lighting after Edit > Keys > Bake Simulation, I get this error: `Cannot convert a texture connected to initialShadingGroup`. I cannot find any information on this error. Is this something you've encountered? – Kyle Richardson Jun 28 '17 at 15:37
  • Nope. I meant another problem: three.js don't recognise the imported lights. – Andy Jazz Jun 28 '17 at 19:56
  • Oh, this fluid does not receive lights, it is self illuminated through Incandescence channel, which is mapped to Temperature. Opacity channel is controlled by density. The color is black, and the in the Lighting section I have Real Lights unchecked. – Kyle Richardson Jun 28 '17 at 20:17
  • The color isn't black. Have you seen my picture? I assigned fluid texture to poly model. – Andy Jazz Jun 28 '17 at 21:07
  • Thank you Andy. I will review your material once again :) I'll get back to you on my results, though this looks like it hits the nail! – Kyle Richardson Jun 28 '17 at 23:16
  • So I will mark your answer as correct if you would like, but I'm still having issues unfortunately. The color of my fluid is black btw, I will post a screenshot. It does not receive lighting and is self illuminated. Can't get the object to render non-black once converted to polygons. Going to add an edit. Let me know if you'd like me to just mark your answer correct, you've put a lot of effort in helping me. – Kyle Richardson Jun 29 '17 at 15:34
  • You sir are awesome. – Kyle Richardson Jun 29 '17 at 15:41
  • Oh btw, I'm using Maya 2017 if that makes much difference. – Kyle Richardson Jun 29 '17 at 15:42
  • I suppose 2017 is OK. – Andy Jazz Jun 29 '17 at 15:46
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/147962/discussion-between-andy-and-kyle-richardson). – Andy Jazz Jun 29 '17 at 16:22