Perspective


Yesterday, I figured out a problem that’s been bothering me for over 10 years! I am a software engineer by trade, so you’ll understand that I deal with technical issues all the time. I’ve never been really a “Graphics” person (per se) but I’ve always dabbled in graphics as a hobby. Anyhow, the issue is one that’s been solved many times over by many folks, but I couldn’t get it figured out in my own personal “graphics engine” so it bothered me. What it boils down to is this: Perspective distorts images according to how we view them.

Let me explain. In computer displays, you are tasked with making a 3-dimensional (3d) object appear that way, but on a flat, 2-dimensional (2d) surface. What you must do therefore is to take a 3d object and “map” it to the 2d display so that it “appears” to be a 3d object. This uses the concept of “perspective” of course, and most of us are familiar with the notion where parallel lines appear to converge in the distance if we view them from behind. Think of walking down some railroad tracks and as you look down at your feet and then raise your eye-level gradually to the horizon, you will note that the tracks appear to converge in the distance, ultimately to a point.

This is not a new concept, but it is critical to get it right in order to have the appearance of 3d on your 2d display monitor on your computer. So – just how is it done? Well, that’s the trick. I’ve spent 100’s of hours studying various algorithms from many folks and kind of come up with my own “blended” version of those algorithms. It works well for simple objects, but I always had a glitch in my algorithm when I tried to take it to the next level which was to apply texture maps to the object in order to give it “realism.” In today’s graphical world of the computer, it was decided that it would be far cheaper and easier that instead of actually drawing each and every pixel of an object on the screen, that we could simply draw them in a flat 2d space (a canvas if you will) and then “apply” that drawing to a “surface” that has been mapped from 3d to 2d space already.

Now, that’s all a very technical way of saying that we “cover” the outside of our model in 3d space with a 2d bitmap that represents a “picture” of the object in question such that it appears realistic. Make sense? The simplest example is a wall in a room. Take and visualize a wall in a room, actually, you should have at least 3 walls in your visual field when you are looking at a wall, and of course a ceiling too, but we’ll ignore that for now. So, as you’re looking at the walls, they are changed from “square” or “rectangular” shapes which they are in actuality to something that appears distorted in your visual field according to the principle of perspective to where the “side” of the rectangle that is further away from you will appear to be shorter or smaller, and the lines of the top and bottom of the rectangle in your field of view will appear to converge somewhat as they merge with that far side of the wall.

Have I lost you yet? Good. You get it. It’s very difficult to draw in “text” so maybe I can insert some pictures (eventually) into this to give you the idea quickly. Now, that wall is simple and easy enough to visualize, and even to take to the next level where we take a picture of a wall, an image, a “bitmap” representing an image of a real wall somewhere in the world, but which is rectangular, and now I must “map” that image to the perspective view of the wall that I have been describing now so that it also gets the rules of perspective applied to it. But that’s it! That was the key ingredient in my algorithm that I was missing all this time. My bitmaps got mapped to the surfaces in 3d space that I was drawing (in pseudo-realtime in my graphical engine) and each image would appear “correct” along the lines of the legs of the triangles represented in the image (you draw triangles in texture-mapping, long explanation, outside the scope of this discussion) but along the hypotenuse of each triangle my images were getting distorted and I could never figure out why!

But now I get it finally, it’s because of the rules of perspective being applied to the 3d object and I was not then applying those same “perspective” rules to the texture map that was being drawing onto that object. I discovered my error by accident too, by fiddling with the perspective “factor” that gets applied to the drawing. There is this one computation that “maps” the 3d coordinates into 2d space for viewing on your flat computer monitor, and what I did was to change that factor to make my “eye” appear relatively closer and then further away from the object in question. When you are “close” to an object the perspective makes it appear very distorted (in a relative sense) according to where your eye is. However, in the reverse sense, if your eye is relatively far away, then the lines of an object won’t appear to converge “as much” and may even appear to be parallel if your eye is pretty far away from that object.

This “optical illusion” is evidenced when we take pictures of objects from a long distance away and they appear to be the same distance from each other even though they are relatively far away from each other. Movie makers know about this and take advantage of it all the time to film “close calls” in scenes of action movies and such. I can make it look like a vehicle is “close” to a moving train using this technique by having the camera lens relatively far away from the vehicle and the moving train, but that again is probably a topic for another discussion. My ultimate point is that I found the error in my algorithm to be that I applied the perspective “factor” to the mapping of the “object” from 3d to 2d space, but I did not then apply the same perspective factor to the application of the texture map to the object. All I have to do now is to go back and figure out exactly where to plug in that factor and my texture maps should no longer appear “distorted” along the hypotenuse of each drawn triangle!

Simple, eh? I thought it significant enough to write it in my blog because “perspective” is something that applies in all situations in life. You can think of it as “world view.” Cheryl and I went to the monthly meeting of the California Republican Assembly (CRA) local South Bay chapter last evening. We are going to join this organization and begin to try to make a difference in our local area. We face some daunting challenges, but the speaker last night had some great ideas. I won’t bother you with the details, a lot of what he had to say was very difficult in fact for all of us to hear. He basically said what we’ve done in the past is not working, and those were the reasons why Craig Huey did not win the election for Congressional District 36.

We face a challenge of “World View” such that we must change our strategy to reach out to others and offer them the Republican notion of “We are the party of principle and opportunity.” We have got to set ourselves up as opposed to the notions of the liberals who want to convert everyone to their “entitlement mentality” (everyone deserves the same reward regardless of how much they work for it). In the same sense, we are faced with the challenge of presenting our Christian ideas onto the world, in a world that wants nothing to do with God or “Religion.” You have to ask the question of “Why don’t they want God in their lives?” That one should be obvious — because they want to be in charge!

So you see – it all boils down to just who is in charge doesn’t it? That’s the “ultimate” perspective in life, the one that changes everything. When I became a born-again believer in Jesus Christ, it changed my entire perspective on life! It changed the way I think about things, how I think about and act towards other people, and how I look at and value life and especially things. We live in a very materialistic society, one that values things and accomplishments above people and relationships. But, it’s not like that in most of the world. It’s easy for us in our western culture, especially here in the U.S. to get “caught up” and become so busy that we don’t look around at the problems in the rest of the world.

My challenge to all of you is to “Raise your perspective” this day. Take a look from a higher level and see whether or not the world’s problems are the same as ours. Get out of your daily struggle and look around you and see if there isn’t work for all of us to do in this world, to help one another and to love one another. This is the ultimate opportunity that Jesus wants to give us when He asked us to “Follow me.”

 

 

Advertisements

2 thoughts on “Perspective

  1. Good site! I truly love how it is simple on my eyes and the data are well written. I am wondering how I might be notified whenever a new post has been made. I’ve subscribed to your RSS feed which must do the trick! Have a nice day! “You can discover what your enemy fears most by observing the means he uses to frighten you.” by Eric Hoffer.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s