<aside> 💡
On this page, I will use SDF (signed distance function) based demos based on the code from 3D Rendering with Ray Marching レイマーチングによる3Dレンダリング. The setup is quite complex compared to the other articles, but the only parts that change are the map
function (where the 3D objects are placed in the scene) and the section after the comment //camera setup
in the main
function.
このページでは、3D Rendering with Ray Marching レイマーチングによる3Dレンダリングのコードを基にしたSDF(符号付き距離関数)ベースのデモを使います。セットアップは他の記事と比べて複雑ですが、変更が必要な箇所はmap
関数(3Dオブジェクトのシーン内配置)とmain
関数内の//camera setup
コメント以降の部分のみです。
The goal of this page is to understand how cameras in 3D graphics work and how they can be configured in general, so you don’t need to understand the other details of the demo. You can find the corresponding settings and functions in various tools such as OpenFrameworks, Three.js, TouchDesigner, After Effects, Blender, etc. — almost anywhere the concept of camera is implemented.
このページの目的は3Dグラフィックスにおけるカメラの仕組みと一般的な設定の理解なので、デモの他の詳細な部分は理解できなくても問題ありません。OpenFrameworks、Three.js、TouchDesigner、After Effects、Blenderなど、カメラの概念を実装しているほぼすべてのツールで、これらの設定や機能に相当するものを見つけることができます。
</aside>
To understand how cameras work, let's start from a pinhole camera, or camera obscura, which is the ancestor of cameras today. A camera obscura is basically a pinhole camera without a film. Camera obscura can come in different sizes, from a box you can hold to a room that you can go in. The name camera obscura means "dark room," so let's imagine a big one here.
カメラの仕組みを理解するために、まずはピンホールカメラ、または今のカメラの先祖にあたるカメラ・オブスクラから始めましょう。カメラ・オブスクラは、基本的にフィルムのないピンホールカメラのことです。手で持てる箱サイズから人が中に入れる部屋サイズまで、さまざまな大きさのものがあります。カメラ・オブスクラという名前は「暗い部屋」という意味なので、ここでは大きな部屋サイズのものを想像しましょう。
Inside a camera obscura it is very dark, with a single tiny hole in one wall. Light can only enter through this hole, creating an image of the outside on the opposite wall.
カメラ・オブスクラの中はとても暗く、壁に小さな穴が1つだけ開いています。光はこの穴からだけ入ってきて、反対側の壁に外の景色を映し出します。
The world outside is full of light. As we have seen when we are discussing environmental light, light bounces off and scatters around in all directions, and objects are lit by the light from all directions mixed together.
外の世界は光で満ちています。環境光についての議論で見たように、光はあらゆる向きに跳ね返って散らばり、あらゆる方向からの光が混ざり合って物体を照らしています。
What the small hole does is filter out all the light except for the rays that go through the small hole. So in a camera obscura, from each point on the image on the wall, you can pinpoint where exactly the light comes from, or the other way around, only the light from a single direction from the outside will light that point. And this is how such a simple device can create a very clear image of the outside.
小さな穴は、その点を通過する光線以外のすべての光を遮断するので、カメラ・オブスクラの壁に映った像のそれぞれの点に対して、光がどこから来ているのか正確に特定できます。逆に言えば、外部からの光は、ある特定の向きからでないとその点を照らすことができません。簡単な装置で外の景色をはっきりと映し出せるのはこのためです。
People used this to trace the image to create accurate pictures. Eventually, they invented a way to capture the image directly on a medium using different kinds of chemicals that react to the light, and that is the beginning of the camera as we know it today. The modern camera has far more complex sets of lenses and a digital sensor in the place of the film, but the fundamental mechanism is still exactly the same.
この像はトレースして正確な絵を描くために使われました。そのうちに光に反応する様々な化学物質を使って、像を直接媒体に定着させる方法が発明され、これが今のカメラの始まりとなりました。現代のカメラはより複雑なレンズのセットがあり、フィルムの代わりにデジタルセンサーを使っていますが、基本の仕組みは今でも全く同じです。