3 ms·
Why can’t you just instantiate a lens in front of the camera and render rays through it?
by xwdv 6y ago
Why can’t you just instantiate a lens in front of the camera and render rays through it?
- hfjrito 6y agoNot an expert, I would guess at least these two things: 1. There are actually around 20 lenses in a camera, not one. 2. A lens converts a ray into a cone, right? And then you need to pass that cone through the other 20 lenses which further modify it's shape, differently at different wavelengths. I would guess this is extremely computationally expensive done naively.
- elihu 6y agoCone tracing is a thing that exists, but I think most path tracers just just regular rays. (There's also ray differentials, which if I understand correctly, are a way of tracking how a cone of light would spread out after bouncing off of curved surfaces, if the ray were a cone.) As to why lenses would cause a problem specifically, I don't know the path tracing algorithm well enough to say for sure offhand, but it may have something to do with introducing random sampling before you even hit the first scene object. Usually in ray tracing the first hit is kind of a freebie; you can calculate direct illumination exactly, and it's only indirect illumination that's approximated. (In path tracing, it's approximated by doing a lot of random sampling.) So, not having to approximate the first-hit direct illumination reduces the noise quite a bit right off the bat.
- joshuak 6y agoYou can. It's just very costly. Rays typically represent just a single sample, so the more probabilistic the projected image becomes (read "unfocused"), the more samples are required to capture it smoothly. This is compounded by the number of lens elements, the material's index of refraction and other complexities. A single element lens adds a minimum of two additional ray/surface evaluations for every sample of which their are many per pixel. Also, as a separate matter many implementations optimize around the assumption that the projection from three dimensions to two is done in a uniform, undistorted space. For example the kind of projection that can be fully described by a 4x4 matrix. Changing that assumption loses those optimizations, and generally leads to substance abuse and mayhem.
- xwdv 6y agoIs unfocused light in real life actually probabilistic?
- nielsbot 6y agoI thought all light transfer was probabilistic. (You should read Feynman's QED for more)
- xwdv 6y agoIt would make sense.
- andbberger 6y agoYes. But probabilistic isn't the word I would use. https://en.wikipedia.org/wiki/Wave%E2%80%93particle_duality https://en.wikipedia.org/wiki/Wave%E2%80%93particle_duality
- layoutIfNeeded 6y agoNo. Bokeh can be perfectly described with classical optics.
- thdrdt 6y agoYou can at the cost of some light bounces. Most modern render engines render rays from the camera into the scene. This speeds up rendering a lot but also means rendering caustics will need a huge amount of samples because the probability of seeing light from a camera through glass is very low. Bi-directional path tracing fixes some of these problems. So it can be done but always at a cost (rendering times). In Blender I have done this a couple of times and even used different IORs for the RGB colors to get real world results.