Infinite ground plane?
-
- Posts: 13
- Joined: Thu Mar 27, 2008 2:59 am
Infinite ground plane?
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?
-
- Admin
- Posts: 3590
- Joined: Mon Oct 09, 2006 9:36 am
- Location: Scotland - gonnae no slag aff mah Engleesh
- Contact:
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
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
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
Another possibility would be to use a system of tiles, similar to what the tiled terrain scene node does.
Travis
-
- Posts: 13
- Joined: Thu Mar 27, 2008 2:59 am
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?
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?
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:
5. Draw the screen quad BEFORE everything else.
Done, if you have any questions feel free to ask.
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.
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
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net