Posts tagged maxscript

Exporting to FBX from MAX (Morpher Issues)

I’ve been looking into porting assets to Maya, MotionBuilder, Softimage via FBX. One problematic area I ran into early on was that of the ‘Morpher’ modifier…

To maintain quads, be sure to do the following:

  1. All mesh objects should be of class ‘Editable_Poly’
  2. In the exporter options, “Preserve Triangle Orientation” should not be checked.

Morpher compatibility…

  1. It seems that only the top most MORPHER modifier is exported with FBX. The others are ignored.Furthermore,it seems that morpher modifiers are limited to 100 channels. While you can set channels above this in mxs, the results are not as intended and I’ve only seen one channel above 100 work and it seems to be any index over 100.
  2. All morph targets need to exist in the scene as objects and targeted via the MORPHER ui. Failing to do this will result in the channel names being truncated to the first letter of their name. IE “Jaw_open” and “Jaw_back” both become “J” and “J” respectively. A script below helps address this by extracting and re-targeting morph target objects embedded in the MORPHER modifier.

More >

Performance Opt. for 3ds Max 2012 – Disable Hidden Skin & Morpher

It seems the 3ds Max 2012 is still processing Skin and Morpher modifiers when their geometry objects are hidden.  So, this quick snippet just toggles the modifiers onoff across the entire scene based on their objects’ visibility.

mapped fn toggleSkinMorph_basedOnVis obj = (
   modA = obj.modifiers
   for m in modA do (
      if classof m == Skin or classOf m == Morpher then (
         m.enabled = not obj.isHidden
      )
   )
)

toggleSkinMorph_basedOnVis $geometry

MXS Transform Test

Objects in 3ds Max will typically need to have “clean” transforms.  It is quite easy to invalidate them via non-uniform scales or mirroring. I wrote a simple script to identify objects submitted to us by our vendor that are in need of correction.

The script checked for offset pivots, mirrored  objects, and non-uniformly scaled objects.

Here is an example of the feedback dialog that the user would be presented with.

SR3 MXS Convert Pattern Maps

We discovered, after the majority of assets were authored, that we needed to convert our PC pattern maps to the technique we were using with NPC’s.  Pattern maps were used to customize the characters by replacing the pure RED, GREEN, or BLUE with a new color via the shader at runtime.

Rather than stick someone with the tedious task of reworking all of these bitmaps by hand, I created a maxscript that handled the heavy lifting.  Details below:

You need to install or upgrade Flash Player to view this content, install or upgrade by clicking here.

Here is an overview of how the script works.  It has  THREE main operations:

  1. Convert PC pattern maps to NPC pattern maps, as follows:
    1. Renders existing pattern maps (UV3) out to UV1…
    2. Converts the color setup from PC to NPC…
    3. Combines the Pattern & Diffuse…
  2. Renders out Decals on UV1.
  3. Ports shaders from PC to NPC materials.

SR3 MXS Toggle Character Bitmap Size

This was a quick script that I threw together to help with outsourcing.  I needed to be able to quickly check for an evaluate the delivered high resolution and low resolution bitmaps authored for the character assets.

To toggle between the large and small maps, the script looks at the materials and finds the bitmaps in use. Then it looks on disk for it’s counterpart and swaps the entry in the material.  Simple stuff, but it makes the workflow of selecting a character and running the script much faster than doing it by hand.  The only requirements are that the filenames use the naming conventions already established, that is “_SM” for small and “_LG” need to appear somewhere in the filenames.

By default, the script runs on all selected objects toggling the maps highlighted in the scripts gui.  You can <CTRL> or <SHIFT> click to add or remove maps from the selection.  If a new map type needs to be added, it can easily be done in the script.

SR3 DX9 Shader to Simple Shader

This post shows a simple script & shader that I wrote to workaround an issue and better visualize the results an artist would see with their asset further down the pipeline in game.  This was by no means an ideal solution and was only a bandaid.

You need to install or upgrade Flash Player to view this content, install or upgrade by clicking here.

NOTE: The intended audience of the video was a group of outsourced artists.

The issue:

Our game materials are authored in a proprietary editor that generates multiple shaders for different targets, such as different hardware consoles or optimizations.  One such target is a DX9 shader that is viewable in 3ds Max.  Unfortunately, Max handles normal maps inversely from how our game renderer handles it and the tool did not account for this in the hlsl that it generated.  This meant that it was difficult for the artist to identify and correct normal map seams early in the process (prior to exporting and viewing in game, which many outsourcers did not have the ability to do).

This was a known, long standing problem and existed on the work backlog for one of our employees to address.  Unfortunately it was lower priority than other work yet was still deemed to be something that would get resolved properly and ‘soon’ by the individual. Rather than step on his toes and avoid jumping into, admittedly unfamiliar, c++ territory for the proprietary editor I implemented a quick solution…

The solution:

  • I authored a simple dx9 shader that would properly display our game’s normal map format in the 3ds Max viewport.  This shader was very stripped down to the basics…diffuse map, normal map, and ambient color.
  • I authored a simple maxscript gui to …
    • control toggling between the game shader and this simple diagnostic shader (non destructively using scene states)
    • toggle map and parameters on\off quickly

vMesh Projector

3dsmax maxscript that I threw together that aids in retopologizing hi-poly meshes down to lo-poly.

“vMeshProjector” is a maxscript that projects one mesh onto another. It is primarily envisioned as a tool to aide in building lo-poly meshes that conform to high poly counterparts, from which normal maps and other data may be pulled. It does however have other potential uses, particularly in the areas of kit bashing.

