diff --git a/README.md b/README.md index 80912b88a04b68de8876a041383dd00e045884f5..75639179d836abb63dc8a5c3a73720d8a8ab46f8 100644 --- a/README.md +++ b/README.md @@ -26,19 +26,6 @@ - 삼각형을 더 잘게자른다면, 굴곡이 더욱 자연스러워 질 것이다. <br><br> - ``` - varying mediump vec2 texCoord; - uniform sampler2D sampler2d; - void main(void) - { - gl_FragColor = texture2D(sampler2d, texCoord); - gl_FragColor.a = 1.0 ; - } - ``` - - - Vertex shader source code : attribute로 현재 vertex의정보와 각 vertex에서의 color및 texture의 uv vector정보가 있다. 또한, vertex들의 이동을 통해 object를 trasnformation 할 수 있는데, 이때 matrix의 곱의 형태로 사용되어진다. <br>texture의 uv vector는 varying으로 fragment에 전해진다. <br><br> - - ``` attribute highp vec3 myVertex; attribute highp vec4 myColor; @@ -55,6 +42,19 @@ texCoord = myUV; } ``` + + - Vertex shader source code : attribute로 현재 vertex의정보와 각 vertex에서의 color및 texture의 uv vector정보가 있다. 또한, vertex들의 이동을 통해 object를 trasnformation 할 수 있는데, 이때 matrix의 곱의 형태로 사용되어진다. <br>texture의 uv vector는 varying으로 fragment에 전해진다. <br><br> + + + ``` + varying mediump vec2 texCoord; + uniform sampler2D sampler2d; + void main(void) + { + gl_FragColor = texture2D(sampler2d, texCoord); + gl_FragColor.a = 1.0 ; + } + ``` - Fragment shader source code : vertex fragment로부터 varing을 통해 전달받은 texture의 uv vector를 통해 uniform 으로 선언된 texture를 mapping 할 수 있게 된다. <br> @@ -130,10 +130,22 @@ - vertex shader source code : 나머지는 이전에 보았던 texture mapping과 같지만, texture의 vector가 vec3로 dimension이 늘어난 것을 확인할 수 있다. x,y,z 가 모두 필요하기 때문에 vec3를 사용하여야한다. + ``` + precision mediump float; + varying highp vec3 texCoord; + uniform samplerCube Cube; + void main(void) + { + gl_FragColor = textureCube(Cube, normalize(texCoord)); + gl_FragColor.a = 1.0 ; + } + ``` + + - fragment shader source code : fragment shader에서는 vertex shader로 부터 받은 texture coordinate를 이용하여 texture mapping을 한다. 이때, sample2D로 정의하지않고, sampleCube로 정의해 주어 cube에 mapping하기 쉽도록 해준다. - ` + > 참고문헌 [webglfundamentals](https://webglfundamentals.org/webgl/lessons/webgl-cube-maps.html "webglfundamentals")