<p>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 <a href="http://www.terathon.com/gdc07_lengyel.pdf" rel="nofollow noreferrer">here</a>. 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.</p>

<p>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.</p>

CC BY-SA 3.0
2017-09-28T15:16:13.127Z
2017-09-28T15:38:46.670Z
2017-09-28T15:38:46.670Z
Quinchilion
<ul>
<li>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.</li>
</ul>
<p>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.</p>
<p>An example, take a textured cube, and have it appear infinitely tiled in one direction, to its vanishing point:
<a href="https://i.sstatic.net/ZEwMC.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ZEwMC.png" alt="enter image description here" /></a></p>
<p>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?</p>
<p>Hopefully this isn't a stupid or misplaced question, thanks for your time.</p>

<shader><computational-geometry><perspective>
Creating a vanishing point perspective shader
Orion Reed
# Creating a vanishing point perspective shader

(Asked by: username_0 on 2017-09-27)

* 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](https://i.sstatic.net/ZEwMC.png)](https://i.sstatic.net/ZEwMC.png)

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.

**Tags:** shader, computational-geometry, perspective


---

## 1 answers

### Answer by username_1 on 2017-09-28. Score: 2

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](http://www.terathon.com/gdc07_lengyel.pdf). 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.


---

