terrain smoothing only on one camera?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
death_au
Posts: 38
Joined: Tue Apr 17, 2007 9:48 am
Location: Australia

terrain smoothing only on one camera?

Post by death_au »

I wasn't sure whether to put this in beginners or advanced help. Need an intermediate one :P
I've got a problem where the terrain I'm loading up looks all jagged, but not on all cameras. I have 3 viewports with 1 camera each. On one of the viewports the terrain is smoothed, but not on the other two.
To understand what I mean, check out the following screenshot (look at the hill just in front):
Image
(click for a larger view)

I've tried creating cameras in a different order, as well as rendering the viewports in a different order. I've also tried changing the camera types between the default, FPS and Maya cams, none of which seems to make any difference.
Does anyone know why this is the case? It would be really great if we could smooth the terrain on the other viewports, too...
Atraides
Posts: 18
Joined: Wed Jun 06, 2007 1:09 am
Location: Australia

Post by Atraides »

i'm having the same problems too. Is there anyone who knows why this is happening cause its confusing the hell out of me.
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

I'm unable to reproduce this problem by just setting up two viewports in the terrain example, so i guess it must be your camera settings. are you using FoV to zoom in? are your cameras children of scaled nodes?

can you show some (minimal) code that illustrates the bug?
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Yeah theres a good chance that some of the cameras are far enough from the hill to trigger the terrain LOD. Try to tinker with the LOD setting on terrain creation (it is one of the initialisation parameters near the end, you have to set the LOD level) and see if disabling LOD rids you of this problem.
death_au
Posts: 38
Joined: Tue Apr 17, 2007 9:48 am
Location: Australia

Post by death_au »

bitplane wrote:I'm unable to reproduce this problem by just setting up two viewports in the terrain example, so i guess it must be your camera settings. are you using FoV to zoom in? are your cameras children of scaled nodes?

can you show some (minimal) code that illustrates the bug?
I'll work on getting some minimal code up if you want it, but the two cameras that are not smoothing are indeed children of scaled nodes. If that is what is causing the problem, then how can I fix it?
The cameras are parented for a reason. For example, the camera on the left is parented to the tank so that when the tank moves and turns, the camera stays behind it. And the top-right camera is parented to the end of the gun for aiming.
I'm interested to know why this makes in a difference in the rendering of the terrain.
Image
death_au
Posts: 38
Joined: Tue Apr 17, 2007 9:48 am
Location: Australia

Post by death_au »

okay, here's the code that does it:

Code: Select all

	//load the hightmap
	world_node = smgr->addTerrainSceneNode("heightmaptest.png");
	world_node->setScale(vector3df(10,2,10));
	world_node->setMaterialFlag(video::EMF_LIGHTING, false);

	//apply some textures
	world_node->setMaterialTexture(0, driver->getTexture("default_terrain_texture.jpg"));
	world_node->setMaterialTexture(1, driver->getTexture("detault_detailmap.jpg"));
	world_node->scaleTexture(1.0f,20.0f);
	world_node->setMaterialType(video::EMT_DETAIL_MAP);

	//create a tank node
	tank_node = smgr->addAnimatedMeshSceneNode(smgr->getMesh("tank.x"));
	tank_node->setScale(vector3df(5,5,5));
	tank_node->setPosition(vector3df(1300.0f,300.0f,1700.0f));

	//get the screen size and calc aspect ratio for cameras
	dimension2di screenSize = driver->getScreenSize();
	f32 ratio = ((f32)screenSize.Width/2.0f)/(f32)screenSize.Height;

	//create the camera on the left (unparented)
	left_cam = smgr->addCameraSceneNodeFPS();
	left_cam->setPosition(vector3df(0,0,-50.0f));
	left_cam->setAspectRatio(ratio);
	left_cam->setTarget(vector3df(970,280,1300));

	//create the camrea on the right (parented to scaled tank)
	right_cam = smgr->addCameraSceneNodeFPS();
	right_cam->setPosition(vector3df(1300.0f,300.0f,1650.0f));
	right_cam->setAspectRatio(ratio);
	right_cam->setInputReceiverEnabled(false);
	right_cam->setParent(tank_node);

	//...

	//main loop
	while(device->run()) 
	if(device->isWindowActive())
	{
		driver->beginScene(true,true,video::SColor(0,0,0,0));

		//Draw Right cam	
		smgr->setActiveCamera(right_cam);
		driver->setViewPort(rect<s32>((f32)screenSize.Width/2.0f,0,(f32)screenSize.Width,(f32)screenSize.Height));
		smgr->drawAll();

		//Draw Left cam
		smgr->setActiveCamera(left_cam);
		driver->setViewPort(rect<s32>(0,0,(f32)screenSize.Width/2.0f,(f32)screenSize.Height));
		smgr->drawAll();
		
		driver->endScene();

	}
and here's what the output looks like (click for a larger image):
Image
Image
Post Reply