Skip to content

Commit ca702ba

Browse files
committed
fixes for new lesson-builder
1 parent 2e132dc commit ca702ba

26 files changed

+120
-120
lines changed

webgl/lessons/ja/webgl-how-it-works.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,16 @@ trueにした場合、BYTE型 (-128 〜 127) なら-1.0 〜 +1.0 、UNSIGNED_BYT
333333
これで頂点ごとに1色につき4バイトしか必要なくなり、75%の節約になります。
334334
</p>
335335
<p>実際にコーディングしてみましょう。データの取り出し方を指定する部分は以下のコードになります。</p>
336-
<pre class="prettyprint showlinemods">
336+
<pre class="prettyprint showlinemods">{{#escapehtml}}
337337
var size = 4;
338338
* var type = gl.UNSIGNED_BYTE;
339339
* var normalize = true;
340340
var stride = 0;
341341
var offset = 0;
342342
gl.vertexAttribPointer(colorLocation, size, type, normalize, stride, offset);
343-
</pre>
343+
{{/escapehtml}}</pre>
344344
<p>バッファを色で塗りつぶす時は次のようにします。</p>
345-
<pre class="prettyprint showlinemods">
345+
<pre class="prettyprint showlinemods">{{#escapehtml}}
346346
// Fill the buffer with colors for the 2 triangles
347347
// that make the rectangle.
348348
function setColors(gl) {
@@ -365,7 +365,7 @@ function setColors(gl) {
365365
r2, b2, g2, 255]),
366366
gl.STATIC_DRAW);
367367
}
368-
</pre>
368+
{{/escapehtml}}</pre>
369369
<p>
370370
実行結果はこのようになります。
371371
</p>

webgl/lessons/ja/webgl1-to-webgl2.md

+6-6
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ var someVAO = gl.createVertexArray();
354354
<p>WebGL1とWebGL2の両方で実行したい場合は、いくつかの課題があります。</p>
355355
<p>1つの回避策は、初期化時にWebGL1の拡張機能をWebGLコンテキストにコピーする事です。そうすると残りのコードをそのままにできます。以下が例です。
356356
</p>
357-
<pre class="prettyprint">
357+
<pre class="prettyprint">{{#escapehtml}}
358358
const gl = someCanvas.getContext("webgl");
359359
const haveVAOs = getAndApplyExtension(gl, "OES_vertex_array_object");
360360

@@ -393,18 +393,18 @@ function getAndApplyExtension(gl, name) {
393393
}
394394
return ext;
395395
}
396-
</pre>
396+
{{/escapehtml}}</pre>
397397
<p>コードが両方で同じように動作するようになりました。例:</p>
398-
<pre class="prettyprint">
398+
<pre class="prettyprint">{{#escapehtml}}
399399
if (haveVAOs) {
400400
var someVAO = gl.createVertexArray();
401401
...
402402
} else {
403403
... do whatever for no VAOs.
404404
}
405-
</pre>
405+
{{/escapehtml}}</pre>
406406
<p>代替案は次のような事をしなければならないでしょう。</p>
407-
<pre class="prettyprint">
407+
<pre class="prettyprint">{{#escapehtml}}
408408
if (haveVAOs) {
409409
if (isWebGL2)
410410
someVAO = gl.createVertexArray();
@@ -415,7 +415,7 @@ if (haveVAOs) {
415415
} else {
416416
... do whatever for no VAOs.
417417
}
418-
</pre>
418+
{{/escapehtml}}</pre>
419419
<p>注意点: 特に頂点配列オブジェクトの場合、<a href="https://github.com/greggman/oes-vertex-array-object-polyfill">ポリフィルを使用する</a>事をお勧めします。
420420
VAOはほとんどのシステムで利用可能です。
421421
VAOが利用可能ではない場合、ポリフィルが処理しコードがシンプルになります。

webgl/lessons/ko/webgl-2d-drawimage.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ WebGL을 창의적으로 사용하기 위한 것이라는 점을 강조하고
467467
혹시 눈치챘을지 모르지만 우리는 위치 좌표에 사용한 단위 사각형은 정확히 텍스쳐 좌표의 단위
468468
사각형과 크기가 일치합니다. 따라서 우리는 위치좌표를 바로 텍스쳐 좌표로 사용할 수 있습니다.
469469
</p>
470-
<pre class="prettyprint showlinemods">
470+
<pre class="prettyprint showlinemods">{{#escapehtml}}
471471
#version 300 es
472472
in vec4 a_position;
473473
-in vec2 a_texcoord;
@@ -481,7 +481,7 @@ void main() {
481481
gl_Position = u_matrix * a_position;
482482
* v_texcoord = (u_textureMatrix * a_position).xy;
483483
}
484-
</pre>
484+
{{/escapehtml}}</pre>
485485
<p>
486486
이제 텍스쳐 좌표를 설정하는 코드를 삭제해도 됩니다. 삭제하더라도 이전과 완전히 동일하게 동작할 것입니다.
487487
</p>

webgl/lessons/ko/webgl-2d-vs-3d-library.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ WebGL(그리고 OpenGL ES 2.0+)도 3D 장면을 그릴 때 사용하긴 하지
2828

2929
three.js를 사용하는 경우 코드는 아래와 같습니다.
3030

31-
<pre class="prettyprint showlinemods">
31+
<pre class="prettyprint showlinemods">{{#escapehtml}}
3232
// 설정
3333
renderer = new THREE.WebGLRenderer({canvas: document.querySelector("#canvas")});
3434
c.appendChild(renderer.domElement);
@@ -64,15 +64,15 @@ three.js를 사용하는 경우 코드는 아래와 같습니다.
6464
light2 = new THREE.PointLight(0x0040ff, 2, 0);
6565
light2.position.set(-200, 100, 300);
6666
scene.add(light2);
67-
</pre>
67+
{{/escapehtml}}</pre>
6868

6969
그러면 아래와 같이 표시됩니다.
7070

7171
{{{example url="resources/three-js-cube-with-lights.html" }}}
7272

7373
OpenGL(ES가 아닌)을 사용해 2개의 조명과 육면체를 그리는 유사한 코드입니다.
7474

75-
<pre class="prettyprint showlinemods">
75+
<pre class="prettyprint showlinemods">{{#escapehtml}}
7676
// 설정
7777
glViewport(0, 0, width, height);
7878
glMatrixMode(GL_PROJECTION);
@@ -125,7 +125,7 @@ OpenGL(ES가 아닌)을 사용해 2개의 조명과 육면체를 그리는 유
125125
*/
126126

127127
glEnd();
128-
</pre>
128+
{{/escapehtml}}</pre>
129129

130130
이 두 예제를 작성하는데 있어서 거의 3D 수학 지식이 필요하지 않다는 것에 주목하십시오. WebGL과 비교해서요. WebGL로 그리기 위한 코드는 작성하지 않을겁니다.
131131
코드는 그렇게 길어지지는 않을겁니다. 코드 라인이 얼마나 필요한지가 중요한 것이 아닙니다.

webgl/lessons/ko/webgl-3d-orthographic.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -639,7 +639,7 @@ in vec4 a_position;
639639
in vec4 a_color;
640640
</pre>
641641
<p>둘 다 'vec4'지만, 우리가 버퍼에서 데이터를 가져오는 방법을 WebGL에 알려줄 때에는 아래와 같이 정의하였습니다.</p>
642-
<pre class="prettyprint showlinemods">
642+
<pre class="prettyprint showlinemods">{{#escapehtml}}
643643
// attribute에게 positionBuffer (ARRAY_BUFFER)로부터 데이터를 가져오는 법을 알려줍니다.
644644
var size = 3; // iteration마다 3 개의 component
645645
var type = gl.FLOAT; // 데이터는 32bit floats
@@ -658,7 +658,7 @@ var stride = 0; // 0 = 각 iteration마다 다음 색상값을 얻기 위
658658
var offset = 0; // 버퍼의 맨 앞부분부터 시작
659659
gl.vertexAttribPointer(
660660
colorAttributeLocation, size, type, normalize, stride, offset);
661-
</pre>
661+
{{/escapehtml}}</pre>
662662
<p>
663663
위에 써있는 '3'들은 버퍼에서 iteration마다, attribute마다 3개의 값을 가져오라는 뜻입니다.
664664
이래도 되는 이유는 WebGL의 정점 쉐이더는 입력하지 않는 값에 대해 기본값을 사용하기 때문입니다.

webgl/lessons/ko/webgl-how-it-works.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -278,16 +278,16 @@ attribute의 위치를 알게 되면 두개의 명령문을 실행합니다.
278278
정규화된 데이터의 가장 일반적인 용도는 색상입니다. 대부분의 경우 색상은 0.0에서 1.0 사이의 값으로 정의됩니다. 빨강, 초록, 파랑 그리고 알파에 대해 완전한 부동소수점을 사용하면 각 정점의 각 색상을 위해 16바이트를 사용하게 됩니다. 복잡한 geometry가 있는 경우 더 많은 바이트가 추가될 수 있습니다. 그 대신 색상들을 0이 0.0으로, 255가 1.0을 표현하는 UNSIGNED_BYTE로 변환 할 수 있습니다. 이제 정점당 색상에 4 바이트만 필요하므로 75%의 메모리 절감 효과가 있습니다.
279279
</p>
280280
<p>이를 위해 코드를 변경해 보겠습니다. WebGL에게 우리가 사용할 색상을 가져오는 방법을 알려줄 때, </p>
281-
<pre class="prettyprint showlinemods">
281+
<pre class="prettyprint showlinemods">{{#escapehtml}}
282282
var size = 4;
283283
* var type = gl.UNSIGNED_BYTE;
284284
* var normalize = true;
285285
var stride = 0;
286286
var offset = 0;
287287
gl.vertexAttribPointer(colorLocation, size, type, normalize, stride, offset);
288-
</pre>
288+
{{/escapehtml}}</pre>
289289
<p>그 다음 버퍼를 사용할 색상으로 채울때 입니다.</p>
290-
<pre class="prettyprint showlinemods">
290+
<pre class="prettyprint showlinemods">{{#escapehtml}}
291291
// 사각형을 구성하는 두 개의 삼각형의 색상으로 버퍼를 채움
292292
function setColors(gl) {
293293
// 2 개의 랜덤 색상 선택
@@ -309,7 +309,7 @@ function setColors(gl) {
309309
r2, b2, g2, 255]),
310310
gl.STATIC_DRAW);
311311
}
312-
</pre>
312+
{{/escapehtml}}</pre>
313313
<p>
314314
아래는 결과 예제입니다.
315315
</p>

webgl/lessons/ko/webgl-less-code-more-fun.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -439,19 +439,19 @@ objects.forEach(function(object) {
439439
<p>
440440
자바스크립트에 익숙하신 분은들 setter를 아래와 같이 직접 호출해서 사용할 수 있는지 궁금하실 겁니다.
441441
</p>
442-
<pre class="prettyprint">
442+
<pre class="prettyprint">{{#escapehtml}}
443443
// 초기화 시점에
444444
var uniformSetters = twgl.createUniformSetters(program);
445445

446446
// 그리는 시점에
447447
uniformSetters.u_ambient([1, 0, 0, 1]); // ambient color를 빨간색으로 설정.
448-
</pre>
448+
{{/escapehtml}}</pre>
449449
<p>이렇게 하는것이 좋지 않은 이유는 GLSL 프로그램을 작성할 때 셰이더를 변경하는 경우가 종종 생긴다는 겁니다. 주로 디버깅 목적으로요.
450450
예를들어 프로그램을 사용했더니 화면에 아무것도 보이지 않는다고 합시다.
451451
저같은 경우 이렇게 아무것도 나타나지 않을때 때 제일 먼저 하는 작업은 셰이더를 단순화 하는 것입니다.
452452
예를들어 프래그먼트 셰이더의 출력을 아주 간단하게 바꿔봅니다.
453453
</p>
454-
<pre class="prettyprint showlinemods">
454+
<pre class="prettyprint showlinemods">{{#escapehtml}}
455455
#version 300 es
456456
precision highp float;
457457

@@ -491,7 +491,7 @@ void main() {
491491
diffuseColor.a);
492492
* outColor = vec4(0,1,0,1); // &lt;!--- 단순한 초록색으로
493493
}
494-
</pre>
494+
{{/escapehtml}}</pre>
495495
<p><code>outColor</code>를 단색으로 설정하는 라인을 추가한 것에 주목하세요.
496496
대부분의 드라이버는 위쪽 라인의 코드들이 최종 결과에 영향을 주지 않는다는 것을 알아냅니다.
497497
그래서 모든 uniform들을 최적화합니다. 프로그램을 다시 실행하여 <code>twgl.createUniformSetters</code>를 호출하면 <code>u_ambient</code>를 위한 setter를 생성하지 못하고 위 코드에서 <code>uniformSetters.u_ambient()</code>를 호출하는 부분이 실패하면서 아래와 같은 메시지가 나타납니다.

webgl/lessons/ko/webgl-planar-projection-mapping.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -740,21 +740,21 @@ Geometry를 생성하는 것이 올바른 방법인데, 그렇지 않으면 2개
740740
<div class="webgl_bottombar">
741741
<h3>조건부 텍스처 참조</h3>
742742
<p>위의 프래그먼트 셰이더에서는 항상 두 개의 텍스처를 모두 읽게 됩니다.</p>
743-
<pre class="prettyprint"><code>
743+
<pre class="prettyprint"><code>{{#escapehtml}}
744744
vec4 projectedTexColor = texture(u_projectedTexture, projectedTexcoord.xy);
745745
vec4 texColor = texture(u_texture, v_texcoord) * u_colorMult;
746746

747747
float projectedAmount = inRange ? 1.0 : 0.0;
748748
gl_FragColor = mix(texColor, projectedTexColor, projectedAmount);
749-
</code></pre>
749+
{{/escapehtml}}</code></pre>
750750
<p>왜 아래와 같이 하지 않았을까요?</p>
751-
<pre class="prettyprint"><code>
751+
<pre class="prettyprint"><code>{{#escapehtml}}
752752
if (inRange) {
753753
gl_FragColor = texture(u_projectedTexture, projectedTexcoord.xy);
754754
} else {
755755
gl_FragColor = texture(u_texture, v_texcoord) * u_colorMult;
756756
}
757-
</code></pre>
757+
{{/escapehtml}}</code></pre>
758758
<p><a href="https://www.khronos.org/registry/OpenGL/specs/es/3.0/GLSL_ES_Specification_3.00.pdf">GLSL ES 3.0 명세의 Section 8.8</a>에 따르면</p>
759759
<blockquote>
760760
<h4>Texture Lookup Functions</h4>
@@ -767,7 +767,7 @@ derivatives are undefined within non-uniform control flow and for vertex texture
767767
다시 말해 텍스처를 사용하는 경우 항상 텍스처에 접근할 수 있어야 한다는 것입니다.
768768
결과를 조건부로 사용할 수는 있습니다.
769769
예를 들어 아래와 같이 작성하거나</p>
770-
<pre class="prettyprint"><code>
770+
<pre class="prettyprint"><code>{{#escapehtml}}
771771
vec4 projectedTexColor = texture(u_projectedTexture, projectedTexcoord.xy);
772772
vec4 texColor = texture(u_texture, v_texcoord) * u_colorMult;
773773

@@ -776,14 +776,14 @@ derivatives are undefined within non-uniform control flow and for vertex texture
776776
} else {
777777
gl_FragColor = texColor;
778778
}
779-
</code></pre>
779+
{{/escapehtml}}</code></pre>
780780
<p>아래와 같이 작성할 수 있습니다.</p>
781-
<pre class="prettyprint"><code>
781+
<pre class="prettyprint"><code>{{#escapehtml}}
782782
vec4 projectedTexColor = texture(u_projectedTexture, projectedTexcoord.xy);
783783
vec4 texColor = texture(u_texture, v_texcoord) * u_colorMult;
784784

785785
gl_FragColor = inRange ? projectedTexColor : texColor;
786-
</code></pre>
786+
{{/escapehtml}}</code></pre>
787787
<p>
788788
하지만 텍스처 접근 자체를 조건부로 만들 수는 없습니다.
789789
어떤 GPU에서는 작동될 수 있지만 모든 GPU에서 작동이 보장되지는 않습니다.

webgl/lessons/ko/webgl1-to-webgl2.md

+8-8
Original file line numberDiff line numberDiff line change
@@ -355,14 +355,14 @@ extension을 사용하는 것처럼 작성하시면 안되고 조금은 수정
355355
<div class="webgl_bottombar">
356356
<h3>WebGL1 extension을 WebGL2처럼 만들기</h3>
357357
<p>WebGL1의 extension에 있던 함수들은, WebGL2에서는 extension 없이 사용할 수 있습니다. 예를 들면, WebGL1에서는 아래와 같았지만</p>
358-
<pre class="prettyprint">
358+
<pre class="prettyprint">{{#escapehtml}}
359359
var ext = gl.getExtension("OES_vertex_array_object");
360360
if (!ext) {
361361
// tell user they don't have the required extension or work around it
362362
} else {
363363
var someVAO = ext.createVertexArrayOES();
364364
}
365-
</pre>
365+
{{/escapehtml}}</pre>
366366
<p>
367367
WebGL2 에서는 이렇죠.
368368
</p>
@@ -373,7 +373,7 @@ var someVAO = gl.createVertexArray();
373373
좀 어려울 수 있습니다.</p>
374374
<p>한 가지 해결 방법은, 초기화할 때 WebGL1 extension을 WebGL context에 복사하는 것입니다.
375375
그렇게 하면 나머지 코드는 그대로입니다. 예시:</p>
376-
<pre class="prettyprint">
376+
<pre class="prettyprint">{{#escapehtml}}
377377
const gl = someCanvas.getContext("webgl");
378378
const haveVAOs = getAndApplyExtension(gl, "OES_vertex_array_object");
379379

@@ -412,18 +412,18 @@ function getAndApplyExtension(gl, name) {
412412
}
413413
return ext;
414414
}
415-
</pre>
415+
{{/escapehtml}}</pre>
416416
<p>이제 이 코드는 WebGL1과 WebGL2 에서 대부분 똑같이 동작할 겁니다. 예시:</p>
417-
<pre class="prettyprint">
417+
<pre class="prettyprint">{{#escapehtml}}
418418
if (haveVAOs) {
419419
var someVAO = gl.createVertexArray();
420420
...
421421
} else {
422422
... do whatever for no VAOs.
423423
}
424-
</pre>
424+
{{/escapehtml}}</pre>
425425
<p>아니면 이런식으로 적어야겠죠.</p>
426-
<pre class="prettyprint">
426+
<pre class="prettyprint">{{#escapehtml}}
427427
if (haveVAOs) {
428428
if (isWebGL2)
429429
someVAO = gl.createVertexArray();
@@ -434,7 +434,7 @@ if (haveVAOs) {
434434
} else {
435435
... do whatever for no VAOs.
436436
}
437-
</pre>
437+
{{/escapehtml}}</pre>
438438
<p>참고: Vertex Array Objects를 사용하는 경우에는, <a href="https://github.com/greggman/oes-vertex-array-object-polyfill">polyfill</a>을 사용하는 것을 권장합니다. VAO는 대부분의 시스템에서 지원되지만, 지원하지 않는 몇 시스템에서는 polyfill로 해결할 수 있습니다.
439439
코드의 변경 없이 말이죠.</p>
440440
</div>

webgl/lessons/pt-br/webgl-2d-vs-3d-library.md

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ com luzes.
3535

3636
Aqui está o código em three.js para fazer isso
3737

38-
<pre class="prettyprint showlinemods">
38+
<pre class="prettyprint showlinemods">{{#escapehtml}}
3939
// Setup.
4040
renderer = new THREE.WebGLRenderer({canvas: document.querySelector("#canvas")});
4141
c.appendChild(renderer.domElement);
@@ -71,15 +71,15 @@ Aqui está o código em three.js para fazer isso
7171
light2 = new THREE.PointLight(0x0040ff, 2, 0);
7272
light2.position.set(-200, 100, 300);
7373
scene.add(light2);
74-
</pre>
74+
{{/escapehtml}}</pre>
7575

7676
e aqui é exibido.
7777

7878
{{{example url="resources/three-js-cube-with-lights.html" }}}
7979

8080
Aqui está o código similar em OpenGL (não ES) para exibir um cubo com 2 luzes.
8181

82-
<pre class="prettyprint showlinemods">
82+
<pre class="prettyprint showlinemods">{{#escapehtml}}
8383
// Setup
8484
glViewport(0, 0, width, height);
8585
glMatrixMode(GL_PROJECTION);
@@ -132,7 +132,7 @@ Aqui está o código similar em OpenGL (não ES) para exibir um cubo com 2 luzes
132132
*/
133133

134134
glEnd();
135-
</pre>
135+
{{/escapehtml}}</pre>
136136

137137

138138
Observe como precisamos quase nenhum conhecimento de matemática para 3D para qualquer um desses

0 commit comments

Comments
 (0)