3
$\begingroup$
  • I have done my due hour of research before asking this question, it's a simple question, but I have found no hint at an answer online.

I want the ability to extend an object infinitely in one direction, such as a tower that appears infinitely high, or a road infinitely long. I have tried my hardest to think up an approach to this that doesn't cheat, but nothing has come to mind.

An example, take a textured cube, and have it appear infinitely tiled in one direction, to its vanishing point: enter image description here

Is there a way of doing this while retaining lighting and bumpmaps so it seamlessly blends with level geometry? Is there any way to do this efficiently?

Hopefully this isn't a stupid or misplaced question, thanks for your time.

$\endgroup$
2
$\begingroup$

It should be possible to do this properly by using a modified projection matrix for your entire scene that has its far plane at infinity, as detailed here. That should allow you to properly render points infinitely far away from the camera. The presentation says that such a point is represented by a direction (a vector with .w = 0), so it should be as simple as replacing the position of your vertex with the direction vector pointing towards the desired vanishing point.

One caveat is that any interpolation between the vanishing point and any other vertex would be incorrect, because the perspective correct hardware interpolator can't properly handle infinite values. This shouldn't affect lighting assuming normals are the same, but it will make texturing considerably harder. Probably the easiest way here would be to do an inverse projection of the point back to object space in the fragment shader and define the texture coordinates to be based on the object space position of the fragment.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.