GeoMipMapped Terrain Scene Node ( UPDATED 3/3/05 )

A forum to store posts deemed exceptionally wise and useful
Guest

Post by Guest »

yes, you have to scale the heightmap down to 128x128, the provided one in the demo is 512x512.


another question: how can i scale the node bigger? the 7th command does not work for me or i do something wrong.

and if i use "mipmap->setScale(vector3df(10.0f, 10.0f, 10.0f));" the whole geometry mipmapping is beyond repair!

the geomipmapped terrain is cool, but way to small for my needs :(
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

Ok, I fixed the setScale and setPosition functions to re-calculate the data needed for proper geomipmapping after those calls, they should work now.

Thanks for that bug report! :) Glad to finally get some feedback from people using it, I need it ;)
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

deprecated wrote:Ok, my problem was that the headers were old and the new headers here not being found... fixed...

now, using the map provided, i keep getting seg. faults....

spintz, could the seg. faults have to do with the 16bit indices ???


anyways, nice screenshots, keep up the good work... The one thing that is really holding me (and probably more people) back from cool apps, is the lack of a good terrain engine in irrlicht...
I don't think it's the 16 bit indices causing the segfaults, weren't causing seg faults on my computer. Make sure that the lib you're linking with is compatible with you're DLL.
Guest

Post by Guest »

i have found another bug too (or maybe it isnt a bug):
the lightmap of the terrain is not correctly loaded. i painted a "Test" in the lightmap and searched it on the terrain, but i havent found it. i tested around and filled the lightmap with blue and red colors, then the terrain color got violet. i dont know if this is a bug but it obviously does not work :)

maybe another idea: set some sort of "cliprange" when the terrain should be geomipmapped. i use your (really great!!) code for my game framework (realtime strategy) and so the camera is some sort of high above the terrain. now, i nearly never get to see the first lod (the one that has the highest detail) only if i set the camera position down a bit. it would be cool if we could set a variable like "clipstart = (distance from the camera to a certain value like 100 for example)" . i hope you know what i mean, my english is really bad.

if i can be of some sort of help i would surely do it :) but i dont have much skill in coding.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

I'll add it to the list of future changes.

You're asking for the ability to manually edit the distances from the camera for which it's determined the level of detail the patch is drawn with.

The code in the scenenode which does this automatically is in CGeoMipMapSceneNode.cpp in the function CalculateTerrainData -

Code: Select all

	// Generate the distance threshold for determining what LOD to draw patches at
	if ( TerrainData.LODDistanceThreshold )
		delete [] TerrainData.LODDistanceThreshold;

	TerrainData.LODDistanceThreshold = new s32[TerrainData.MaxLOD];
	for ( i = 0; i < TerrainData.MaxLOD; i++ )
		TerrainData.LODDistanceThreshold[i] = (s32)( ( TerrainData.PatchSize * TerrainData.PatchSize ) * 
		( TerrainData.Scale.X * TerrainData.Scale.Z ) * ( i + 1 + i / 2 ) * ( i + 1 + i / 2 ) );
I'll look into the lightmap problem when I get a chance.
AmigaIrr
Posts: 94
Joined: Mon Jan 10, 2005 7:55 am
Location: France, Alsace

Post by AmigaIrr »

DEV-C++ support

thanks to réalise that....
L'eternité c'est long, surtout vers la fin...

Q6600 triton 79, 4 GO, 2* RAPTOR 150GO of ARECA 256 RAID 0, 3870 Zalmann, P5K. 24" Samsung. Antec nine hundred
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

what do you mean Dev-C++ support? Never used it. Does it not work with Dev-C++?

EDIT: I'll download Dev-C++ and see what the problem may be, never used it though, gonna be a while.
Guest

Post by Guest »

i use dev c++ and i have no problems at all :) really easy now
deprecated
Posts: 62
Joined: Fri Jan 07, 2005 4:37 pm
Location: California

Post by deprecated »

Alright!.
It works for me, on linux...

only a few small probs...

Collision Triangles are being drawn on the backside of the terrain only...

FPS is low (50's) ... i'm playing with the options to try to raise this...

any ideas?

otherwise,, this is really nice... the number of triangles that appear as you get closer... very cool...
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

deprecated, what is your terrain heightmap size? What are you setting your patchsize to?
deprecated
Posts: 62
Joined: Fri Jan 07, 2005 4:37 pm
Location: California

Post by deprecated »

hieghtmap = 512x512
patchSize = 17

Doesnt seem to matter what scale its at... same FPS...
Guest

Post by Guest »

here are some problems that i noticed, they may help you ^^ :

1. the scaling at creation doesnt work and the scaling after creation with setScale does not work good either :)

