Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » vanishing point perspective
- gtoal
-
1000+ posts
vanishing point perspective
I just thought I would post and share a thought I just had - this may be obvious to some people but I managed to live 57 years without putting 2+2 together :-)
Question: why are there two types of perspective? Single vanishing point and two-point perspective?
Answer: there aren't! There is only 2-point perspective. However if you are looking down corridors that are perpendicular, the other vanishing point is level with you and off to one side - effectively infinitely far away as far as the horizon is concerned!
As soon as you start turning, the single vanishing point directly in front of you starts to move off to one side, and the other vanishing point which was level with you and effectively infinitely far away, starts moving in from infinity towards the center. Once you're at a 45 degree angle to the grid, the left and right vanishing points are equally far away.
If you continue to turn to a full 90 degree quarter turn, the vanishing point which was inifinitely far off to one side is now in front of you and the one which was in front of you is now infinitely far off to the other side.
Bottom line, single vanishing point perspective is the degenerate case subset of two-point perspective.
Was this obvious to everyone else and I just missed it?
G
Question: why are there two types of perspective? Single vanishing point and two-point perspective?
Answer: there aren't! There is only 2-point perspective. However if you are looking down corridors that are perpendicular, the other vanishing point is level with you and off to one side - effectively infinitely far away as far as the horizon is concerned!
As soon as you start turning, the single vanishing point directly in front of you starts to move off to one side, and the other vanishing point which was level with you and effectively infinitely far away, starts moving in from infinity towards the center. Once you're at a 45 degree angle to the grid, the left and right vanishing points are equally far away.
If you continue to turn to a full 90 degree quarter turn, the vanishing point which was inifinitely far off to one side is now in front of you and the one which was in front of you is now infinitely far off to the other side.
Bottom line, single vanishing point perspective is the degenerate case subset of two-point perspective.
Was this obvious to everyone else and I just missed it?
G
- gtoal
-
1000+ posts
vanishing point perspective
A further thought has somewhat shaken up my world view :-) … two point perspective depends on:
1) a rectilinear grid
and
2) a human field of view of < 180 degrees. (If you could see around say 200 degrees, then you could look down the road in front of you and a road to the left of you and a road to the right of you, and you would see 3 vanishing points!)
and
3) the assumption that the horizon is a straight line - when in fact it is really a circle.
If you lived in a city where the streets were on a hex grid and blocks were triangular, you would in fact be able to look down three streets at once and see three vanishing points!
If you stood in the middle of a circular city laid out like spokes of a bicycle, you would see a vanishing point at the end of every street, so in fact the circular horizon would effectively be an infinite number of vanishing points.
Therefore the concept of a vanishing point is not a fixed function defined by the standard perspective transformation, but a convenient concept to approximate the effect of a perspective transformation applied to whatever grid the geometry of the objects you are looking at is on.
By the way the reason I'm thinking about this stuff is that I am exploring the possibility of doing a 3D world (grid, maze type) using only vanishing point similar triangles to do the math rather than the usual perspective formula. One side effect of doing it this way would be you could never get the problem that some raycasters have of curved-appearing walls that should be straight. And maybe the calculations would be cheaper - I don't yet know.
As far as I can find, there are no 3D games that use vanishing points as their primitive. They may generate them incidentally as a side effect of using the normal projective transform, but none that I can find *define* the projection by creating the vanishing points first and extending lines in their direction.
At the moment I'm hung up on working out the maths for this problem: you have a wall/fence/whatever that is equally spaced, which you are viewing at an angle, ie it is receding into the distance. Each fencepost is 10 units apart, but when projected on to 2D, the spacing between segments reduces the farther away each segment is located in world coordinates. Although I can work out the values by using a perspective transformation from the 3D coordinates, what I want to do is discover the function F(x,y,theta) that maps each segment to an X offset on screen (and which by use of similar triangles makes working out the height a simple proportional calculation) For example the first wall segment is 40 pixels wide, then the next is 30, then 25 or whatever - and a segment infinitely far away would have 0 width and would be located at the right hand vanishing point (something like x=150px)
I found this page on vanishing points et al which is quite interesting, although only tangentially relevant to my problem: http://www.extentofthejam.com/pseudo/ (it's a better fit for the road modelling I'm looking at in https://scratch.mit.edu/projects/142864962/ than it is for a block world)
It's undoubtedly true that the solution I'm looking for is mappable to a standard projective transformation; I'm just looking to see if a different way of looking at the problem can lead to a simplification of the way things are calculated. I may be barking up the wrong tree. We'll see…
G
1) a rectilinear grid
and
2) a human field of view of < 180 degrees. (If you could see around say 200 degrees, then you could look down the road in front of you and a road to the left of you and a road to the right of you, and you would see 3 vanishing points!)
and
3) the assumption that the horizon is a straight line - when in fact it is really a circle.
If you lived in a city where the streets were on a hex grid and blocks were triangular, you would in fact be able to look down three streets at once and see three vanishing points!
If you stood in the middle of a circular city laid out like spokes of a bicycle, you would see a vanishing point at the end of every street, so in fact the circular horizon would effectively be an infinite number of vanishing points.
Therefore the concept of a vanishing point is not a fixed function defined by the standard perspective transformation, but a convenient concept to approximate the effect of a perspective transformation applied to whatever grid the geometry of the objects you are looking at is on.
By the way the reason I'm thinking about this stuff is that I am exploring the possibility of doing a 3D world (grid, maze type) using only vanishing point similar triangles to do the math rather than the usual perspective formula. One side effect of doing it this way would be you could never get the problem that some raycasters have of curved-appearing walls that should be straight. And maybe the calculations would be cheaper - I don't yet know.
As far as I can find, there are no 3D games that use vanishing points as their primitive. They may generate them incidentally as a side effect of using the normal projective transform, but none that I can find *define* the projection by creating the vanishing points first and extending lines in their direction.
At the moment I'm hung up on working out the maths for this problem: you have a wall/fence/whatever that is equally spaced, which you are viewing at an angle, ie it is receding into the distance. Each fencepost is 10 units apart, but when projected on to 2D, the spacing between segments reduces the farther away each segment is located in world coordinates. Although I can work out the values by using a perspective transformation from the 3D coordinates, what I want to do is discover the function F(x,y,theta) that maps each segment to an X offset on screen (and which by use of similar triangles makes working out the height a simple proportional calculation) For example the first wall segment is 40 pixels wide, then the next is 30, then 25 or whatever - and a segment infinitely far away would have 0 width and would be located at the right hand vanishing point (something like x=150px)
I found this page on vanishing points et al which is quite interesting, although only tangentially relevant to my problem: http://www.extentofthejam.com/pseudo/ (it's a better fit for the road modelling I'm looking at in https://scratch.mit.edu/projects/142864962/ than it is for a block world)
It's undoubtedly true that the solution I'm looking for is mappable to a standard projective transformation; I'm just looking to see if a different way of looking at the problem can lead to a simplification of the way things are calculated. I may be barking up the wrong tree. We'll see…
G
- __init__
-
1000+ posts
vanishing point perspective
Pretty sure we see in three point perspective 

