T3D 1.0.1 / 1.1a LODs not working
by Matt Kronyak · in Torque 3D Professional · 02/02/2010 (10:04 pm) · 18 replies
I've been searching around for some information regarding LODs in T3D but haven't been able to find the answer I'm looking for yet. The problem I'm having is that I'm not seeing any LOD changes on any model, in particular models that work fine in TGEA. I have taken models directly from my TGEA project, verified their LODs are working as expected, dropped them right into T3D and don't get any LOD changes.
Do the models need to be re-exported with a new exporter? Do the LODs need to be named differently? Is there something in script or in the engine I need to change? I took a look into the code since I had an encountered a bug in TGEA 1.7.1 where LODs weren't working (and posted a fix for this) but it doesn't appear to be the same problem in T3D. All of the TSShapeInstance "selectCurrentDetail" methods are commented out in T3D so I'm not clear on how LOD changing works in the engine yet.
What has changed with how LODs are handled and / or how the models need to be structured from TGEA 1.8.1 to T3D 1.x?
Do the models need to be re-exported with a new exporter? Do the LODs need to be named differently? Is there something in script or in the engine I need to change? I took a look into the code since I had an encountered a bug in TGEA 1.7.1 where LODs weren't working (and posted a fix for this) but it doesn't appear to be the same problem in T3D. All of the TSShapeInstance "selectCurrentDetail" methods are commented out in T3D so I'm not clear on how LOD changing works in the engine yet.
What has changed with how LODs are handled and / or how the models need to be structured from TGEA 1.8.1 to T3D 1.x?
About the author
#2
I don't personally export the models so I'm not familiar with the entire process from the tools perspective but I know we were using numbers at the end of the mesh names to indicate the LOD levels. The models are made in Max and Maya.
02/02/2010 (11:52 pm)
Strangely in TGEA, LODs work fine. In Show Tool I can see all of the LODs. In T3D, they never change. The models always stay at the highest LOD. I also noticed this with the recent "Flower Power" pack that I was taking a look at. TGEA/Show Tool work fine, but I'm not getting any LODs in T3D (neither the standard exe/dll nor my custom build of the engine).I don't personally export the models so I'm not familiar with the entire process from the tools perspective but I know we were using numbers at the end of the mesh names to indicate the LOD levels. The models are made in Max and Maya.
#3
02/03/2010 (1:52 am)
Try sticking them in the ShapeEditor in 1.1a and then check the lods box and see what detail numbers come up with the slider ... if any.
#4
02/03/2010 (3:54 am)
Interesting. If I load it into the 1.1a ShapeEditor I'm able to use the "levels" slider and see the different LODs. If I drop a model down into the level it never changes on its own, though.
#5
02/03/2010 (6:45 am)
Another interesting thing -- if I change the value of $pref::TS::skipRenderDLs in the console I can universally change the LOD of every object in the level. The LODs appear to be part of the models correctly they just aren't automatically switching. I'll look into this more. If someone else has run into this and has a solution I would appreciate seeing it. Otherwise if I can get this sorted out I'll post my solution here.
#6
I think the problem must be what are the conditions to change the lod in game. Try checking the bounding boxes sizes, and if the detail numbers are too low or high...
02/03/2010 (10:40 am)
Hi!I think the problem must be what are the conditions to change the lod in game. Try checking the bounding boxes sizes, and if the detail numbers are too low or high...
#7
02/03/2010 (7:04 pm)
Matt, we are also experiencing the same issues with our LODs not showing up in T3D...They're the exact same models we used in the Juggernaut release of Buccaneer but we've not looked into it at all yet...Did you find anything out?
#8
02/03/2010 (7:33 pm)
So far I've determined that the models have the LODs and I'm able to programatically switch between them but for whatever reason the LODs won't automatically switch. I'm going to investigate more tonight.
#9
1.0.1or 1.1Alpha? Is there any differce between them?
Is this a certain classtype (playerObjects, vehicleObjects, staticshapeObjects, etc) or anything and everything? (including TsStatic)
02/03/2010 (8:04 pm)
No idea if this'll help but just to check guys - 1.0.1or 1.1Alpha? Is there any differce between them?
Is this a certain classtype (playerObjects, vehicleObjects, staticshapeObjects, etc) or anything and everything? (including TsStatic)
#10
02/03/2010 (8:09 pm)
Auto LODs neither work in 1.0.1 nor 1.1a with my models. Seems to be everything (including TsStatic).
#11
02/04/2010 (3:58 am)
I had some difficulties with displaying LODs in T3d. In Showtool I could see the different LODs but not in T3D. After searching the forums and the documentation I found a document regarding DTS faq, saying that the dts should be unmeshed with unmeshdts. After that everything worked fine.
#12
I was able to get LODs working with a change to TSShapeInstance.
In engine\ts\tsShapeInstance.cpp in this method:
S32 TSShapeInstance::setDetailFromDistance( const SceneState *state, F32 scaledDistance )
I commented out the following code:
This got the LODs working on my models and drastically improved the performance of my game.
What the exact problem is I'm not entirely sure yet. Is it the if condition? Is it something with details.first().maxError? Is it something wrong with how the pixelRadius value is calculated? the const value of smScreenError? A problem in setDetailFromScreenError?
Right now, I don't know. Having it completely bypass this code which is supposed to make "legacy" DTS LOD work and letting it flow into using setDetailFromPixelSize appears to work without a problem.
I'm not sure of what side effects this might have yet so I'll look into it further when I have time. For now I'm going with this solution and will revisit it if there are any problems later on.
02/04/2010 (4:08 am)
Richard, do you have a link to that document by any chance?I was able to get LODs working with a change to TSShapeInstance.
In engine\ts\tsShapeInstance.cpp in this method:
S32 TSShapeInstance::setDetailFromDistance( const SceneState *state, F32 scaledDistance )
I commented out the following code:
// This is legacy DTS support for older "multires" based
// meshes. The original crossbow weapon uses this.
//
// If we have more than one detail level and the maxError
// is non-negative then we do some sort of screen error
// metric for detail selection.
//
if ( mShape->mSmallestVisibleDL >= 0 &&
mShape->details.first().maxError >= 0 )
{
// The pixel size of 1 meter at the input distance.
F32 pixelRadius = state->projectRadius( scaledDistance, 1.0f ) * pixelScale;
static const F32 smScreenError = 5.0f;
return setDetailFromScreenError( smScreenError / pixelRadius );
}This got the LODs working on my models and drastically improved the performance of my game.
What the exact problem is I'm not entirely sure yet. Is it the if condition? Is it something with details.first().maxError? Is it something wrong with how the pixelRadius value is calculated? the const value of smScreenError? A problem in setDetailFromScreenError?
Right now, I don't know. Having it completely bypass this code which is supposed to make "legacy" DTS LOD work and letting it flow into using setDetailFromPixelSize appears to work without a problem.
I'm not sure of what side effects this might have yet so I'll look into it further when I have time. For now I'm going with this solution and will revisit it if there are any problems later on.
#13
This link:
http://docs.torquepowered.com/artist/official/3D%20Studio%20Max/DTS%20FAQ.html
See the part about Exporting, especially this one:
- My model exports correctly, so why are there problems with auto detail levels?
They mention that you use unmeshdts when you have a MultiRes modifier, but for me it worked on models that did not have the modifier.
Also this link:
http://tdn.garagegames.com/wiki/DTS/Getting_Started
Here you find a lot about dts and setting up your models.
There was also a thread about this item, but I can't find it anymore.
02/04/2010 (7:40 am)
@Matt:This link:
http://docs.torquepowered.com/artist/official/3D%20Studio%20Max/DTS%20FAQ.html
See the part about Exporting, especially this one:
- My model exports correctly, so why are there problems with auto detail levels?
They mention that you use unmeshdts when you have a MultiRes modifier, but for me it worked on models that did not have the modifier.
Also this link:
http://tdn.garagegames.com/wiki/DTS/Getting_Started
Here you find a lot about dts and setting up your models.
There was also a thread about this item, but I can't find it anymore.
#14
www.torquepowered.com/community/forums/viewthread/109109
Not explicitly a problem w/ the engine, actually an issue with the exporters not filling in these values. Cheap hack in there automatically loads models with -1 screenerror, since it's not the preferred method of LODing. Exporters fail to set any value, resulting in random crazy LOD values.
02/04/2010 (2:08 pm)
Might be the same issue as:www.torquepowered.com/community/forums/viewthread/109109
Not explicitly a problem w/ the engine, actually an issue with the exporters not filling in these values. Cheap hack in there automatically loads models with -1 screenerror, since it's not the preferred method of LODing. Exporters fail to set any value, resulting in random crazy LOD values.
#15
02/04/2010 (2:15 pm)
Very interesting Henry. This does sound related. The solution found in the post you linked to would end up achieving the same result as the solution I posted here. If mShape->details.first().maxError is < 0 (the code in your post sets it to -1) then it will skip trying to use setDetailFromScreenError and use setDetailFromPixelSize.
#16
02/05/2010 (1:38 am)
The funny bit here is that I don't think I know of any legacy DTS's that ever used screenerror. As far as I can tell the Max2DTS exporter has never correctly set a value... maybe I'm wrong (and obviously there are other exporters). I guess it just seems odd that we're breaking so many legacy models over something that's supposed to support them, yet I've never encountered a model that doesn't define its details levels in terms of pixel size. ::boggle::
#17
02/05/2010 (6:12 am)
May be this will help you. Same like Steve I don't have problems with LODs but in my project I realized that models made for TGEA switch their LODs in T3D at greater distance. What I did to get this solved was I just changed the size of Bounds and reexported them and I managed to get LODs switch at normal distance in T3D.
#18
02/05/2010 (5:19 pm)
The T3D pixel size calculations seem to consistently produce far larger values than the TGE/A calculations, not sure why that is. Hadn't thought of changing the bounding box sizes. I do think there are a few cases where making the bounds smaller than the object itself might break things, though -- for example polysoup collision, which doesn't check geometry outside the bounds. Still good to know, though.
Associate Steve Acaster
[YorkshireRifles.com]
I'd say recheck the hierarchies - but a DTS should just be a DTS ...
What are you using for export? (something fancy like Max I presume - I know little about this high-end expensive stuff, but I think that there might be a new exporter for that ... or am I thinking of collada?)