Terrain with multiple scene managers (SOLVED)

Falagard

30-03-2006 05:06:35

I'm trying to set up a terrain that uses a much smaller scale than most of the PLM2 examples, and I'm having a hard time setting up the options so the LODs work properly.

The terrain I'm using is a 1025x1025 map split into 257x257 sized pages, with PageSize=256 and height and width set to 4 in the config. The scale values I'm using are ScaleX and ScaleZ = 514, and ScaleY = 1024. This should give me a vertex every 2 units.

This machine doesn't have a very good 3d card, so I've disabled morphing.

What I'm getting is very low polygon lods being displayed all the time. If I set the MaxLodUnderCam=yes I can see the high detail terrain under the camera, but every other tile around the terrain is very low level of detail.

Here's the big problem - there are a couple settings, such as DistanceLOD that I can't figure out what they do in the code. I can't even see where they're being used! I've done Find All in visual studio for DistanceLOD and it doesn't seem to be used anywhere except to calculate LOD_Factor variable, and the LOD_Factor variable doesn't seem to be used anywhere special. However it is definitely doing something since when I change DistanceLOD from say 2 to 0.0001 I get more detail on the terrain, but not the full detail I'm expecting. I've tried changing it to 0.000001 and many other things but it doesn't seem to do anything and I have no idea what I'm actually changing.

I've also played with everything else I can think of, MaxPixelError, MaxRenderLevel, CameraThreshold, etc.

Here's my current config:


GroupName=PLSM2
LandScapeFileName=TempMap
LandScapeExtension=raw
Width=4
Height=4
PageSize=257
TileSize=65
ScaleX=514
ScaleY=1024
ScaleZ=514
MaxRenderLevel=10
MaxPixelError=2
Deformable=yes
DistanceLOD=0.001
VertexCompression=yes
VertexProgramMorph=no
VisibleRenderables=512
CameraThreshold=0.1
AvgColorsExists=yes
TextureFormat=Splatting2
NumMatHeightSplat=4
TextureFormatSupported0=Splatting2
NumTextureFormatSupported=1
VertexLit=yes
VertexNormals=yes
MaxLodUnderCam=no


What am I missing?

Clay

Falagard

30-03-2006 05:30:18

I'm also going to try this out on a machine with a better 3d card :-)

tuan kuranes

31-03-2006 08:32:01

Sorry distance lod an lod_factor no more used. Still there as intended to make a separated LOD system that combine geomorph lod + distance based lod. no done yet...
When I'll have more time, I'll add this on WIKI.
MaxPixelError is directly from geomorph paper.
Maxrenderlevel, is number of lod per Tile possible (absolute max being related to tile size)
Check here if not done yet :
http://www.ogre3d.org/wiki/index.php/Pa ... ing_Option

And point me what is not clear, what I should add ?

Falagard

31-03-2006 09:01:43

I've checked out that wiki page.

Thanks for letting me know the LODDistance and such are no longer used.

Can you help me resolve my problem though?

Max pixel error on its own doesn't seem to be doing anything. Setting MaxRenderLevel to 1 will give me the highly tesselated terrain everywhere, however I can't figure out what settings I need to get good level of detail for my scale values.

tuan kuranes

31-03-2006 09:16:51

Maxpixel error is the only parameter that matters, setting it the lower possible is the way to max lod at screen.

I don't remember if geomorph tile "roughness" factor computation takes scale in account, that could be the problem...

It's in PagingLandScapeRenderable::_calculateMinLevelDist2()

Falagard

31-03-2006 09:33:33

MaxPixelError = 0 doesn't work. I'm going to play with the scale values, try it out on my other machine again with LOD morph enabled, etc. but something's definitely not looking right for me.

tuan kuranes

31-03-2006 09:36:00

If you have time, just try add scale in PagingLandScapeRenderable::_calculateMinLevelDist2()
when computing v1, v2, v3, v4

Falagard

03-04-2006 07:44:03

LODs still aren't working. Doesn't seem to have anything to do with scale, have tried larger scales. MaxPixelError doesn't help, and MaxPixelError=0 will never work btw, I stepped through the code and your SetInt function in the Options class always checks for 0 returned from ParseInt and ignores it, so 0 is never valid in the settings ;-)

Are you sure LOD is working at the moment?

I'm packaging up my current app so I can put it online so you can at least look at the settings and tell me what I've done wrong.

Clay

tuan kuranes

03-04-2006 09:05:36

good spot. fixed that in cvs(when cvs will be available...)
Lod works here.

Falagard

03-04-2006 19:46:25

Does LOD work in any texture mode (nor morphing, just LOD) regardless of hardware?

http://www.larabie.net/ogre/GOOFEditorB ... 3-2006.rar

If you get a chance can you download that binary and take a look at my cfg file? I really have no idea what to do here. You can go in and edit the scale values to scale it much larger and it still doesn't seem to do anything.

Controls:

Alt+1 will enable wireframe
Mousewheel speeds and slows down the camera movement

The map name is TempMap and you can modify its cfg as much as you want.

