Export Maya fluid so that it can be imported into a three.js game - three.js

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:
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 )
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:
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.
Here is a screenshot of the fluid shading attributes.
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:
As polygons with 10 steps applied:
Here is attribute editor:
And here is the material applied through hypershader:
I repeated the 10 steps you gave me several times with the same results each time.

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:
Modify – Convert – Fluid 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.
Remember: if you've got animation in your scene you need to bake it before export using:
Edit – Keys – Bake 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.
STEP-BY-STEP INSTRUCTION:
Select a fluid container and apply Modify–Convert–FluidToPolygons. You'll see in Viewport a polygonal Object with Lambert1 shader.
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.
After that select PolyObject in Outliner and choose tab with its initialShadingGroup in AE.
Open Windows–RenderingEditors–Hypershade, select FluidTexture and assign it using MMB-drag-and-drop to Surface Material Slot in initialShadingGroup of PolyObject in AE.
Create Spot Light in the scene. Run test Render. You'll see a lit Poly.
To change Transparency, Opacity or Incandescence just select PolyObject in Outliner and in AE go to fluidShape tab and choose Shading area.
Bake a Light (and Shadows if needed) using Arnold Renderer properties in Maya 2017 or Mental Ray properties in Maya 2016 and earlier.
To output a Poly Mesh from Maya you need to select mesh and apply a command Edit–Keys–BakeSimulation.
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)
Export OBJ sequence.

Related

How to fix image texture not transfering to Unity from Blender

