Move closer or shrink FOV?

There was this question posed by my professor in a computer graphics class. It was for bonus points (we love them, don’t we?) and sadly, I didn’t give a satisfactory answer. And to this date, I still don’t know what the answer should be.

To elaborate, first I need to explain what field of view or FOV is. Humans have an FOV of almost 180 degrees. For 3D graphics and computer games, it’s typically 90, 60 or 45 degrees (helps with cutting down processing calculations). What is it?

Simple illustration of field of view

Suppose you’re standing somewhere looking at a scene. You notice something in the distance, and you want to take a closer look or zoom in. For the purposes of this example, let’s just assume you have some bionic superpower that enables your eyes to function like a camera/binoculars thingy.

There are two ways to go about doing this. You can physically move closer. Or you can shrink your FOV. A smaller FOV means less is visible, but whatever is visible is enlarged, so to speak. Either way, the object of your attention becomes larger.

Move closer or shrink FOV?

The resulting rendered scene is of the same “width” in both cases. The object is enlarged in both cases. The question was, what’s the difference between moving closer and shrinking the FOV?

Let’s look at a normal rendered scene.

Scene with normal perspective

If we move closer and keep the FOV at 60 degrees, we get this:

Scene with camera closer

If we stay where we are and change the FOV to 45 degrees, we get this:

Scene with smaller FOV

Using the tree and cube to act as reference points, and the mountain as backdrop, can you spot the difference?

Now that I think about it, the answer probably has some similarities to the concept of ray tracing. Instead of having light reflecting off objects and enter your eye, think about shooting back rays from the eye towards the scene.

I guess I’ll have to talk more on this. Please share your answer and we can compare notes. Stay tuned.

Path of a Polymath Programmer Part 5

I’ve talked about how stories, typing, role playing, console games and self-learning Japanese so far. Quick links here for reference:

Continuing the console game part, I started noticing more about the games than actually playing them. I marvelled at the graphics (it was mostly pixel art then), and appreciated the game music. Immersed in the story plots, I identified with the characters (I still have sniffles when I think of Celeste losing her grandpa in Final Fantasy VI) and got lost in the fantastic worlds the game creators forged.

I was in the Chinese orchestra then, so I had begun learning about music. It was at this point that I found I could separate distinct music pieces in the same song played by different instruments in my mind! There’s the main melody, the supporting melody, and the bass or beat carrying the song through.

Fast forwarding… got drafted into military service. Learned to harden will and tons of self discipline and self reliance. Fast forwarding…

University life!! I would eventually major in applied math and computational science. What’s the difference between computer science and computational science? You can read the short description here. You will also notice that a lot of my sample program source or topics tend to focus on math and science related stuff.

With university life came a lot more freedom in how I use my time. I watched tons of television shows. Ed. Friends. Gilmore Girls. Ally McBeal. Charmed. CSI. Andromeda. Alias. Sliders. I also watched tons of movies (my friends usually find out about the latest movies from me). Lots of stories and plot lines. Improved listening skills and English language (I’m in Singapore, and sometimes the English spoken here leaves a lot to be desired…).

Also with university life, I needed a computer. So finally, I got a proper computer so I could print notes and reports, and do some light programming. If you’re doing C/C++ programming on the Windows platform, I suggest the Dev-C++ software. I was writing code on the *nix platform, but sometimes I needed to test my code without going to the university labs.

Then I started mucking around with computer graphics software. There’s Terragen™ for generating incredible landscapes, Bryce 4 (version 6 as of this writing) for creating quick scenes and texture generation, and trueSpace 4 (version 7.5 out as of this writing) for object modelling. I used the different software for the function it provides best, then export the results to another software for the purpose I need. For example, I could model something in trueSpace, export it into Bryce, and render the object there with a texture I created. Or I could

  • render scene in Terragen and export as picture (resource 1)
  • create texture in Bryce and export as picture (resource 2)
  • import resource 1 and 2 into trueSpace
  • map resource 1 onto cylinder and place on scene to use as backdrop
  • map resource 2 onto an object modelled in trueSpace
  • render entire scene in trueSpace

Learn to use the tool that is most efficient at what it does. More importantly, learn to use the results from that tool with other tools.

Then I learned about Hyper Text Markup Language (HTML) and Cascading Style Sheets (CSS), and played with the code. It looks very nice and all, but it’s only on my computer. The web was all the craze then, so I thought I might as well get a place to put my brand new spanking HTML page up, so I searched around for web hosts. I went for free hosting for a while, but eventually got a paid package. I was still a student then, so this cut me back quite a bit.

Sometime around this period, I was taking computer graphics and 3D geometry classes. One of the professors mentioned a computer graphics contest, and the deadline was only a few days away. I don’t know what came into me, but I spent the next few days coming up with a theme and the scene. My weekend was burnt because I was busy scanning textures. I worked through the night before the deadline because I was slapping on textures and tweaking the radiosity settings and rendering and rerendering the scene.

It was terrible. I don’t think my submission even got noticed. The other entries were way better looking than mine. But I thought I had a better theme. All those days and nights gone… oh well, at least I tried.

Time passed and suddenly I was in my final year. The thesis topics available weren’t interesting, so I talked with my advisor and finally came up with something. I would be doing a study on computer virus epidemiology. Ok, big word there. Simply put, I’d be studying how computer viruses behave during an epidemic, and I’ll be using existing information on biological viruses as a comparison.

So amidst the graph theory, coding theory and Frenet apparatus from my math classes, and more matrix calculations than I ever want to see in my computational science classes, I was busy researching on both biological and computer viruses. I had to understand the math models used in epidemiology so I could transfer the relevant properties over to my simulation program.

Oh, I didn’t tell you. I was writing a computer virus behaviour simulation program that mimics real world results. And no, it’s not a computer virus. I was interested in its behaviour, not its method of spreading (though I got bombarded with information on payload and security and what-not during my research).

Then my ability to use tools and interchange results was put to the test. I wrote my simulation program in C and ran it in Unix. But I didn’t know how to produce a graph or chart with my results. Then I remembered Matlab, so I changed my C program to output something Matlab could take in. Then I used Matlab to generate the chart.

I was using LaTeX to generate my thesis document, and I had had to write small programs to generate code for some LaTeX commands. I also imported the Matlab generated charts into my thesis document. I remember one of my fellow students being kind of smug about his knowledge of document generation, because he co-wrote a few papers with his professor. Oh well…

In the end, I wrote a 40-page thesis, complete with research findings, charts, math formulas, proofs, topological models and my proposed model and program for computer viruses. That fellow student was kind of smug about his 100+ pages of material. Whatever

Next came the thesis dissertation. I figured that my presentation would have more impact if I could show the computer virus propagation. I needed a Windows port of my simulation code. Oh my goodness! Luckily, I tinkered with Windows code before, so I dug up the remnants of a working template, and translated my C program simulation logic into the Windows code equivalent. My original simulation program had no interface to speak of (it was supposed to just run for hours and blip out a bunch of numbers), so I had some work to do. I also had to display the viral propagation in real time, so I had to code in some basic charting function.

I got the Windows program up in time, and all in all, the dissertation went well. Whew…

So… a preview for the next one in this series, I’ll be talking about game development and demos. Keep coding!

Continue to part 6