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

You discovered a bug in the engine, and you are sure that it is not a problem of your code? Just post it in here. Please read the bug posting guidelines first.
Post Reply
fritzgryphon
Posts: 22
Joined: Mon Sep 08, 2008 1:22 am

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

Post 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.
CarlS
Posts: 86
Joined: Wed May 09, 2007 1:21 am
Contact:

Post 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
fennec
Posts: 55
Joined: Fri Oct 10, 2008 7:23 am

Post 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.
hybrid
Admin
Posts: 14143
Joined: Wed Apr 19, 2006 9:20 pm
Location: Oldenburg(Oldb), Germany
Contact:

Post 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...
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post 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 :)
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Luke
Admin
Posts: 449
Joined: Fri Jul 14, 2006 7:55 am
Location: Australia
Contact:

Post by Luke »

I've seen the same problem. should have some time to fix this on wednesday.
[url=irc://irc.freenode.net/irrlicht]irrlicht irc[/url] - corrodinggames.com
fennec
Posts: 55
Joined: Fri Oct 10, 2008 7:23 am

Post 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
Luke
Admin
Posts: 449
Joined: Fri Jul 14, 2006 7:55 am
Location: Australia
Contact:

Post by Luke »

should be fixed now in the SVN.

sorry it took so long, been busy.
[url=irc://irc.freenode.net/irrlicht]irrlicht irc[/url] - corrodinggames.com
Post Reply