Infinite ground plane?

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
starphoenix
Posts: 13
Joined: Thu Mar 27, 2008 2:59 am

Infinite ground plane?

Post by starphoenix »

I've been looking through the scene manager and everything for a while, and I don't seem to be able to find anything about how to create an infinite ground plane. I have created a finite ground plane using a flat terrain node, but it would be nice if I could simply create a plane. Any solutions?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Can you clarify the visual effect that you want to achive? A truly infinite plane would always fill the screen (unless viewed exactly orthogonally) out to the far clip plane.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

One way would be to create a finite ground plane so that its dimensions are slightly greater than double the camera far plane value. Then, every frame move the ground plane to be centered at the camera position. You can do this by moving the quad, or by overriding the world transform when rendering it. By keeping the camera over the center of the plane, you'll never see the edges.

Another possibility would be to use a system of tiles, similar to what the tiled terrain scene node does.

Travis
starphoenix
Posts: 13
Joined: Thu Mar 27, 2008 2:59 am

Post by starphoenix »

rogerborg:
I'm thinking something like the way you would view the horizon on earth, which isn't a plane, and it actually disappears because of the curvature, but I have the far plane

vitek:
Moving the plane around is actually a pretty good idea, I hadn't thought about that.

EDIT:
How can I determine the distance the far plane is at?
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

Haha I actually did something like this a few days ago. Basic method:

1. Create a screen quad.
2. Send 8 3d vectors as shader variables. 4 of them are the world space starting points for a line shot directly from the corner of the screen into the far plane corner on the other end of the frustum, and the other 4 are the ends of these rays. These are easy to obtain just use SceneManager->getCollisionManager()->getRayFromScreenCoords() (Name of function is similar to this but might not be 100%).
3. Send them as vertex shader uniform variables in the call back.
4. In the vertex shader interpolate between the 4 starting position and the 4 end positions based on the screen quad screen coordinates. This is already done for you linearly, you just have to know which side of the screen your on and send the corresponding ray. e.g. An easy but dirty way to do this is if(pos.x < 0.0 && pos.y < 0.0) RayStart = rStart4 else if(pos.x < 0.0 && pos.y > 0.0) send ray 3 instead, etc. I hope you get the jist of it because this part can be a little fiddly.
5. In the pixel shader just take the recieved line start and end and do your basic ray/infinite plane intersection. This is just something like:

Code: Select all

RayDirection = normalize(RayEnd -RayStart);
PVal = dot(PlaneNormal, RayDirection);

return (PVal > 0.0); // Might have to make that a <, or flip the plane normal, depending on certain factors.
5. Draw the screen quad BEFORE everything else.

Done, if you have any questions feel free to ask.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

obviously if you're moving the plane to always be underneath the camera then you're not going to get the visual effect of walking over it, the texture applied to the plane will not move as you walk so you might have to fiddle with the texture matrix or something to scroll it around as you walk.
Image Image Image
fennec
Posts: 55
Joined: Fri Oct 10, 2008 7:23 am

Post by fennec »

Want to go for an infinite stroll?
Post Reply