I textured an object in Blender because it wouldn't texture properly in Unity, and then imported the object and texture to Unity.
I don't know how to fix this, I'll put both pictures here.
Blender Texture Before Import
Object In Unity
Okay, so based on your screenshots..
You're going to select everything then add a modifier called "Solidify", then set this to something very small like .03. (Unity doesn't like objects that are just planes).
double check all your normals are facing out. Let me know if you don't know how to do this...
Go into edit mode select all edges, then right click, select "mark as seam".
Open UV editor window (should be split screen with Edit mode on one side, UV view on the other). In the Edit side select all, then go to UV dropdown menu and click "unwrap". You should then see your object unfolded into flat planes over on the UV window side. There's different unwrap options, like smart UV unwrap, etc. I think just "unwrap" has worked for me, but play around and there may be something that shows your object shapes in a less distorted way..
At this point, since your pattern is basically repeating. If you export the OBJ file and take it into unity, and you add the image file (make sure it's dimensions are perfectly square) it should receive the image file as an Albedo texture much better than in your screenshots. You can play with the 'tiling' and "X/Y offset" till it looks right (you might face issues with rotation though.
BUT
If you want to line it up very specifically, you can export the UV layout as a png from the UV window in blender. Then use photoshop or another photo editor to change/rotate and arrange your texture so the sides line up properly. In blender in the Edit window (assuming you still have both UV + editor open) when you select a side it will highlight in the UV window the corresponding flat plane, based on this you should be able to figure out what should be rotated up/down, etc. Then when you change that 2d image and drag it into Unity, it will adjust and wrap around the object.
I'm pretty new to both, but the advice I've been given is to not do the texturing in blender, but instead to do it in Unity.
This is a 10-month-old post but incase anyone is curious or struggling the same, Blender exports models with a scale of 100 so you need to scale up the tile of the material (in material settings) to see it.
This is a bad solution however because then you are not working with objects on a scale of 1 so you actually want to check "Apply transformations" when exporting the FBX model in blender

Why do two faces appear invisible in ThreeJs?

I've an object in Blender. Because I want to do some UV-unwrapping using ThreeJS (see here) I determined that I need merge two of the sides to correctly unwrap.
So before exporting the .blend as a .obj object I selected the Tris to Quads face option to create a square face for the two sides as opposed to it being made up of two triangles. Here's what it looked like in Blender:
But when I import the .obj and .mtl file into ThreeJs I get this:
Is this a problem to do with me not updating the material being added to the new object?
The handles appearing white makes me think this is the case. If so how can I go about fixing it?
When I see something like this, the first thing I usually do is to set the material to side: THREE.DoubleSide. If that helps, the problem has to do with the normal-directions (so the face is actually there but isn't rendered because it is facing away from you).
To fix this, you should try the following:
In blender you can enable displaying of normal-directions in the right-hand menu (select "Face normals in section "Mesh Display").
You should now see if any of the normals are pointing inwards/in the wrong direction.
There is an automatic fix that works well for properly constructed meshes:
select object and switch into edit-mode (<Tab>)
select all vertices (shortcut &ltA>)
via menu "Mesh" > "Normals" > "Recalculate Outside" (shortcut <Ctrl>+<N>).

How do I animate attributes and export it as a fbx-file?

I have made a pipe in Maya, on which I have animated the thickness (Below is an example of 4 of the keyframes in the animation). Unfortunately when I export it as an fbx file, the animation of the of the thickness is not saved. Is there a way to save an animation that would be something similar to this one or some help on getting this solution to work?
I'm fairly new to Maya so there might be something I'm missing. Hope you can help me.
Default FBX won't export the changes in the geometry - it will give you the position, rotation and scale of the object over time but not changes to vertex positions within the object.
You can turn on the 'Geometry Cache' option in the fbx export dialog:
Vertex Animation stored in FBX file without using Point Cache?
However not all applications that use FBX support geometry caches - you'll have to see what your target software supports. Other options might be to export a series of .OBJ files (1 per frame) and use the vertex data from those, or to use an animated geometry specific format like Alembic

Export Fbx from Blender To Unity

I have a complete blender file which has an animated character with two actions and I want to export it as an fbx so i can view it in unity. I did it and for some reason it is only exporting my actions and not the mesh or camera or anything else only exports the actions. Why is it not exporting my mesh I have everything selected and i have apply modifiers and include animation selected. Thanks for the help
Sounds like you are exporting in Blender with Selected Objects options set. In this case you have to select the mesh itself in object mode to export both. Selecting the armature will export animations only.
If you do have a mesh in Unity3D but can't see it in the scene, you have to fix the scale factor. It's set to 0.01 by default. So change it to 1 to see the mesh in its original size.

Maya Mel Scripted Animation Not Animating as FBX

I've acquired a great quad model. I skinned and animated it to a rig build by a
Mel script. It works great as far as editing the animation using sliders and parameters
in Maya. When I export the file as an FBX file to Unity3D, it does not animate. Is something
being lost in the translation from Mel to the rig? Unity needs a boned rig, is this procedural rig not the equivalent of a rig built and animated with the skeleton tools in Maya? I've check that I have a 'Reference' folder, I've set keys, changed root name to "Hips".
Thanks for any insight on this question.
dDuane
If you are transferring the file with no errors and there is no animation then there are three issues to look at.
First, you may have accidentally not exported the keyframes. Make sure the box is checked to export animation on the FBX export UI.
Second, it's possible that the object that contains the actual keyframes is not being exported. When you animate using the MEL scripted GUI, find out where the actual keyframes are on the rig and make sure that object is exporting with the rest of the character.
Third, the object might be transferring fine but depending on the rig setup the connections/constraints/whatever might not be working or supported in Unity. You might consider baking the animation to the skeleton before transferring to the engine. To do this, select the skeleton, click [Edit -> Keys -> Bake Simulation].
I don't know what Maya you are using, but I've always used 2010. This is the workflow that we used for a small unity 3D game project:
Export all of the
animations in one scene as a .fbx. Be sure you just select the geometry (it
usually helps to have it all grouped, but if you can't for some reason that's
okay) and hit export selected.
These FBX export options should be checked:
Geometry:
Edge smoothing,
Tangents and Bi-normals
Animation:
Animation,
Bake Animations,
Bake Animations,
(range of animation),
step = 1
Deformed Models:
Deformed Models,
Skins,
Blend Shapes (if using these),
Curve Filters,
Resample as Euler Interpolation,
Input Connections,
Instances to Objects,
Referenced Containers Content (if using any references),
FBX File Format
Binary
FBX200900
When you bring this into Unity, set animation generation
to "store in root." If all of your
animation is in this one file (which it should be). The "split
animations" box should be checked and define the names and range of these in the
chart below. When you eventually create an animation blending script, drag
and drop it on the animation object within the player prefab, not the prefab
itself.

Resources