You can change the camera LOD bias when on the Object tool click the Options button on the far right and you should see the property there.

Clay

Falagard

03-04-2006 19:51:33

Godamnit there has to be something wrong with my code cause I just dropped in the TempMap.cfg into your binary demo of PLM2 and set it as the default map and LOD worked. So the config is right, I'll go through the code and look if you're doing anything else different.

Falagard

03-04-2006 20:59:05

I've tried the following:

Setting the primary camera using setOption("primaryCamera", cam).
Setting the CurrentOptionCamera using setOption.
Calling loadNow passing the camera.
Setting the far clip distance of the camera to infinite.

*edit*

Disabled shadows. No go.

*end edit*

I'm about ready to throw my computer through the window.

Falagard

04-04-2006 05:13:42

Still not seeing the problem. Is there something I have to call every frame? I've stepped through the PagingLandscapeDemo (after having to comment out the overlay code for some reason the overlay couldn't find bluesomethingorother font?) and can't see what I'm missing.

Somebody has to know what the problem might be.

tuan kuranes

04-04-2006 08:35:17

cannot think of something there...
LOD is directly from camera to tile...

How do you switch to wireframe in goofed ?
[edit]found, alt+1[/edit]

tuan kuranes

04-04-2006 09:05:22

Well terrain has many, many problems.

Nothing seems tweakable (visible distance, number of visible pages, etc...), and when I replace the "temp" map with puget, it ends in assert about queuing twice same thing (which I cannot reproduce in demo)...
All those may be related to a problem with framelistener being registered by plsm2 and not being called.

But LOD problem is independant of that, it's camera to tile distance comparison...

That's indeed very weird...

Cannot remove octreescenemanager plugin from plugins.cfg... do you use multiple scene manager ?

cannot tell more without debug exe and pdb.

Falagard

04-04-2006 14:45:38

Okay, fixed it by creating only a single scene manager. I thought I had removed the creation of multiple scene managers while trying to find this bug (to try simplify the code to its simplest form to track down the bug) but forgot that the Application class creates a default scene manager before the plugins even start up.

I was creating multiple scene managers at once, and I need to for the editor because, well it's an editor ;-) I need to support an arbitrary number of scene managers and switch between them when the user switches tools.

Here's what I do:

The main application class creates a default scene manager (currently OctreeSceneManager as you guessed by being unable to remove that plugin), a viewport, and a camera. Each editor plugin can also create a scene manager and a camera. One editor plugin is activated at a time. When a plugin is activated, it sets its scene manager active by calling:


mRoot->_setCurrentSceneManager(mActiveSceneMgr);
mViewport->setCamera(mActiveCamera);


Is there anything else I should be doing, or any way I can make the PLM2 scene manager work with this system?

I didn't think this would cause any problems. Part of the design for my editor is the ability for plugins to each have their own scene manager - and if this is going to cause problems because scene managers can't support this, I may have to reconsider pulling this functionality out and force only a single scene manager for the entire editor.

What this means is you'd have to run the editor and choose your tool suite before the editor starts.

tuan kuranes

04-04-2006 14:50:35

Just to be sure, You share camera between scene managers ?
mmm not sure it's intended by design... perhaps even a Ogre bug if you can do that.... we should report that to Ogre team !

(camera are often derived in scenemanager therefore making them usable only by scene manger which created it.)

Falagard

04-04-2006 14:53:24

Nope, i don't share camera between scene managers. Please re-read.

I create a single viewport, multiple scene managers and a camera per scene manager. Then I switch the viewport's camera, and the root's current scene manager.

tuan kuranes

04-04-2006 15:04:32

Ok, In theory, it should work.

try adding some assert(cam->getscnmgr() == goodpluginscnmgr); just to be sure that camera-scenemgr correspondance is ok. As it is the best (only) explanation I can think of what's happening...

Falagard

04-04-2006 15:27:02

Camera is fine, I've added the assert and stepped through the code to verify that it's a PagingLandscapeCamera and its scene manager is the one PLM scene manager.

I assume your frame listeners get called each frame and are causing some sort of trouble when your scene manager is not active?

*edit*

That can't be it because your scene manager IS active.

tuan kuranes

04-04-2006 15:35:32

It shouldn"t as it's for queuing only, not lod :

bool isPaused = true;
setOption("pause", &isPaused );
// and when needed to know if paused or not
isPaused = *(bool*)getOption("pause");

should resolve queuing problem if any

tuan kuranes

04-04-2006 15:55:16

Just in case, I remember that Cegui should be informed too of a scenemanager change.

Falagard

04-04-2006 16:20:51

Of course.

Falagard

04-04-2006 18:28:31

Fixed :-)

I tracked the problem down to PagingLandScapeOptions::calculateCFactor the CFactor was staying at 0 because the primaryCamera->getViewport() was returning null. So now when activating a plugin in addition to calling:

mRoot->_setCurrentSceneManager(mActiveSceneMgr);
mViewport->setCamera(camera);

I added:

camera->_notifyViewport(mViewport);

Thanks for the help!

*big sigh of relief*