2. with patchsize 17 and terrainsize of 256 or greater i get slow framerates with opengl sometimes too. and heightmaps above 512 seem really slow to me, i dont know why.

3. if you scale the terrain bigger with setScale, the terrain sometimes disappears at certain camera angles.

4. the terrain with patch size 17 has edges (is not smooth).

5. if i set maxLod to smaller as 5 or bigger as 5 it gets reaally slow.

6. makePlanarTextureMapping does not work with the terrain, i always get errors.

that was everything that i noticed until now, it seems that its quite stable :) keep up the good work! you´re the man!!! :D


edit: maybe im doing something wrong with the terrain scaling? i post my code here:

Code: Select all

void CGame::CWorld_createGeoTerrain(IGeoMipMapSceneNode* mipmap,
							ITexture* terraintexture,
							ITexture* terrainlightmap,
							const c8* terrainheightmap,
							int maxLevelOfDetail,
							int maxGridResolution,
							vector3df terrainPosition,
							vector3df terrainRotation,
							vector3df terrainSize,
							bool debug)
{
	mipmap = CScene->addGeoMipMapSceneNode (0, -1, maxLevelOfDetail, maxGridResolution, 
   											terrainPosition,
											terrainRotation, 
   											terrainSize);
   											
	mipmap->LoadHeightMap (terrainheightmap);
	mipmap->setMaterialTexture (0, terraintexture); 
	mipmap->setMaterialTexture (1, terrainlightmap); 
	mipmap->setMaterialFlag (EMF_LIGHTING, true); 
	mipmap->setMaterialFlag (EMF_FOG_ENABLE, true);
	
	//for testing
	mipmap->setScale(vector3df(5.0f, 5.0f, 5.0f));
	
	if(debug == true){mipmap->setMaterialFlag (EMF_WIREFRAME, true);}
	if(debug == false){mipmap->setMaterialFlag (EMF_WIREFRAME, false);}
	
}

and i call the function like this:

Code: Select all

		CWorld_createGeoTerrain(terrain1,
							terraintexture1,
							terrainlightmap1,
							terrainheightmap1,
							5,
							17,
							vector3df(0.0f, 0.0f, 0.0f),
							vector3df(0.0f, 0.0f, 0.0f),
							vector3df(100.0f, 0.0f, 100.0f),
							false);
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

1. the scaling at creation doesnt work and the scaling after creation with setScale does not work good either
Could you describe "does not work good" both scaling works fine for me, either at creation or after with the setScale function.

2. with patchsize 17 and terrainsize of 256 or greater i get slow framerates with opengl sometimes too. and heightmaps above 512 seem really slow to me, i dont know why.
What are your machine specs?

3. if you scale the terrain bigger with setScale, the terrain sometimes disappears at certain camera angles.
I believe this is a product of the backface culling. If you are under the terrain, the backface culling will cull those triangles out. Try setting backface culling to false for the material and see if you still get this problem

4. the terrain with patch size 17 has edges (is not smooth).
Could you show me a screenshot of this? Everything is smooth for me

5. if i set maxLod to smaller as 5 or bigger as 5 it gets reaally slow.
5 is the highest LOD i've been able to use with this algorithm, and seems to be the most efficient, more work needs to be done with this. I need to figure out why, when the LOD is higher than 5, it doesn't work right. A lower LOD, like 2, means the patches in the distance will still be pretty detailed, so it will be slower.

6. makePlanarTextureMapping does not work with the terrain, i always get errors.
Yes, I need to test out the makePlanarTextureMapping, haven't used it yet, will figure out why it isn't working properly

Also, when you set the Y of the scale to 0, you're terrain will be flat.
Spintz
Posts: 1688
Joined: Thu Nov 04, 2004 3:25 pm

Post by Spintz »

deprecated wrote:hieghtmap = 512x512
patchSize = 17

Doesnt seem to matter what scale its at... same FPS...
Not sure, 512x512 is a rather large terrain, and it will run a little slow, until I can get the higher levels of detail working. Right now 5 is really the highest you can use and is the most efficient, once I get that fixed, I think we'll see a huge improvement in performance in the very large terrains.
deprecated
Posts: 62
Joined: Fri Jan 07, 2005 4:37 pm
Location: California

Post by deprecated »

Image
Image

Low FPS.... Shouldn't this be higher?
Last edited by deprecated on Sun Jan 23, 2005 8:02 pm, edited 1 time in total.
Post Reply