Level of Detail for geometry...is there a better way?

Hi,

I’m a technical artist for a company that has just recently added Unity to their pipeline. I’ve been trying to test LODs using the JavaScript method Aras described back in 2007, but I’ve been having a bit of trouble.

I brought in my meshes from a single FBX file, then created a new prefab, added the meshes and the script. I then pulled the prefab into the scene Hierarchy, but each mesh is seen, regardless of distance. I’ve checked the console for any errors and found none. The attributes load fine in the inspector. However, when I try to connect the meshes to the attributes, nothing updates in the Scene or the Game view. I’ve tried this with two objects and with three, updating the script accordingly.

Is there a method in 2.5 that’s better than this? From an offline rendering perspective, I’ve generated LODs in RenderMan based on screen-space pixel count before. Is there a similar screen-space method I could implement in Unity?

Thanks.

There is no lod integrated, so you can basically let your LoD code base on anything you want. The most common approach though are:

  1. Distance
  2. Bounding volume screen projection size through the corresponding method to calculate a screen point from a 3d position and calculating the area between the measuring points.

Sure you set it up right, that means outside of the game mode and then start the actual game mode?
I doubt that the script will work correctly when added at runtime (especially the whole setup is gone when you leave the game mode again)

u need something like this?!

var HighRes : GameObject;
var LowRes : GameObject;
var distance1 = 10.0; 

function Start ()
{
	HighRes.SetActiveRecursively(true);
	LowRes.SetActiveRecursively(false);
}


function Update () 
{
    var campos = Camera.main.transform.position;
    var dist = (transform.position-campos).sqrMagnitude;

    if( dist > distance1 ) 
    { 
		HighRes.SetActiveRecursively(false);
		LowRes.SetActiveRecursively(true);
	}

    else
    { 
		HighRes.SetActiveRecursively(true);
		LowRes.SetActiveRecursively(false);
    }
}

@dreamora:

I know about distance and bounding-volume based approaches, but each of them have their own limitations. Screen-space is a lot simpler in theory and doesn’t have to traverse the whole scene. Hm. I’ll try to think of a way to implement it.

@Archivision:

I tried using your code instead, but I’m still not getting full functionality. I played around with the LOD meshes and finally got some switching going on, but not the way I expected or could fully control. Using GameObject is really throwing me off. Correct me if I’m wrong, but the method Aras used before made sense because it stored all LODs for that object in the prefab. GameObject sort of defeats that organization.

I prefer to use cameras instead of scripting.

The basic idea is to place different LOD’s in different layers on the same object. You set up two cameras that are identical, ie field of view, position etc. Then you edit the far and near clipping ranges of each camera so that one camera’s view frustum(?) ends where the next begins. The “closer” camera displays the high LOD layer. The other camera displays the lower LOD layer.

You will of course have to set up the particular depth and clearing properties of each camera.

There will most likely be objects that you want to show in both cameras without any LOD, put them in a third layer that both cameras can see.

You can extend this with as many LOD’s as you see fit.

Did you notice the complete lack of scripting?