proofread

pull/28/head
kynd 9 years ago
parent c754ed6385
commit b343e8b474

@ -3,25 +3,23 @@
Since shader programs are executed by pixel-by-pixel no matter how much you repeat a shape the number of calculations stays constant. This means that fragment shaders are particulary suitable for tile patterns.
シェーダーのプログラムはピクセルごとに処理するので同じ形を何度も繰り替えしたとしても計算の回数は一定に止まります。このことからフラグメントシェーダーはタイルのようなパターンに特に適していると言えます。
シェーダーのプログラムはピクセルごとに並列で処理されるので、同じ形を何度も繰り返したとしても計算の回数は一定に留まります。そのためフラグメントシェーダーはタイルのような繰り返しのパターンに特に適しています。
[ ![Nina Warmerdam - The IMPRINT Project (2013)](warmerdam.jpg) ](../edit.html#09/dots5.frag)
In this chapter we are going to apply what we've learned so far and repeat it along a canvas. Like in previous chapters, our strategy will be based on multiplying the space coordinates (between 0.0 and 1.0), so that the shapes we draw between the values 0.0 and 1.0 will be repeated to make a grid.
この章ではこれまでに学んだことを生かし、描画領域のなかで繰り返していきます。前章で行ったのと同様に、空間座標に対して掛け算を行い、0.0から1.0の間に掛かれた図形がグリッド状に繰り返されるようにします。
この章ではこれまでに学んだことを応用して、描画領域のなかで繰り返しを行います。前章で行ったのと同様に、空間座標に対して掛け算を行い、0.0 から 1.0 の間に掛かれた図形がグリッド状に反復されるようにします。
*"The grid provides a framework within which human intuition and invention can operate and that it can subvert. Within the chaos of nature, regular patterns provide a constrast and promise of order. From early patterns on pottery to geometric mosaics in Roman baths, people have long used grids to enhance their lives with decoration."* [*10 PRINT*, Mit Press, (2013)](http://10print.org/)
*「グリッドは人間の直感と創意が働く枠組み、構築と解体のためのフレームワークを提供します。
自然界のカオスの中に、規則的なパターンは対比と秩序の兆しをもたらします。
*「グリッドは人間の直感と創意が働く枠組み、構築と解体のためのフレームワークを提供します。自然界のカオスの中に、規則的なパターンは対比と秩序の兆しをもたらしてくれます。
草創期の陶芸品の模様からローマ時代の浴場の幾何学的なモザイクまで、長い間人々はグリッドを用い生活を豊かに彩ってきました。」*[*10 PRINT*, Mit Press, (2013)](http://10print.org/)
(訳注:そのまま訳すのが難しい文章だったため、本人に意図を確認して言葉を補いました。)
First let's remember the [```fract()```](../glossary/?search=fract) function. It returns the fractional part of a number, making ```fract()``` in essence the modulo of one ([```mod(x,1.0)```](../glossary/?search=mod)). In other words, [```fract()```](../glossary/?search=fract) returns the number after the floating point. Our normalized coordinate system variable (```st```) already goes from 0.0 to 1.0 so it doesn't make sense to do something like:
まず [```fract()```](../glossary/?search=fract) 関数を思い出しましょう。この関数はつまるところ1の剰余 [```mod(x,1.0)```](../glossary/?search=mod))と同等で、数値の少数部分を返します。言い換えれば [```fract()```](../glossary/?search=fract) は小数点以下の部分の数を返してくれます。正規化された座標 (```st```は既に0.0から1.0の間に収まっているので、下記のようなコードは意味を成しません。
まず [```fract()```](../glossary/?search=fract) 関数を思い出しましょう。この関数はつまるところ 1 の剰余 [```mod(x,1.0)```](../glossary/?search=mod))と同等です。言い換えれば [```fract()```](../glossary/?search=fract) は小数点以下の部分の数を返してくれます。正規化された座標(```st```)は既に 0.0 から 1.0 の間に収まっているので、下記のようなコードは意味を成しません。
```glsl
void main(){
@ -35,13 +33,13 @@ void main(){
But if we scale the normalized coordinate system up - let's say by three - we will get three sequences of linear interpolations between 0-1: the first one between 0-1, the second one for the floating points between 1-2 and the third one for the floating points between 2-3.
しかしここで正規化された座標系を拡大すると ー例えば3倍にしてみましょうー 0から1までの滑らかに変化する値の繰り返しを3つ得ることができます。1つ目は0から1までの値、2つ目は2から3までの値の少数部分、3つめは2から3までの値の少数部分です。
しかしここで、正規化された座標系を例えば3倍に拡大すると、0 から 1 までの滑らかに変化する値の繰り返しを3つ得ることができます。1つ目は 0 から 1 までの値、2つ目は 1 から 2 までの値の少数部分、3つ目は 2 から 3 までの値の少数部分です。
<div class="codeAndCanvas" data="grid-making.frag"></div>
Now it's time to draw something in each subspace, by uncommenting line 27. (Because we are multiplying equally in x and y the aspect ratio of the space doesn't change and shapes will be as expected.)
ここで、27行目のコメントを外して分割されたそれぞれの空間の中に何か描いてみましょう。xとyを等しく拡大しているので空間のアスペクト比は変わらず、期待した通りの形が描かれます。
さて、27行目のコメントを外して分割されたそれぞれの空間の中に何か描いてみましょう。xとyを等しく拡大しているので空間のアスペクト比は変わらず、期待した通りの形が描かれます。
Try some of the following exercises to get a deeper understanding:
@ -49,7 +47,7 @@ Try some of the following exercises to get a deeper understanding:
* Multiply the space by different numbers. Try with floating point values and also with different values for x and y.
* 空間にたいして違う数をかけてみましょう。少数部分を持つ数を試したり、xとyに違う数を掛けてみましょう。
* 空間にして違う数をかけてみましょう。少数部分を持つ数を試したり、xとyに違う数を掛けてみましょう。
* Make a reusable function of this tiling trick.
@ -57,7 +55,7 @@ Try some of the following exercises to get a deeper understanding:
* Divide the space into 3 rows and 3 columns. Find a way to know in which column and row the thread is and use that to change the shape that is displaying. Try to compose a tic-tac-toe match.
* 空間を3列3行に分割します。スレッドがどの列と行にいるのかを知る方法を考えて、表示する図形を変えてください。Tic-tac-toe×ゲームを描いてみましょう。
* 空間を3行3列に分割します。スレッドがどの行と列にいるのかを知る方法を考えて、表示する図形を変えてください。Tic-tac-toe×ゲームを描いてみましょう。
### Apply matrices inside patterns
@ -71,7 +69,7 @@ Since each subdivision or cell is a smaller version of the normalized coordinate
* Think of interesting ways of animating this pattern. Consider animating color, shapes and motion. Make three different animations.
* このパターンをアニメーションさせる面白いアイデアを考えてください。色、形、動きについて考えましょう。3種類の異なるアニメーションを作成してください。
* このパターンをアニメーションにする面白いアイデアを考えてください。色、形、動きの変化について考えましょう。3種類の異なるアニメーションを作成してください。
* Recreate more complicated patterns by composing different shapes.
@ -105,32 +103,34 @@ ____we have to fix these next two paragraphs together____
To determine if our thread is in an odd or even row, we are going to use [```mod()```](../glossary/?search=mod) of ```2.0``` and then see if the result is under ```1.0``` or not. Take a look at the following formula and uncomment the two last lines.
スレッドが奇数行か複数行かを求めるには、```2.0``` の剰余([```mod()```](../glossary/?search=mod) を拡大した座標系に対して用い値が1.0を下回るかどうかを見ます。下記のコードの最後の2行のコメントを外してましょう。
訳注このサンプルではxは0.0から1.0ではなく-4から4の範囲にすでに拡大されています。コメントを外すとxの整数部分が奇数になる、つまり ```mod(x, 2.0)``` が1.0以上になる場合にだけyが1.0になります。)
スレッドが偶数行か奇数行かを求めるには、2.0 の剰余([```mod()```](../glossary/?search=mod) )を、拡大した座標系に対して用い結果が 1.0 を下回るかどうかを見ます。下記のコードの最後の2行のコメントを外してましょう。
<div class="simpleFunction" data="y = mod(x,2.0);
// y = mod(x,2.0) < 1.0 ? 0. : 1. ;
// y = step(1.0,mod(x,2.0));"></div>
訳注このサンプルではxは 0.0 から 1.0 ではなく -4 から 4 の範囲にすでに拡大されています。コメントを外すとxの整数部分が奇数になる、つまり ```mod(x, 2.0)``` が 1.0 以上になる場合にだけyが 1.0 になります。)
As you can see we can use a [ternary operator](https://en.wikipedia.org/wiki/%3F:) to check if the [```mod()```](../glossary/?search=mod) of ```2.0``` is under ```1.0``` (second line) or similarly we can use a [```step()```](../glossary/?search=step) function which does that the same operation, but faster. Why? Although is hard to know how each graphic card optimizes and compiles the code, it is safe to assume that built-in functions are faster than non-built-in ones. Everytime you can use a built-in function, use it!
ご覧のとおり、``2.0``` の剰余([```mod()```](../glossary/?search=mod))が ```1.0```
を下回るかどうかの判定には、[三項演算子](https://ja.wikipedia.org/wiki/%E6%9D%A1%E4%BB%B6%E6%BC%94%E7%AE%97%E5%AD%90)2行目を使うか、 [```step()```](../glossary/?search=step) ー 3行目) を使ってより高速に処理を行うことができます。グラフィックスカードがどのように最適化されていてどのようにコードをコンパイルするのかを知るのは難しいことですが、組み込み関数はそうでない関数に比べて高速に処理されると考えて問題ありません。組み込み関数が使える場合には必ず使うようにしましょう。
見てのとおり、2.0 の剰余([```mod()```](../glossary/?search=mod))が 1.0
を下回るかどうかの判定には、[三項演算子](https://ja.wikipedia.org/wiki/%E6%9D%A1%E4%BB%B6%E6%BC%94%E7%AE%97%E5%AD%90)2行目を使うか、 [```step()```](../glossary/?search=step) 3行目) を使ってより高速に処理を行うこともできます。グラフィックカードがどのように最適化されていてどのようにコードをコンパイルするのかを知るのは難しいことですが、組み込み関数はそうでない関数に比べて高速に処理されると考えてまず問題ありません。組み込み関数が使える場合には必ず使うようにしましょう。
So now that we have our odd number formula we can apply an offset to the odd rows to give a *brick* effect to our tiles. Line 14 of the following code is where we are using the function to "detect" odd rows and give them a half-unit offset on ```x```. Note that for even rows, the result of our function is ```0.0```, and multiplying ```0.0``` by the offset of ```0.5``` gives an offset of ```0.0```. But on odd rows we multiply the result of our function, ```1.0```, by the offset of ```0.5```, which moves the ```x``` axis of the coordinate system by ```0.5```.
偶奇判定の式ができたので、これでタイルの奇数行をブロックらしく見せることができます。下記のコードの14行目の関数で、奇数行かどうかを判定して ```x``` をブロック半個分ずらしています。この関数は偶数行に対して ```0.0``` を返します。ブロック半個分の ```0.5``` をかけると結果は ```0.0```です。奇数行に対しては ```1.0``` を返すので ```0.5``` を掛けた結果、座標系をx軸方向に ```0.5``` だけ移動させることになります。
偶奇判定の式ができたので、これでタイルの奇数行をずらしてブロックらしく見せることができます。下記のコードの14行目の関数で、奇数行かどうかを判定して ```x``` をブロック半個分ずらしています。この行の [```step()```](../glossary/?search=step) は偶数行に対して ```0.0``` を返します。ブロック半個分の ```0.5``` をかけると結果は ```0.0```です。奇数行に対しては ```1.0``` を返すので ```0.5``` を掛けた結果、座標系をx軸方向に ```0.5``` だけ移動させることになります。
Now try uncommenting line 32 - this stretches the aspect ratio of the coordinate system to mimic the aspect of a "modern brick". By uncommenting line 40 you can see how the coordinate system looks mapped to red and green.
32行目のコメントを外してみましょう。こうすると座標系のアスペクト比が引き伸ばされて現代のブロックの比率になります。40行目のコメントを外すと座標系の様子が赤と緑の色で示されるのを見ることができます。
32行目のコメントを外してみましょう。こうすると座標系のアスペクト比が引き伸ばされて現代のブロックの比率になります。40行目のコメントを外すと座標系の様子が赤と緑で示されるのを見ることができます。
<div class="codeAndCanvas" data="bricks.frag"></div>
* Try animating this by moving the offset according to time.
* このサンプルを、時間とともにブロックをずらしていくことでアニメーションさせてください。
* このサンプルを、時間とともにブロックがずれていくアニメーションにしてください。
* Make another animation where even rows move to the left and odd rows move to the right.
@ -138,7 +138,7 @@ Now try uncommenting line 32 - this stretches the aspect ratio of the coordinate
* Can you repeat this effect but with columns?
* 行方向ではなく列方向に対して同じ効果を適応するできますか。
* 行方向ではなく列方向に対して同じ効果を適応することはできますか。
* Try combining an offset on ```x``` and ```y``` axis to get something like this:
@ -152,7 +152,7 @@ Now try uncommenting line 32 - this stretches the aspect ratio of the coordinate
Now that we've learned how to tell if our cell is in an even or odd row or column, it's possible to reuse a single design element depending on its position. Consider the case of the [Truchet Tiles](http://en.wikipedia.org/wiki/Truchet_tiles) where a single design element can be presented in four different ways:
升目が偶数行と奇数行(または列)どちらに当たるかの判定方法を学んだ今、デザイン要素を場所に応じて再利用することができます。
マス目が偶数行と奇数行(または列)どちらに当たるかの判定方法を学んだので、デザイン要素を場所に応じて再利用することができます。
同じデザイン要素が4種類の方法で使われる、[トルシェタイル](http://en.wikipedia.org/wiki/Truchet_tiles) を例として考えてみましょう。
![](truchet-00.png)
@ -165,7 +165,7 @@ By changing the pattern across tiles, it's possible to contruct an infinite set
Pay close attention to the function ```rotateTilePattern()```, which subdivides the space into four cells and assigns an angle of rotation to each one.
```rotateTilePattern()``` に注目してください。この関数は空間を4つの目に分割しそれぞれに回転の角度を割り当てます。
```rotateTilePattern()``` に注目してください。この関数は空間を4つのマス目に分割しそれぞれに回転の角度を割り当てます。
<div class="codeAndCanvas" data="truchet.frag"></div>
@ -179,7 +179,7 @@ Pay close attention to the function ```rotateTilePattern()```, which subdivides
* Code other patterns where the elements are rotated according to their position.
* 要素がその位置に応じて回転するパターンを作成してください。
* 要素が位置に応じて回転して配置される、新しいパターンを作成してください。
* Make a pattern that changes other properties according to the position of the elements.
@ -187,22 +187,22 @@ Pay close attention to the function ```rotateTilePattern()```, which subdivides
* Think of something else that is not necessarily a pattern where you can apply the principles from this section. (Ex: I Ching hexagrams)
* 必ずしも繰り返しのパターンではないもので、この項で学んだ原則を使える例を考えてください(例八卦の組み合わせの一覧)。
* 必ずしも繰り返しのパターンではないもので、この項で学んだ原則を使える例を考えてください(例八卦の組み合わせの一覧)。
<a href="../edit.html#09/iching-01.frag"><canvas id="custom" class="canvas" data-fragment-url="iching-01.frag" width="520px" height="200px"></canvas></a>
## Making your own rules
##
## 自分でルールを作る
Making procedural patterns is a mental exercise in finding minimal reusable elements. This practice is old; we as a species have been using grids and patterns to decorate textiles, floors and borders of objects for a long time: from meanders patterns in ancient Greece, to Chinese lattice design, the pleasure of repetition and variation catches our imagination. Take some time to look at [decorative](https://archive.org/stream/traditionalmetho00chririch#page/130/mode/2up) [patterns](https://www.pinterest.com/patriciogonzv/paterns/) and see how artists and designers have a long history of navigating the fine edge between the predictability of order and the surprise of variation and chaos. From Arabic geometrical patterns, to gorgeous African fabric designs, there is an entire universe of patterns to learn from.
規則によるパターン作りは、再利用可能な最小の要素を見つける頭の体操です。この行為自体は古くからあるもので、私たちの種はグリッドとパターンを織物や床をはじめ様々なものを装飾するために長い間利用してきました。曲がりくねった古代ギリシャの模様から中国の格子模様まで、繰り返しとその変奏をする楽しみはは私たちの想像力を捉えて来ました。ゆっくりと装飾的なパターン(例: [1](https://archive.org/stream/traditionalmetho00chririch#page/130/mode/2up) [2](https://www.pinterest.com/patriciogonzv/paterns/))を眺めて、芸術家とデザイナー達が予測可能な規則正しさと、驚きにあふれた変化とカオスの間の微妙な線を渡り歩いてきた様子を見てみましょう。アラブの幾何学的なパターンから、アフリカの生地のデザインまで、学ぶべき大きな世界がそこにあります。
規則によるパターン作りは、再利用可能な最小の要素を見つける頭の体操です。この行為自体は古くからあるもので、私たちの種はグリッドとパターンを織物や床をはじめ様々なものを装飾するために長い間利用してきました。曲がりくねった古代ギリシャの模様から中国の格子模様まで、反復と変化の楽しみは私たちの想像力をかきたててきました。装飾的なパターン([例1](https://archive.org/stream/traditionalmetho00chririch#page/130/mode/2up) [2](https://www.pinterest.com/patriciogonzv/paterns/))をゆっくりと眺めて、予測可能な規則正しさと、驚きにあふれた変化とカオスの間の微妙な線を芸術家やデザイナー達が渡り歩いてきた様子を見てみましょう。アラブの幾何学的なパターンから、アフリカの生地のデザインまで、学ぶべき大きな世界がそこにあります。
![Franz Sales Meyer - A handbook of ornament (1920)](geometricpatters.png)
With this chapter we end the section on Algorithmic Drawing. In the following chapters we will learn how to bring some entropy to our shaders and produce generative designs.
この章で「アルゴリズムで絵を描く」の説は終わりです。続く章ではある種の無秩序さをシェーダーに持ち込んでデザインを生成する方法について学びます。
この章で「アルゴリズムで絵を描く」のセクションは終わりです。続く章では多少の無秩序さをシェーダーに持ち込んでデザインを生成する方法について学びます。

@ -28,8 +28,8 @@
* アルゴリズムで絵を描く
* [シェイピング関数](05/?lan=jp)
* [色について](06/?lan=jp)
* [Shapes未訳](07/)
* [Matrices未訳](08/)
* [形について](07/?lan=jp)
* [二次元行列](08/?lan=jp)
* [Patterns未訳](09/)
* Generative designs

Loading…
Cancel
Save