# TU Wien Rendering #10 - Camera models

## Метаданные

- **Канал:** Two Minute Papers
- **YouTube:** https://www.youtube.com/watch?v=ZhN5-o397QI
- **Дата:** 30.03.2015
- **Длительность:** 7:47
- **Просмотры:** 7,396

## Описание

To build an adequate light simulation program, we also need to model how exactly light interacts with a camera. In this segment, we learn more about perspective and orthographic cameras, and we quickly implement the former in just a few lines of simple C++ code.

About the course:
This course aims to give an overview of basic and state-of-the-art methods of rendering. Offline methods such as ray and path tracing, photon mapping and many other algorithms are introduced and various refinement are explained. 

The basics of the involved physics, such as geometric optics, surface and media interaction with light and camera models are outlined. 

The apparatus of Monte Carlo methods is introduced which is heavily used in several algorithms and its refinement in the form of stratified sampling and the Metropolis-Hastings method is explained. 

At the end of the course students should be familiar with common techniques in rendering and find their way around the current state-of-the-art of the field. Furthermore the exercises should deepen the attendees' understanding of the basic principles of light transport and enable them to write a simple rendering program themselves.

These videos are the recordings of the lectures of 2015 at the Teschnische Universität Wien by Károly Zsolnai and Thomas Auzinger

Course website and slides → http://www.cg.tuwien.ac.at/courses/Rendering/
Subscribe → http://www.youtube.com/subscription_center?add_user=keeroyz
Web → https://cg.tuwien.ac.at/~zsolnai/
Twitter → https://twitter.com/karoly_zsolnai

## Содержание

### [0:00](https://www.youtube.com/watch?v=ZhN5-o397QI) Perspective camera

let's talk about cameras uh i'm just going to rush through this because obviously everyone knows about pinhole cameras the most basic camera model one can imagine is basically a box and you make a super small hole on the box and you put a film in it basically some amount of light will flow into this and it is going to be caught by the film and therefore you are going to see an image on this film we are not that interested in this model but what you're interested in is for instance a perspective camera means that i have the length of the camera this is what you see the teapot on and this is where the image is going to be formed and i have a point somewhere and this is going to be where the rays are starting from so i have this i and i'm going to shoot race towards the length of the camera and i'm the i'm going to be interested in the continuation of these rays what objects do they hit and what color they are but there's multiple things that i need to specify when creating a perspective camera this plane can have a width a height some kind of field of view and the aspect ratio is given by the ratio of the width and the height what about the field of view well if you like to play first person shooters you have probably fiddled with settings like that but the field of view is basically what you see here and different camera models or different eye models have different fields of view so for instance it's quite different for a horse if you would like to model how a horse sees something then the field of view would be much larger because the eyes are on the sides so you can almost see what it did what's behind it

### [2:00](https://www.youtube.com/watch?v=ZhN5-o397QI&t=120s) Perspective camera implementation

and we have a given field of view that we can model here and this can be arbitrarily changed if you have a good perspective camera implementation let's quickly put together an implementation of that what i'm interested in is that i'm going to give an x y pair these are pixel positions give me the zeroth pixel uh in terms of x and the fifth pixel of uh with respect to y and this is going to give me back a world space coordinate where this is exactly on the lens so i'm subdividing this lens into pixels i only want to care about the pixels because each pixel after each other they are going to be computed how much light is going through these pixels and therefore these workspace coordinates are interesting so if i instantiate such a perspective camera the height and the width is definitely given and the field of view with respect to the x axis is also given and the desired pixel positions are going to be x p and y p what are these variables are supported on so x p and y p are on zero and w and h so these are really the pixels which pixel am i interested in the field of view can be like reasonably arbitrary but same choices on zero pi and the field of view with respect to the y direction can be computed from the aspect ratio and the other field of view this is the end result and before we try to understand what's going on let's try to play with it and this i do because usually if you read literature math books whatever you never see the journey behind things you you get the answer and this is usually a huge formula that doesn't seem to make any sense so let's get a bit more experience on how to play with this formula how can we understand this so for instance let's forget a in x and y let's forget these tangent terms and let's just play with the fraction so i substitute x and y equals zero x p so what do i have for the x coordinate well it's two times zero minus the width over the width therefore this is minus one and i have the same for y so this is zero minus h over h that's minus one so for the zero pixels i have world space positions of minus one and minus one therefore this is going to be the bottom left so far this seems to make some sense what if i substitute the other end for the pixels well if i have w for xp then i have 2w minus w over w and therefore this is going to be one both for x and both for y so this is going to be the upper right and whatever i specify for xp and yp between these two extreme values then this is really going to give me the word space coordinates of this camera model we have forgotten about the tangents well let's put them back i don't know what i just did now but it's working again yes i wonder why this presenter has like 2 million 500 buttons but okay let's not digress so i multiply back these numbers with these tangents and then i can see that basically what it gives me more perspective distortion so the higher the field of view with respect to x's the more perspective distortion i'm going to get

### [5:50](https://www.youtube.com/watch?v=ZhN5-o397QI&t=350s) Graphic camera implementation

well this is already a good enough description that i can put in code in fact i have already coded it up and this is a very simple function that does exactly what we have been talking about it's simple as that so if you don't take the prototype of the function this is basically five lines and this is still readable so this could be even less so not too shabby i mean a prospective camera in five lines of code passed there are also autographic cameras this is a large difference between from the perspective camera because the rays of light are also parallel with each other and they are perpendicular to this camera plane so basically they don't start from one point looking outwards they are perfectly parallel with each other and perpendicular to this lens and they also don't meet at the eye and you can see that the perspective distortion is completely omitted here so you can see here the same image the same scene with the same settings with an orthographic and the perspective camera and you can see that the realism is completely different in the two there's another example with lux render in the next image you won't see the environment map in the background but disregard that because the implementation of environment maps with orthographic cameras is in a way non-trivial so lots of perspective distortion well maybe you don't notice because this is what you're used to but if you have an orthographic camera then this is a perfect distortion free geometric shape and back to the perspective camera so this fourth gives you a significant perspective distortion

---
*Источник: https://ekstraktznaniy.ru/video/15002*