It was a fun project and I learned a lot.

Here are some additional samples of the tool in action:


Dog Gun Seat Skull

vAnimBarGUI

You need to install or upgrade Flash Player to view this content, install or upgrade by clicking here.

This was a experiment in creating a graphic widget via maxscript for some general purpose trackview type manipulation of data.  I learned a great deal such as the use of back buffers and updating regions to speedup the drawing of a bitmap to the screen.  Additionally, I learned about mouse tracking and parsing a bitmap font sheet for letter forms to create words in the bitmap.   MXS is not fast at drawing bitmaps, but I think this actually managed to hit an acceptable level of performance.

This was initially designed to fill a whole in loss functionality in 3dsmax’s trackview which we want to have custom blocks of labeled keys to control lip synch data.  We ended up modifying our lip-synch method and never actually put it to use.

vCombo_UVW’s

You need to install or upgrade Flash Player to view this content, install or upgrade by clicking here.

This maxscript I made to initially assist the vehicle artists added the missing functionality of being able unwrap multiple objects simultaneously.  This is incredibly useful when working with multiple objects that share the same texture sheet.  Modifications subsequent to this video include support of multiple map channels, epoly support, and support to maintain morpher modifiers.

Note: Autodesk added this in subsequent versionsof 3dsmax, starting in r9 IIRC.

Object Renamer

You need to install or upgrade Flash Player to view this content, install or upgrade by clicking here.

This video demonstrates a rather simple but useful enhancement to the object renaming tool that ships with 3dsmax.  Nothing complex here, just string operations and a decent preview of the result prior to committing.

vProp Shop 3

vPropShop3 is a light-weight asset management system that facilitated creating a sharable library of assets that could be browsed, shared, and leveraged by production artists at Volition.

Key Features included:

• TreeView and browser with list, detail, and thumbnail views
• Placement tools for dropping objects into 3dsmax
• Easy method for adding props to the library
• Ability to edit entries in the library, locking them from multiple edits
• Multi-user support
• Light-weight approval and commenting system

Initially, this script started out as a small dialog with a text list of objects in it that could be selected an merged into the 3dsmax session, by Adam Pletcher.  I saw a benefit for adding preview support for v2, and then v3 added a new gui browser (somewhat inspired by XSI’s style). Up through v3, the script simply used the Windows file system.

The script became heavily used by the Environment Artists at Volition.  For Saints Row 2 another employee Andy Tidball, picked up the script and reworked it to be integrated with Perforce.

Enable Renderable Vertex Colors

Vertex colors do not render in the scanline or mental ray renderer by default in 3dsmax.  Nor is there a switch to enable them.  So, I built a script that tweaked the selected object or scene’s materials to allow this.

Interface Shot:

Material Change:

Results:

The screenshot above has a Advanced Lighting Radiosity pass baked down into vertex colors that were tweaked using the Vertex Color Tools Suite script to augment hue, control blending, and fix problem areas.

The render maintained the vertex colors, allowed over-brightening, and added cast shadows.

vConvex Hull Maker

Here are some screens from a convex hull maker script that I made as we began to integrate physics engines into our games and hence had the need for convex shells for collision calculations.

It was an interesting script to right.  I treat the source meshes as a point cloud.  I then start at any three points, build a face, and then randomly jump through all of the remaining points looking to the center to see if it can see any triangles.  It is sees one, it is concave and is deleted.  Then new faces are built.  Process is repeated until all the points have been run through.

Description:

  • This script builds convex hulls based on selected geometry.
  • Definition of a convex mesh: ”An object is defined as convex if, given any two points inside the object, you can always go in a straight line from one to the other without going out of the object.”

Usage:

  • Workflow:
  1. Select the object(s) that you want to build a convex hull around.
  2. Verify that the scope option in the script’s ui is set appropriately.
  3. Press the “Build Hull” button to create the new hull object(s).
  4. Select the new hull(s) and name them properly. (They will all be named “ObjectXX”)
  • Options:
    • Scope:
      • “Selection as single object”
      • “Individual Objects”
      • “Update Viewports”
        • This is a frivolous option that will allow you to watch the hull being built in the viewport.
        • Note this option drastically slows down the hull creation process.

Advanced Lighting Settings Utility

Description:

3dsmax had one of the first available tools for calculating radiosity and it did this at the vertex level.  So, we decided to make use of this for generating vertex color based lighting for our levels. The problem that quickly arose is that we wanted different light setups within the same level max file, i.e. one for a daylight exterior, another for a darker interior, and so on.

This script facilitates this by storing multiple radiosity and exposure settings coupled with associated geometry and lights.  It allows for batch processing one or more of these settings and where possible blending the vertex colors at transition edges, such as the threshold of a door.

Screenshots of the script’s gui:

Usage demonstration:

Vertex Color Tools

vcTools is a compilation of several maxscripts that aide in manipulating vertex colors on single or multiple objects at a time in 3dsmax r5+.  I built this script suite as a reaction to missing functionality that we needed to set and manipulate vertex colors in 3dsmax for level art in Summoner.

There were several modules including:

• Assign Vertex Colors
• Adjust Vertex Colors
• Pits’n’Peaks
• Utilities
• Vertex Color Selection tools

Download the .chm file HERE for complete details.

NOTE: This script relied on several compiled extensions that do not ship with 3dsmax and therefore it is not compatible with current versions of 3dsmax.  It could be updated, but the reason to do so has become much less compelling since the inclusion of the Vertex Paint Modifier (which incidentally referenced this script numerous times in is beta spec.)

Here are a few sample images from the documentation: