Page 1 of 1

[fixed] Culling terrain patches according to camera's FOV

Posted: Thu Oct 09, 2008 10:17 pm
by fritzgryphon
The Irrlicht terrain automatically culls itself according to the camera's FOV.
So, any terrain patches outside of your FOV are not rendered for speed.

My dilemma is that I have two cameras; the player's camera, and the player's gun camera, which is attached to his gun, and facing in the same direction.

The player's FOV is 1(radian), and the gun camera's FOV is 0.2. The camera renders to a texture, which appears on the player's screen as a textured cube. It works like a scope, giving the player an always-present zoomed view of what the gun sees.

The terrain culls itself according to the gun camera's FOV, and the player sees large gaps in the terrain off to the sides of the screen.

*************
Image

*************


I've tried loading the gun camera first, or last, or resetting the FOV of the camera(s) in different order, but no matter what I do, the terrain culls itself according to the gun camera, which always has a narrower FOV. I've tried changing or disabling the culling mode for the terrain, but it seems to be for something different, and has no effect.

Is there a way to force the terrain to use a particular camera to cull with, or perhaps even 2 cameras? Or better yet, disable this FOV culling altogether? Or perhaps I need to make my own terrain mesh instead of using the Irrlicht terrain?

Any help greatly appreciated, thanks.

****

And a related question; is it possible to prevent the terrain from ever changing LODs? I understand it is effective to improve performance, but sometimes bullets will strike apparent thin air above the peak of a hill in the distance, with unpleasant results.

Posted: Fri Oct 10, 2008 3:31 pm
by CarlS
Interesting problem.
When you said that you tried changing the culling mode for the terrain, do you mean you tried setting the Level Of Detail to 0 in the TerrainSceneNode argument list?

If that doesn't do it, you may need to take a performance hit and switch to using the TerrainMesh instead.

EDIT/
Sorry, think I may have misread your post. Try setting TerrainNode->setAutomaticCulling(EAC_OFF).
/END EDIT


--Carl

Posted: Fri Oct 10, 2008 7:11 pm
by fennec
Setting the LOD argument to 1 does solve the terrain morphing (0 is crash).

I thought of setting the patch size to ETPS_127 (basically the entire terrain in one patch), but I get the error on runtime that there are 'cannot draw triangles, too many primitives'.

I suppose there's a maximum number of polygons per object (patch).

EAC_OFF doesn't seem to have an effect.

Thanks, that terrainmesh should work good.

Posted: Fri Oct 10, 2008 8:34 pm
by hybrid
If you disable the LOD effect, you should use the terrain mesh instead of the terrain scene node. That allows for arbitrarily sized heightmaps (as will the terrain node in Irrlicht 1.5 as well) and will also avoid the calculations which will still happen in the background...

Posted: Fri Oct 10, 2008 9:01 pm
by bitplane
The terrain culls itself according to the gun camera's FOV, and the player sees large gaps in the terrain off to the sides of the screen.
Sounds like a bug to me. The terrain should cull its patches depending on the current camera, not a previous one. Looks like CTerrainSceneNode::preRenderLODCalculations() could do with a test that works when a camera changes the FOV but not the position.
No time to look at this atm, but can move this thread to bug reports :)

Posted: Sun Oct 12, 2008 1:59 am
by Luke
I've seen the same problem. should have some time to fix this on wednesday.

Posted: Sun Oct 12, 2008 4:26 am
by fennec
One further thing to add; originally the gun camera was a CameraFPS.

When I changed it to a standard camera, the terrain glitches ceased. Just like that.

I'm new to this, so I can't begin to understand why. But if my app will help you track the bug, you can download the vcproj and media files here.

http://members.shaw.ca/evilgryphon1/boxwander.rar

Posted: Fri Oct 17, 2008 5:12 am
by Luke
should be fixed now in the SVN.

sorry it took so long, been busy.