Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
WebGL Tutorial
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
최형택
WebGL Tutorial
Commits
50ca136a
Commit
50ca136a
authored
4 years ago
by
Hyung-Taik Choi
Browse files
Options
Downloads
Patches
Plain Diff
Update README
parent
cde9ba5a
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
README.md
+81
-16
81 additions, 16 deletions
README.md
with
81 additions
and
16 deletions
README.md
+
81
−
16
View file @
50ca136a
...
@@ -18,9 +18,9 @@
...
@@ -18,9 +18,9 @@
<a
href=
"#references"
>
References
</a>
•
<a
href=
"#references"
>
References
</a>
•
<a
href=
"#acknowledgements"
>
Acknowledgements
</a>
<a
href=
"#acknowledgements"
>
Acknowledgements
</a>
</p>
</p>
WebGL은 인터넷 브라우저 환경에서 OpenGL을 플러그인 도움 없이 공식적으로 사용할 수 있도록 Khronos Group에서 제정한 웹 그래픽스 API
입니다
.
WebGL은 인터넷 브라우저 환경에서 OpenGL을 플러그인 도움 없이 공식적으로 사용할 수 있도록 Khronos Group에서 제정한 웹 그래픽스 API
에요
.
2017년 2월에 OpenGL ES 3.0기반 WebGL 2.0이 공개됐
습니다
.
2017년 2월에 OpenGL ES 3.0기반 WebGL 2.0이 공개됐
어요
.
WebGL2에 입문하고자 하시는 분들을 위해 WebGL로 할 수 있는 다양한 것 중 가장 흥미로웠던 유체 시뮬레이션에 대한 튜토리얼
입니다
.
WebGL2에 입문하고자 하시는 분들을 위해 WebGL로 할 수 있는 다양한 것 중 가장 흥미로웠던 유체 시뮬레이션에 대한 튜토리얼
이에요
.
</div>
</div>
## Try Here
## Try Here
...
@@ -40,30 +40,57 @@
...
@@ -40,30 +40,57 @@
## Moving from WebGL1 to WebGL2
## Moving from WebGL1 to WebGL2
### `getContext`를 호출할 때 `webgl` 대신 `webgl2` 사용
### `getContext`를 호출할 때 `webgl` 대신 `webgl2` 사용
`var gl = someCanvas.getContext("webgl2");`
```
javascript
// WebGL1
var
gl
=
canvas
.
getContext
(
'
webgl
'
);
// WebGL2 @ script.js:121
var
gl
=
canvas
.
getContext
(
'
webgl2
'
);
```
### 부동 소수점 프레임버퍼 추가
WebGL1에선 부동 소수점 텍스처를 지원하는지 확인하기 위해
`OES_texture_float`
를 활성화 한 후 부동 소수점 텍스처를 생성하고 프레임버퍼에 추가해
`gl.checkFramebufferStatus`
를 호출해
`gl.FRAMEBUFFER_COMPLETE`
를 반환하는지 확인해야 했어요.
WebGL2에선
`EXT_color_buffer_float`
를 허용해주면
### WebGL1 확장의 WebGL2 표준화
### WebGL1 확장의 WebGL2 표준화
WebGL1:
아래 확장들이 표준에 편입됐어요.
-
Depth Textures (
`WEBGL_depth_texture`
)
-
Floating Point Textures (
`OES_texture_float/OES_texture_float_linear`
)
-
Half Floating Point Textures (
`OES_texture_half_float/- OES_texture_half_float_linear`
)
-
Vertex Array Objects (
`OES_vertex_array_object`
)
-
Standard Derivatives (
`OES_standard_derivatives`
)
-
Instanced Drawing (
`ANGLE_instanced_arrays`
)
-
UNSIGNED_INT indices (
`OES_element_index_uint`
)
-
Setting gl_FragDepth (
`EXT_frag_depth`
)
-
Blend Equation MIN/MAX (
`EXT_blend_minmax`
)
-
Direct texture LOD access (
`EXT_shader_texture_lod`
)
-
Multiple Draw Buffers (
`WEBGL_draw_buffers`
)
-
Texture access in vertex shaders
자주 사용되던
`OES_vertex_array_object`
를 예시로 확장 없이 사용하는 예시를 들어볼게요.
```
javascript
```
javascript
// WebGL1
var
ext
=
gl
.
getExtension
(
"
OES_vertex_array_object
"
);
var
ext
=
gl
.
getExtension
(
"
OES_vertex_array_object
"
);
if
(
!
ext
)
{
if
(
!
ext
)
{
// tell user they don't have the required extension or work around it
// tell user they don't have the required extension or work around it
}
else
{
}
else
{
var
someVAO
=
ext
.
createVertexArrayOES
();
var
someVAO
=
ext
.
createVertexArrayOES
();
}
}
// WebGL2
var
someVAO
=
gl
.
createVertexArray
();
```
```
WebGL2:
`var someVAO = gl.createVertexArray();`
### `GLSL 300 es` 사용
### `GLSL 300 es` 사용
사용하는 쉐이더를 GLSL 3.00 ES로 업그레이드 하면 좋다. 그러기 위해선 쉐이더 선언의 첫 줄이
`#version 300 es`
면 된다
. 반드시 첫 줄이여야 하기 때문에 주석이나 개행이 이루어지면 안
된다
.
사용하는 쉐이더를 GLSL 3.00 ES로 업그레이드 하면 좋다. 그러기 위해선 쉐이더 선언의 첫 줄이
`#version 300 es`
야 해요
. 반드시 첫 줄이여야 하기 때문에 주석이나 개행이 이루어지면 안
돼요
.
```
javascript
```
javascript
// BAD
!!!!
+---There's a new line here!
// BAD
+---There's a new line here!
// BAD
!!!!
V
// BAD
V
var
vertexShaderSource
=
`
var
vertexShaderSource
=
`
#version 300 es
#version 300 es
..
..
.
`
;
`
;
// GOOD
// GOOD
...
@@ -73,8 +100,47 @@ var vertexShaderSource = `#version 300 es
...
@@ -73,8 +100,47 @@ var vertexShaderSource = `#version 300 es
```
```
#### `attribute` 대신 `in` 사용
#### `attribute` 대신 `in` 사용
```
javascript
// WebGL1
attribute
vec4
a_position
;
attribute
vec2
a_texcoord
;
attribute
vec3
a_normal
;
// WebGL2
in
vec4
a_position
;
in
vec2
a_texcoord
;
in
vec3
a_normal
;
```
#### `varying` 대신 `in/out` 사용
#### `varying` 대신 `in/out` 사용
```
javascript
// WebGL1
varying
vec2
v_texcoord
;
varying
vec3
v_normal
;
// WebGL2
// Vertex Shader
out
vec2
v_texcoord
;
out
vec3
v_normal
;
// Framgent Shader
in
vec2
v_texcoord
;
in
vec3
v_normal
;
```
#### `gl_FragColor` 대신 원하는 변수명 사용 가능
#### `gl_FragColor` 대신 원하는 변수명 사용 가능
```
javascript
// WebGL1
gl_FragColor
=
vec4
(
1
,
0
,
0
,
1
);
// red
// WebGL2
out
vec4
myOutputColor
;
void
main
()
{
myOutputColor
=
vec4
(
1
,
0
,
0
,
1
);
// red
}
```
#### `texture2D` 대신 `texture` 사용
#### `texture2D` 대신 `texture` 사용
```
javascript
```
javascript
// WebGL1
// WebGL1
...
@@ -86,9 +152,8 @@ vec4 color1 = texture(u_some2DTexture, ...);
...
@@ -86,9 +152,8 @@ vec4 color1 = texture(u_some2DTexture, ...);
vec4
color2
=
texture
(
u_someCubeTexture
,
...);
vec4
color2
=
texture
(
u_someCubeTexture
,
...);
```
```
## License
## License
MIT License
###
MIT License
-
Linking: Permissive
-
Linking: Permissive
-
Distribution: Permissive
-
Distribution: Permissive
-
Modification: Permissive
-
Modification: Permissive
...
@@ -98,13 +163,13 @@ MIT License
...
@@ -98,13 +163,13 @@ MIT License
-
TM Grant: Manually
-
TM Grant: Manually
## References
## References
WebGL
2
###
WebGL
2.0
-
https://webgl2fundamentals.org/webgl/lessons/webgl2-whats-new.html
-
https://webgl2fundamentals.org/webgl/lessons/webgl2-whats-new.html
-
https://webgl2fundamentals.org/webgl/lessons/webgl1-to-webgl2.html
-
https://webgl2fundamentals.org/webgl/lessons/webgl1-to-webgl2.html
-
https://www.khronos.org/assets/uploads/developers/library/2017-webgl-webinar/Khronos-Webinar-WebGL-20-is-here_What-you-need-to-know_Apr17.pdf
-
https://www.khronos.org/assets/uploads/developers/library/2017-webgl-webinar/Khronos-Webinar-WebGL-20-is-here_What-you-need-to-know_Apr17.pdf
-
https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Using_Extensions
-
https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API/Using_Extensions
Open Source Licensing
###
Open Source Licensing
-
https://en.wikipedia.org/wiki/Comparison_of_free_and_open-source_software_licences
-
https://en.wikipedia.org/wiki/Comparison_of_free_and_open-source_software_licences
## Acknowledgements
## Acknowledgements
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment