TrueGrit – Dirt simulation

(A Bytegeist Software Tool)

 


Release Notes:


Installation


Just stick truegrit.dlu in your Max plugins folder.

NB [3dsmax4/5 only]: If TrueGrit doesn't appear in the utility plugin list in Max, then you might need to put this DLL in your windows system folder (eg c:\winnt\system32)


Introduction

TrueGrit is a dirt simulation plugin that stores its results in a normal bitmap that can be mapped onto your object using its existing mapping coordinates. This approach to dirt generation has some unique advantages and disadvantages:

Advantages:

Disadvantages (TrueGrit is free – so I can own up to these :) ):


As of version 0.2b, TrueGrit can use the vertex color channel of your object to store grit information instead of using a bitmap. This approach has a different set of advantages & disadvantages. On the plus side You don't need to set up mapping coordinates for your object in order for the grit generation to work, but you do require sufficient face density to give detailed results. In addition, the object must be a collapsed editable mesh.


Mapping an Object for TrueGrit

(or, How I Stopped Worrying and Learned To Love UnwrapUVW)

(NB: This section only applies to the UV algorithm. If you are using the Vertex Color algorithm you do not need to map your object)

In order for TrueGrit to generate grit correctly for an object.

  1. The object must have mapping coordinates.
  2. The UV values of all mapping coordinates must be in the range 0 – 1
  3. The mapping coordinates of faces that share the same material ID must not overlap.

Why not overlap? Well, suppose face A and face B had the same mapping coordinates but were in very different places in the mesh. They would very likely have different amounts of grit on them. So when TrueGrit came to save the grit for the two faces into a bitmap it would have a problem since both faces were using the same part of the map. One face’s grit mapping would have to overwrite the other.

There are two main approaches to avoiding mapping overlap.

  1. Map the object in such a way that no overlap occurs. The Unwrap UVW modifier can be very helpful in moving mapping coordinates about. If you haven’t used it before, do the tutorial on mapping a low-poly space fighter in the Max 3 Tutorial Manual.
  2. Separate overlapping faces by giving them different material IDs. You can then generate a different grit map for each material ID and use a multi-subobject material to display them all.

Generating the Grit

TrueGrit is a utility plugin. You’ll find it in the utility panel in Max. There are a number of controls that control the how the grit is generated:

Algorithm: TrueGrit currently supports two methods of grit generation:

Map Size: This is where you enter the x and y dimensions (in pixels) of the grit map you want to generate. Larger bitmaps will require more calculation time. This parameter applies only to the UV Algorithm.

Distance: This setting controls how close nearby faces need to be before they start causing grit to accumulate on the surface of a face. TrueGrit works by assuming that grit forms in corners, indentations, nooks and crannies of a mesh. The greater the distance value, the more grit you’re going to get. A good way to think about this value is to imagine the inside of a box. The inside edges and corners of this box are going to accumulate grit (because they are harder to clean etc.). Think how far out from the corner you would like that grit to extend and that’s your distance value. Changing the distance value won’t affect the calculation speed in this version of TrueGrit but may well do in future versions (with smaller distances leading to shorter calculation times).

Ray Spread: In order to calculate the grit at a point on a face, TrueGrit fires a number of rays out from that point in a hemispherical pattern and sees if they hit any other faces within the distance value specified. The Ray Spread settings control how many rays are fired. The number of rays fired equals (1 + Vertical * Horizontal). Increasing these values has a significant effect on rendering time. It seems that the point of diminishing returns is reached fairly early (about 16 rays or so), and increasing the number above this doesn’t make things look much better. Start small (with Vertical = 1 and Horizontal = 8) and increase the values by small amounts if you see banding or square looking regions of grit.

Map Channel: This value controls which of Max’s 100 mapping channels TrueGrit will use when calculating the grit map. Most of the time this value will be 1. This parameter applies only to the UV Algorithm.

Selected Faces Only: Check this box if you want TrueGrit to only calculate grit for the currently selected set of faces in the mesh. For large meshes it can speed things up to only calculate grit for a small part of the mesh until you are satisfied with the settings, and only then calculate the grit for the whole mesh.

Noise: TrueGrit can optionally add a noise effect to the calculated grit map. This parameter applies only to the UV Algorithm.

Filter By Material ID: You can use these settings to have TrueGrit only calculate grit for those faces with a particular material ID. This parameter applies only to the UV Algorithm.

Accumulate Vertex Colors: This option only affects vertex color grit. If the box is checked, TrueGrit will blend the calculated grit values with existing vertex colors instead of overwriting them (by performing a color multiply).

Generate: Pressing this button begins the grit generation progress. TrueGrit will display a progress bar at the bottom of the screen. The important bits of the calculation are multithreaded, and should run nearly twice as fast on a dual CPU machine (if anyone has a Quad CPU machine and would like TrueGrit extended to use up to 4 CPUs, send me an email). If you are using the UV algorithm, when the calculation has finished TrueGrit will prompt you for a name and format to save the grit map to. If you are using the Vertex Colors algorithm, TrueGrit automatically updates the vertex colors in your object for you (though you may need to click on the object to get Max to refresh its display properly).


Using the Grit Map

So now you’ve got this map. How to use it? Here are a couple of ideas – I’m sure you’ll think of others.

Using the Vertex Colors

Here's what I usually do:


That gives you a basic noisy blend between the non-grit and grit materials based on the vertex color channel of the object. You will probably need to fiddle with the settings of the various materials to get exactly the result you desire.


Final Points


byte·geist (bīťgīsť)    noun [byte unit of computer information + geist spirit]

[techspeak] The spirit or genius that marks the technology for the next generation.
Historical note: The word was coined by mutating the word 'zeitgeist' meaning the spirit or genius of the time; the general intellectual and moral state or temper characteristic of any period of time.


What does Bytegeist do?

Bytegeist Software Pty Ltd is primarily a service company for specialist game and graphics software creation.

Bytegeist provides a premium solution for your software development needs, delivering software on time and on budget.

Bytegeist covers a wide range of specialist programming areas, including strong expertise in the development of games, graphics, 3D engines and optimizations, 3D plugins & exporters, creation tools, ActiveX technology, Middleware implementation, GUI's, level/map/game editors, advanced compression technologies, web based streaming solutions, localization, Game Boy Advanced, and various file format solutions.

Bytegeist understands product lifecycles and team dynamics, as consultants and project managers we develop procedures to help increase overall productivity and efficiencies.

Finally Bytegeist can provide content creation services such as modeling and animation.

See http://www.bytegeistsoftware.com for more info