Game Development Community

Detail-LOD popup

by Steve Lamperti · in Torque Game Engine · 08/17/2005 (5:14 pm) · 11 replies

I'm trying to set up a popup menu to change the LOD with which the models are displayed. I've got my menu set up, but now I could use some help getting pointed in the right direction as to what to control to change the base LOD of the models. I tried changing DetailManager::smDetailScale, but it doesn't seem to be doing anything.

My popup currently reads Very High, High, Medium, and Low, and it currently takes values from 1 to 4. I tried setting smDetail scale directly to the value of this popup, but, as I said, no luck.

If someone could point me to a thread, tutorial, or some doc on this subject, that would be very helpful.
(I've tried searching the forums, but also had no luck with that.)

If I need to loop through all the open objects, and call a method on each one, that would be fine as well. Just need a hint as to if this makes sense, or if there is something already set up that I am just missing.

Thanks for any responses,

#1
08/17/2005 (5:49 pm)
Did you look at the demo scripts where you move the slider to change the LOD on the orc model?
#2
08/18/2005 (9:15 am)
I just looked at that, (thanks for the suggestion,) but it seems to use a variable called Interior::detailAdjust. I saw this variable, but my assumption was that it was associated with the interior stuff, and would only effect the objects inside an interior. I don't actually have any interiors in my project, and need to effect all the objects in the outside/whole world. I will try to see if I was incorrect about this, by seeing if I can set that variable, and seeing what happens.
#3
10/14/2005 (12:38 am)
In case you are still wondering about this, use $pref::TS::detailAdjust. I had the same problem.
#4
10/17/2005 (9:05 am)
@andy
Thanks for the response. I should have posted here when I resolved this issue on my end.
I'm using mShapeInstance->smDetailAdjust in the C++ code, which seems to work well. I added an instance method to shapebase that takes my 1-4 number, and sets the smDetailAdjust number in the shapeInstance. This seems to be working fine.
#5
05/24/2006 (8:29 pm)
Observed 2 things about LOD switching
- it happens at different distances betw camera and the object when the resolution is different.
- currently setting different values for $pref::TS::detailAdjust to maintain the same LOD switching point across different screen resolution.

Tests using my model yields these $pref::TS::detailAdjust settings

Vertical resolution, $pref::TS::detailAdjust
480, 2.57
600, 1.65
768, 1
1024, 0.641

Note: I used 1024x768 as reference, hence the value 1.

Been trying to find a formula to link these two values to make LOD switching consistent across different screen resolution.

Help, anyone? Or is there a better approach to this? Thanks.
#6
05/24/2006 (8:49 pm)
No, that makes sense, because the LOD is based on the amount of _pixels_ an object is taking up on screen... and thusly different resolutions will affect how many pixels it's taking up.
#7
05/25/2006 (1:15 am)
I'm looking for a formula/equation to calculate the value of $pref::TS::detailAdjust at any given screen resolution, as oppose to manually testing it out on screen which is what I'm doing now.
#8
05/25/2006 (2:23 am)
Wouldn't you just... scale by the difference between the resolutions? I guess going off the resolution you use for reference LOD...
#9
05/25/2006 (8:42 am)
I have plot it out, doesn't seem to be a simple linear relationship betw the 2 values.
#10
02/14/2008 (3:03 pm)
I think I figured this out. It's really strange though.

The code I'm using is:


%detailAdjustRatio = mPow(1024/(getWord(getRes(), 0)), 2);
$pref::TS::detailAdjust = %detailAdjustRatio;


So the function is basically

y = (1024/x)^2


The weird thing is that it works correctly using the X dimension of the screen but not using the Y dimension. The documentation seems to say everywhere that it's the pixel *height* that's important, but for whatever reason, using the width here makes it work correctly.

I have not tested extensively (ie with odd aspect ratios, etc).
#11
02/14/2008 (4:01 pm)
Ah, now I see. It's because when the screen's aspect ratio changes, from say 1024x768 to 1280x768, the view frustrum stays the same angle width-wise but just adjusts how much up/down you can see. I guess it makes sense for an FPS that you'd want to keep your peripheral vision sideways higher priority than your up/down.