- mobluse
-
100+ posts
vanishing point perspective
I made a project 8 Sep 2015 that draws using vanishing points in order to teach perspective drawing. It's rather fast, and you can rotate the building and even see inside it, and change other parameters.
Perspective Drawing
https://scratch.mit.edu/projects/75781702/
Click a green flag. Watch and learn perspective drawing using random angles, ground and height. You can click the floor plan and then the angle is determined by the mouse-pointer and the lower corner by W, A, S, D, and the height by arrow up and down. Space interrupts that the angle is determined by the mouse-pointer, and it is then determined by arrow left and right. J, K, 6, 7 also moves something. Try!
This uses two point perspective. Three point perspective is used to draw e.g. skyscrapers. There are YouTube-videos about this. There are also books: http://lmgtfy.com/?q=ernest+norling
Perspective Drawing
https://scratch.mit.edu/projects/75781702/
Click a green flag. Watch and learn perspective drawing using random angles, ground and height. You can click the floor plan and then the angle is determined by the mouse-pointer and the lower corner by W, A, S, D, and the height by arrow up and down. Space interrupts that the angle is determined by the mouse-pointer, and it is then determined by arrow left and right. J, K, 6, 7 also moves something. Try!
This uses two point perspective. Three point perspective is used to draw e.g. skyscrapers. There are YouTube-videos about this. There are also books: http://lmgtfy.com/?q=ernest+norling
- gtoal
-
1000+ posts
vanishing point perspective
I made a project 8 Sep 2015 that draws using vanishing points in order to teach perspective drawing. It's rather fast, and you can rotate the building and even see inside it, and change other parameters.
Perspective Drawing
https://scratch.mit.edu/projects/75781702/
Thanks, you're thinking alone the same lines I am. My thought is that the maths behind the vanishing point constructs should be simpler or at least less computationally expensive than the traditional mapping of 3D to 2D using a lens and viewport model., even if it maybe isn't as accurate.
The trick that's necessary in order to move from this to something that can draw an arbitrary block world is to get the horizontal spacing right. I've done the traditional ‘fence post’ drawing here: https://scratch.mit.edu/projects/157841571/
There's a geometrical construct that can create the same drawing, which artists use, but for use in a program, you want to calculate the separation between fenceposts rather than construct it using triangles and measuring.
G
- MartinBraendli2
-
100+ posts
vanishing point perspective
The perspective that is modelled with vanishing points simulates the view of a pinhole camera (without a lens). This perspective has the property that straight lines in the world are also straight lines in the projection. The biggest FOV that you can get with a pinhole camera is close to 180 degrees, which is also the biggest FOV that you can draw with the vanishing point method.
Lenses distort the image and destroy the property that straight lines stay straight (the smaller the focal length, the harder straight lines get bent). Since our eye has a lens, we don't actually see straight lines straight (but almost), so technically the perspective with vanishing points is not the perspective of the human eye.
Each angle (in relation to the view angle) has its own vanishing point. Special cases:
- Lines parallel to the view direction: They have the v.p. in center of your view
- Lines perpendicular to the view axis: They don't have a v.p. and stay parallel in the projection (for example fence posts, given that you look parallel to the ground. If you look down a bit, they also get a v.p.)
As for your problem: What exactly is your angle theta? Why don't you calculate where the vanishing point of the wall is (or definie it). The dimension of the wall segments are proportional to the distance to vanishing point, so the math will become quite simple.
Lenses distort the image and destroy the property that straight lines stay straight (the smaller the focal length, the harder straight lines get bent). Since our eye has a lens, we don't actually see straight lines straight (but almost), so technically the perspective with vanishing points is not the perspective of the human eye.
Each angle (in relation to the view angle) has its own vanishing point. Special cases:
- Lines parallel to the view direction: They have the v.p. in center of your view
- Lines perpendicular to the view axis: They don't have a v.p. and stay parallel in the projection (for example fence posts, given that you look parallel to the ground. If you look down a bit, they also get a v.p.)
As for your problem: What exactly is your angle theta? Why don't you calculate where the vanishing point of the wall is (or definie it). The dimension of the wall segments are proportional to the distance to vanishing point, so the math will become quite simple.
- gtoal
-
1000+ posts
vanishing point perspective
I've made some progress with textured perspective walls:
https://scratch.mit.edu/projects/158370759/
This demo only handles single-point perspective, but the principle for two-point perspective is the same and the rendered images from that project ought to work.
I had to rethink the code from the “very big wall” demo I did a couple of days ago which was ghastly slow, and after a late night I was finally able to speed the code up by an order of magnitude. It is *definitely* fast enough now for a dungeon explorer type of game.
I haven't yet written any parameterised code for displaying walls in world coordinates, but clearly that will be possible. It's just a question of determining the correct scale for the sprites and which rendered costume to use, plus a little tricky maths to handle reflections (if your costumes are chosen carefully so that you can halve the number of images by reflecting them).
By rendering a few more versions of the costumes, we can handle a change in the player's eye-level (currently it is centered). A bunch of pre-rendered ceiling and floor sprites might be fun too.
Graham
https://scratch.mit.edu/projects/158370759/
This demo only handles single-point perspective, but the principle for two-point perspective is the same and the rendered images from that project ought to work.
I had to rethink the code from the “very big wall” demo I did a couple of days ago which was ghastly slow, and after a late night I was finally able to speed the code up by an order of magnitude. It is *definitely* fast enough now for a dungeon explorer type of game.
I haven't yet written any parameterised code for displaying walls in world coordinates, but clearly that will be possible. It's just a question of determining the correct scale for the sprites and which rendered costume to use, plus a little tricky maths to handle reflections (if your costumes are chosen carefully so that you can halve the number of images by reflecting them).
By rendering a few more versions of the costumes, we can handle a change in the player's eye-level (currently it is centered). A bunch of pre-rendered ceiling and floor sprites might be fun too.
Graham
- gtoal
-
1000+ posts
vanishing point perspective
More progress: https://scratch.mit.edu/projects/159332081/ - perhaps this will encourage some of you to have a go…
- gtoal
-
1000+ posts
vanishing point perspective
Today's hack… walking down an infinite corridor… https://scratch.mit.edu/projects/159398170/ - I threw this together far too quickly - doing it properly involves a lot of redesign and graphics rework I think - but as a back-of-the-envelope sketch implementation goes, it's OK… Each sprite is magnified until the next one replaces the current one, at which point they're sneakily reset and the loop repeats. With some coding effort I believe it will eventually be a seamless transition.
- Discussion Forums
- » Advanced Topics
-
» vanishing point perspective