This time I wanna talk about my recently implemented physically based camera setup. I stumbled upon this topic while researching for Depth of Field Post-Processing techniques. You can find some really nice write-ups here: Basically what it comes down to is trying to simulate how a camera behaves (including its problems and constrictions) in the real world. I'm still a little uncertain as to how much sense this makes as it can be quite difficult to wrap your head around using it if you're not a photographer/cinematographer (or someone proficient in using digital cameras). There's also some breathing room as to how far you want to go when it comes to simulating a real life camera because of the restrictions that it brings with it. Let me give you a quick rundown... There are 3 settings in a digital camera that control the final image's exposure (aka how bright the image is): - Aperture - Shutter Speed - ISO Speed Aperture is the opening on your camera that describes how much light (stops of light) is allowed to enter. It is measured in F-Stops and describes the ratio of the focal length (f) and the diameter of the lens opening (D): N = f / D Furthermore it directly affects something that is called the Depth of Field. The Depth of Field is the area in your image that is in focus. The rest of the picture that is not in focus becomes increasingly blurry and shows something called Bokeh. Imagine a small dot on the sensor where the lens is focusing all the light onto. If you were to increase the distance between the sensor and the lens (the focal distance) then this small dot of focused light would become larger and spread outwards. This small dot is what is otherwise known as the Circle of Confusion (CoC). So to come back to rendering, the aperture size would be an important variable to simulating Depth of Field and Bokeh. Shutter Speed is the time that the shutter as it is called, is open to let light in. It is measured in seconds (e.g. 2sec, 1sec, 1/200sec). In rendering this would correspond to motion blur and the blur strength. The longer the shutter is open the stronger our motion blur. However as we can't properly simulate this function as an integration of accumulated light over time in computer graphics we just have to approximate this in the form of a motion blur strength in the range of [0,1]: 1 sec = 1.0 (max motion blur). 1/1000 sec = 0.0 (no motion blur) ISO Speed is the speed or sensitivity of the sensor/film to light. A higher ISO allows for a more exposed (brighter) image but introduces noise. These 3 variables together control the image's final exposure. If you increase one of them, you have to decrease one of the others. For example you can't expect to obtain a well exposed image when using a small aperture (high F-number, F/22), a quick shutter speed (1/2000) and a low ISO (100). In that case you'd have three choices to make: - Decrease the shutter speed so that more light comes in (over time) - Increase the aperture size so that more light comes in - Increase the ISO speed however this will create a noisy image Another variable that is important to our physically based camera system would be the focal length (measured in mm). This would correspond to a zoom lens in real life. In my engine I've made this to be in the common range of 18mm - 210mm. It's also quite easy to convert this directly to its corresponding Field of View (Fov) using the following functions: // Focal length (mm) to FoV (degrees) inline double FocalLengthToFOV(const double focalLength) { const double filmSize = 43.266615300557; // common film size return (2 * std::atan(filmSize / (2 * focalLength))) * 180 / PI; } // FoV (degrees) to Focal length (mm) inline double FOVToFocalLength(const double FoV) { const double filmSize = 43.266615300557; // common film size return (filmSize / (2 * std::tan(PI * FoV / 360))); } The relationship between aperture and focal length is something I'm still working on...so don't be alarmed if the result isn't exactly what you'd expect from a real camera. Here are some screenshots showing the resulting image using different camera settings: Aperture: f/1.4 |
Archives
May 2016
AuthorA guy who's passionate about graphics programming and has fun coding engine/tools Categories |