Create an LOD system (Viewport Interactive) in 3ds max

If you ever wonder how to create an LOD system that updates in real-time then this tutorial is for you. You may familiar with the Render time LOD system but this time, we will create a viewport interactive lod system with the help of Flight Studio Utility thanks to the Autodesk Master Louis.
In this tutorial, you will be learning how to set up lod nodes in Flight Studio and complete the system with the help of some simple lines of Maxscript code. Here is the little demo of what we are going to create.

Let’s get started.


Step1

scene-setup

Here, I have three versions of the human skull geometry in the scene and I named them according to their detail levels as High_res, Mid_res and Low_res.


Step2

aligning-the-geometries

Select and align all the skull geometries at the top of each other with the help of Align tool (Alt+A).
Click here to learn more about Align Tool.


Step 3

flight-studio-utility

Now, go to Utilities panel and click on Flight Studio utility and click on Modify Hierarchy / Attributes to launch the Flight Studio Hierarchy dialog.

Note: You can also access the Flight Studio utility through Configure Button Sets dialog.


Step 4

creating-lod-nodes

In Flight Studio Hierarchy dialog, select LOD from the dropdown and create three lod nodes. Name them High, Mid and Low.


Step 5

creating-the-hierarchy

Drag and drop the skull geometries to their respective lod nodes to create a hierarchy.


Step 6

min-max-distance-values

Now, as we know that LOD system works according to the distance between the camera and the geometry, so, we have to provide the minimum and the maximum distance thresholds for each of the lod level.

On the Right side of the Flight Studio Hierarchy dialog, we can provide the minimum- maximum distance ranges for the selected lod node.

Here are the maximum and minimum distance values that I am using in this tutorial. You can change these values according to your need.

For high lod node:
Max Distance: 150
Min Distance: 0

For mid lod node:
Max Distance: 300
Min Distance: 150

For low lod node:
Max Distance: 100000 / infinity
Min Distance: 300

Now, the geometries will switch details based on the minimum and maximum distance attributes of lod nodes.


Step 7

We can now jump back and forth between less and the more detailed version of the geometry through More / Least Detail and More / Less Detail buttons (Flight studio rollout).

We can also do it with the help of a simple MaxScript command.

lod-distance-code

For eg. if I write FlightStudio.SetLODdistance <350> in the MaxScript Editor and execute it by pressing Ctrl + E then it will switch to the Mid_res lod level as the value that I entered, falls under the distance threshold of Mid lod node.

Instead of using a manual value input, we will be using the distance between the camera and the skull geometry as the LOD distance.


Step 8

creating-target-camera

Now, we need a camera so, let’s create a target camera through Create menu > Cameras > Target Camera or just press Ctrl + C to create a camera from the current view. Select the camera target and align it to the skull geometry.


Step 9

Now, we need to calculate the distance between the camera and the Skull geometries. This can be easily done with the help of Expose Transform helper.

You can also use the distance between the camera and its target and as the target is aligned to the geometries it will work fine.

creating-expose-transform-helper

So, let’s create an Expose Tm helper through Create > Helper > Expose Transform. Now, under Parameters rollout, uncheck the Parent option then pick Camera as Expose Node and any of the three skull geometries as Local Reference Node.

Note: Don’t worry About Expose node and Local Reference node. You can pick either object as Expose Node or LR node.


Step 10

copy-maxscript-to-clipboard

Under Distance to Reference group, we have the distance between the two objects. Click on the M button to copy the parameter as MaxScript code. Open the MaxScript Editor and paste the code.


Step 11

modifying-the-code

By putting both the MaxScript command together, we get:

FlightStudio.SetLODdistance $ExposeTransform001.distance

Step 12

Now, whenever we move the camera away or close to the Skull geometry and evaluate the MaxScript, max will fetch the lod level depending upon the distance between the camera and the skull geometry. (See image)

testing-the-code

The LOD system is working pretty well but every time after moving the camera, we have to evaluate the MaxScript code to see the changes. Let’s fix this in the next step.


Step 13

Let’s modify the Script as:

When Parameter $ExposeTransform001 change do
FlightStudio.SetLODdistance $ExposeTransform001.distance

connecting-the-parameters

Code Explanation:

Here, I am making use of When construct and the Change handler to detect the change in the object’s parameter.

So, Whenever camera moves it will change the Distance To Reference parameter of the Expose Transform helper and according to the code, whenever any of the Expose Transform helper’s parameter changes it will set the LOD distance same as the distance between the camera and the skull geometries and fetch the lod geometry that falls under the given distance threshold value.

I hope you enjoyed this tutorial and learned something new. Stay tuned and Subscribe for more tutorials. Thanks.