LOD by distance to the orthographic camera

Hello forum,

I’m trying to do something that I thought was simple, but seemingly it’s not that easy.

I understand that Unity’s LOD system works by refering to a percentage of screen size that objects occupy. That’s not fit for the isometric 3D game I’m trying to make.

I’d like to have my LODs match the distance from the orthographic camera, as perceived from the viewer. Or, to put it otherwise, that the LODs are set according to their distance from the plane of the camera (and not the camera object itself) multiplied by the orthographic factor. Thus, when the ortho camera zooms out, all objects should swap LODs at the same time.

Is there a simple (or less simple) way to do that ?

Thanks

I’ve never tried using the Unity LOD system together with an orthographic camera, so I’m not sure whether and how that works. But I’d say the percentage of screen size still applies for an orthographic camera. Distance to the camera or the camera plane has no influence on the size of the object with an orthographic camera, so I would not like it to influence the LOD level. What it’s really about is the size of the object divided by the scale of the orthographic camera.

For some part that seems to be what you’re describing. “when the ortho camera zooms out, all objects should swap LODs at the same time.” I’m not sure how the distance to camera or camera plane has anything to do with that. And I also don’t see how that is any different from “a percentage of screen size” or “distance from the orthographic camera, as perceived”.

Thanks for the answer. I understand that I wasn’t clear and actually mixed two things: the real distance to the camera (in a conic perspective) and the distance “perceived” by the user in an orthogonal perspective, which truly is the “orthographic size”. My bad.

My problem with the current LOD based on screen percentage is that, when I zoom out my orthographic camera, small bushes swap their LODs earlier than big trees, even if they are on the same “plane” as perceived by the user. And I don’t want that to happen because the shape of the textures for leaves and flowers is supposed to be coherent in the whole scene at a given distance, no matter the size of the plant as a whole.

For those who could be interested, I finally resorted to writing my own LOD system by distance or orthographic size (both cases are coded, conic and orthogonal), which, when added to an object, overrides the default LOD group behaviour. The script is not fully optimized, but since I don’t need that many items on screen, it’s good for me. Feel free to optimize it further if you like !

http://www.unity3d-france.com/unity/phpBB3/viewtopic.php?f=24&p=108007

Disclaimer : in case you need to read the comments there, you may need to translate some French. But it’s easy French :slight_smile:

put it in update, ( make sure camera is facing down i.e xrotationandy rotation to 90)

var pos = this.transform.position;
pos.y = this.GetComponent().orthographicSize;
this.transform.position = pos;

this will solve problem as it will tie camera y world position to orthographicSize, which in orthographic camera wont make a difference ! as it doesnt consider camera y position ! but value of orthographicSize is appox to camera y position , then one can calulate vector3 distance between camera and object , now manually set active lod , i.e set active gameobject at whatever distance you like,