On this page, we will sketch a landscape like this using ray marching. Drawing shapes beyond simple geometries can provide very useful insights into applying the technique to anything.

このページでは、レイマーチングを使って下のような風景をスケッチします。単純で幾何学的な形でないものを描くことで、このテクニックをさまざまな対象に応用する際にとても役立つ知見が得られるでしょう。

I tried to keep the code as simple as possible while maintaining a good amount of details, but this page is still quite technical. If you are not familiar with 3D rendering with the ray marching technique, I recommend reading the following pages first.

十分なディテールを残しながらコードをシンプルに保つようにしましたが、それでもこのページはかなりテクニカルです。レイマーチングを使った3Dレンダリングに馴染みがない方は、まず以下のページをお読むことをお勧めします。

Signed distance functions 符号付き距離関数

Projection and 3D Rendering プロジェクションと3Dレンダリング

Reading “Raymarching - Primitives”

terrain.png

I also used Inigo Quilez's Shadertoy demo as a reference for writing this page. I highly recommend watching his video below, and hope that this page can help with understanding the demo code too.

このページを書くにはInigo Quilezのshadertoyデモも参考にしました。下の動画もぜひ見てください。このページがコードを読み解く役に立てばと思います。

Painting a Landscape with Mathematics

Defining the terrain

地形の定義

First, we need to define the terrain. We can use multiple layers of noise to create intricate ups and downs of the mountains.