SlideShare ist ein Scribd-Unternehmen logo
1 von 17
Downloaden Sie, um offline zu lesen
3 Di n the
    row  ser
http://madebyevan.com/webgl-water/
1994: VRML                  1994
Model & Hyperlink in Page   Rednex - Cotton Eye Joe
                            all-4-one - I swear


1997: VRML97                1997
Scripting & Interaction     Aqua - Barbie Girl
                            Hanson - mmmbop


2004: x3d                   2004
xml & skinning              Linkin Park - Numb
                            Outkast - hey ya!


2007: collada               2007
Intermediate format         DJ ötzi - ein Stern
                            Rihanna - Umbrella


2011: Webgl                 2011
in browser rendering        lady gaga - born this way
                            Justin bieber - Mistletoe
WebGL iss pl attform


OpenGL ES
   cros
      2d&3d API                           subset of Opengl
                                          “for mobile”




for JavaScript.                    ari,
                       chrome, saf a
                                     r
                        firefox, ope
St op
  an en              ss rm
                  ro fo
    dar          c t           ulti-
                    la       m

        OpenGL
        d         p                  age
                             l angu

            nd      wide
         ou 92
       ar 9        eg.   ly u
                              se,
          e1           wow
    si nc
WebGL uses
<canvas>
var ctx = canvas.
  getContext('experimental-webgl');
                                norm
                               is ‘2 al canv
                                    d’      as
WebGL runs on the
 graphics card.
1. Vertex Operations

2. Rasterization

3. Fragment operations

4. Framebuffer
Shaders
                                                    t
                                       pr ograms tha
                                                  gpu
                                       run on the




// -- The vertex shader                           // -- The fragment shader

// position attribute                             // a uniform saying which color
attribute vec3 aVertexPosition;                   uniform vec4 color;

// convert to world space                         void main(void) {
uniform mat4 worldMatrix;                            // color the pixel, YEAH!
                                                      gl_FragColor = color;
// convert to screen space                        }
uniform mat4 viewProjectionMatrix;
                                                                              o  lor
                                                                  returns a c
void main(void) {
   // which pixel is this
   gl_Position = viewProjectionMatrix *
     worldMatrix *
     vec4(aVertexPosition, 1.0);
}
                                            n
                          retu rns a positio
<script type="text/javascript" src="glMatrix-0.9.5.min.js"></script>

<script id="shader-fs" type="x-shader/x-fragment">                                                            var triangleVertexPositionBuffer;
    precision mediump float;                                                                                  var squareVertexPositionBuffer;

    void main(void) {                                                                                         function initBuffers() {
        gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0);                                                                  triangleVertexPositionBuffer = gl.createBuffer();
    }                                                                                                             gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer);
</script>                                                                                                         var vertices = [
                                                                                                                       0.0, 1.0, 0.0,
<script id="shader-vs" type="x-shader/x-vertex">                                                                      -1.0, -1.0, 0.0,
    attribute vec3 aVertexPosition;                                                                                    1.0, -1.0, 0.0
                                                                                                                  ];
    uniform mat4 uMVMatrix;                                                                                       gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
    uniform mat4 uPMatrix;                                                                                        triangleVertexPositionBuffer.itemSize = 3;
                                                                                                                  triangleVertexPositionBuffer.numItems = 3;
    void main(void) {
        gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0);                                          squareVertexPositionBuffer = gl.createBuffer();
    }                                                                                                             gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer);
</script>                                                                                                         vertices = [
                                                                                                                       1.0, 1.0, 0.0,
                                                                                                                      -1.0, 1.0, 0.0,
<script type="text/javascript">                                                                                        1.0, -1.0, 0.0,
                                                                                                                      -1.0, -1.0, 0.0
    var gl;                                                                                                       ];
    function initGL(canvas) {                                                                                     gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
        try {                                                                                                     squareVertexPositionBuffer.itemSize = 3;
            gl = canvas.getContext("experimental-webgl");                                                         squareVertexPositionBuffer.numItems = 4;
            gl.viewportWidth = canvas.width;                                                                  }
            gl.viewportHeight = canvas.height;
        } catch (e) {
        }                                                                                                     function drawScene() {
        if (!gl) {                                                                                                gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
            alert("Could not initialise WebGL, sorry :-(");                                                       gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
        }
    }                                                                                                             mat4.perspective(45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0, pMatrix);

                                                                                                                  mat4.identity(mvMatrix);
    function getShader(gl, id) {
        var shaderScript = document.getElementById(id);                                                           mat4.translate(mvMatrix, [-1.5, 0.0, -7.0]);
        if (!shaderScript) {                                                                                      gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer);
            return null;                                                                                          gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, triangleVertexPositionBuffer.itemSize, gl.FLOAT,
        }                                                                                                 false, 0, 0);
                                                                                                                  setMatrixUniforms();
        var str = "";                                                                                             gl.drawArrays(gl.TRIANGLES, 0, triangleVertexPositionBuffer.numItems);
        var k = shaderScript.firstChild;
        while (k) {
            if (k.nodeType == 3) {                                                                                mat4.translate(mvMatrix, [3.0, 0.0, 0.0]);
                str += k.textContent;                                                                             gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer);
            }                                                                                                     gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, squareVertexPositionBuffer.itemSize, gl.FLOAT,
            k = k.nextSibling;                                                                            false, 0, 0);
        }                                                                                                         setMatrixUniforms();
                                                                                                                  gl.drawArrays(gl.TRIANGLE_STRIP, 0, squareVertexPositionBuffer.numItems);
        var shader;                                                                                           }
        if (shaderScript.type == "x-shader/x-fragment") {
            shader = gl.createShader(gl.FRAGMENT_SHADER);
        } else if (shaderScript.type == "x-shader/x-vertex") {
            shader = gl.createShader(gl.VERTEX_SHADER);                                                       function webGLStart() {
        } else {                                                                                                  var canvas = document.getElementById("lesson01-canvas");
            return null;                                                                                          initGL(canvas);
        }                                                                                                         initShaders();
                                                                                                                  initBuffers();
        gl.shaderSource(shader, str);
        gl.compileShader(shader);                                                                                 gl.clearColor(0.0, 0.0, 0.0, 1.0);
                                                                                                                  gl.enable(gl.DEPTH_TEST);
        if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
            alert(gl.getShaderInfoLog(shader));                                                                   drawScene();
            return null;                                                                                      }
        }

        return shader;                                                                                    </script>
    }


    var shaderProgram;

    function initShaders() {

                                                                                                                                                            mpl                                 e
                                                                                                                                               “simple” exa
        var fragmentShader = getShader(gl, "shader-fs");
        var vertexShader = getShader(gl, "shader-vs");

        shaderProgram = gl.createProgram();
        gl.attachShader(shaderProgram, vertexShader);
                                                                                                                                             a
        gl.attachShader(shaderProgram, fragmentShader);
        gl.linkProgram(shaderProgram);

        if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) {
            alert("Could not initialise shaders");
        }

        gl.useProgram(shaderProgram);

        shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition");
        gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute);

        shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, "uPMatrix");
        shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, "uMVMatrix");
    }


    var mvMatrix = mat4.create();
    var pMatrix = mat4.create();

    function setMatrixUniforms() {
        gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix);
        gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix);
    }
Libraries &
Frameworks                                       e the ler
                                              mak simp
                                              code
http://senchalabs.github.com/philogl/
https://github.com/mrdoob/three.js/
http://www.ambiera.com/copperlicht/
http://www.khronos.org/webgl/wiki/Main_Page
Browser
Support   43%
http://www.chromeexperiments.com/detail/webgl-terrain/?f=webgl
http://www.ambiera.at/copperlicht/demos/demo_quakelevel_external.html
Summary
WebGL
3D in the Browser is nothing new.
WebGL is simple openGL that is rendered directly in the browser.
It uses the graphics card and is therefore very performant.

However the code can be complex and Ie does not support webgl at all.
They will probably want to push directx.
Material Used
            Banksy “Have a Break” http://www.flickr.com/photos/loungerie/4109421950/

            Banksy “Flowing off” http://www.flickr.com/photos/loungerie/4109420324/

         Banksy “They’re Coming” http://www.flickr.com/photos/97041449@N00/4115205218/

      Bansky “Tourqay Robot” http://en.wikipedia.org/wiki/File:Banksy_Torquay_robot_crop.jpg

                  Banksy “You have got to be kidding me” http://www.banksy.co.uk/

        Banksy “follow your Dream” http://www.flickr.com/photos/thomashawk/6343586111/

          Banksy “nola” http://www.flickr.com/photos/eddiedangerous/3045255243/

 Banksy “Flower Pollard Street” http://www.flickr.com/photos/eddiedangerous/1800573742/

Banksy “what are you looking at?” http://www.flickr.com/photos/nolifebeforecoffee/124659356/

   Banksy “Man and Picture of a dog” http://www.flickr.com/photos/atomicshed/141462789/

   Banksy “Anti-Capitalism for sale” http://www.flickr.com/photos/jcodysimms/246024687/
Material Used
       3d teapot model http://resumbrae.com/ub/dms423_f08/10/

 Metal Teapot http://www.flickr.com/photos/11273631@N08/2867342497/

 furry teapot http://www.flickr.com/photos/11273631@N08/2867342461/

 Television Icon http://thenounproject.com/noun/television/#icon-No416

 Graphics Card http://www.flickr.com/photos/43779660@N00/218093887/

 Banksy “under the Carpet” http://www.flickr.com/photos/acb/147223287/

  Boxing http://www.flickr.com/photos/51035655711@N01/2826228569/

Weitere ähnliche Inhalte

Was ist angesagt?

The Canvas API for Rubyists
The Canvas API for RubyistsThe Canvas API for Rubyists
The Canvas API for Rubyistsdeanhudson
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsTypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsAlfonso Peletier
 
openFrameworks 007 - GL
openFrameworks 007 - GL openFrameworks 007 - GL
openFrameworks 007 - GL roxlu
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax BasicsRichard Paul
 
Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume Laforge
Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume LaforgeGroovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume Laforge
Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume LaforgeGuillaume Laforge
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasSteve Purkis
 
Lexical environment in ecma 262 5
Lexical environment in ecma 262 5Lexical environment in ecma 262 5
Lexical environment in ecma 262 5Kim Hunmin
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Platonov Sergey
 
東急Ruby会議向け「rubyの細かい話」
東急Ruby会議向け「rubyの細かい話」東急Ruby会議向け「rubyの細かい話」
東急Ruby会議向け「rubyの細かい話」Masaya TARUI
 
openFrameworks 007 - graphics
openFrameworks 007 - graphicsopenFrameworks 007 - graphics
openFrameworks 007 - graphicsroxlu
 
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!bleis tift
 
Doc Parsers Api Cheatsheet 1 0
Doc Parsers Api Cheatsheet 1 0Doc Parsers Api Cheatsheet 1 0
Doc Parsers Api Cheatsheet 1 0Oleh Burkhay
 

Was ist angesagt? (20)

The Canvas API for Rubyists
The Canvas API for RubyistsThe Canvas API for Rubyists
The Canvas API for Rubyists
 
OpenGL 4.6 Reference Guide
OpenGL 4.6 Reference GuideOpenGL 4.6 Reference Guide
OpenGL 4.6 Reference Guide
 
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic LabsTypeScript - All you ever wanted to know - Tech Talk by Epic Labs
TypeScript - All you ever wanted to know - Tech Talk by Epic Labs
 
openFrameworks 007 - GL
openFrameworks 007 - GL openFrameworks 007 - GL
openFrameworks 007 - GL
 
OpenGL SC 2.0 Quick Reference
OpenGL SC 2.0 Quick ReferenceOpenGL SC 2.0 Quick Reference
OpenGL SC 2.0 Quick Reference
 
OpenGL 4.5 Reference Card
OpenGL 4.5 Reference CardOpenGL 4.5 Reference Card
OpenGL 4.5 Reference Card
 
Vulkan 1.1 Reference Guide
Vulkan 1.1 Reference GuideVulkan 1.1 Reference Guide
Vulkan 1.1 Reference Guide
 
mimikatz @ phdays
mimikatz @ phdaysmimikatz @ phdays
mimikatz @ phdays
 
Qt Rest Server
Qt Rest ServerQt Rest Server
Qt Rest Server
 
Javascript & Ajax Basics
Javascript & Ajax BasicsJavascript & Ajax Basics
Javascript & Ajax Basics
 
Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume Laforge
Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume LaforgeGroovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume Laforge
Groovy to infinity and beyond - GR8Conf Europe 2010 - Guillaume Laforge
 
Writing a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 CanvasWriting a Space Shooter with HTML5 Canvas
Writing a Space Shooter with HTML5 Canvas
 
Lexical environment in ecma 262 5
Lexical environment in ecma 262 5Lexical environment in ecma 262 5
Lexical environment in ecma 262 5
 
EGL 1.4 Reference Card
EGL 1.4 Reference CardEGL 1.4 Reference Card
EGL 1.4 Reference Card
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.
 
東急Ruby会議向け「rubyの細かい話」
東急Ruby会議向け「rubyの細かい話」東急Ruby会議向け「rubyの細かい話」
東急Ruby会議向け「rubyの細かい話」
 
openFrameworks 007 - graphics
openFrameworks 007 - graphicsopenFrameworks 007 - graphics
openFrameworks 007 - graphics
 
そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!そうだ、bf処理系作ろう!もちろんSQLで!
そうだ、bf処理系作ろう!もちろんSQLで!
 
OpenGL ES 3.1 Reference Card
OpenGL ES 3.1 Reference CardOpenGL ES 3.1 Reference Card
OpenGL ES 3.1 Reference Card
 
Doc Parsers Api Cheatsheet 1 0
Doc Parsers Api Cheatsheet 1 0Doc Parsers Api Cheatsheet 1 0
Doc Parsers Api Cheatsheet 1 0
 

Andere mochten auch

HTML5 Canvas - Let's Draw!
HTML5 Canvas - Let's Draw!HTML5 Canvas - Let's Draw!
HTML5 Canvas - Let's Draw!Phil Reither
 
An Introduction to Jquery
An Introduction to JqueryAn Introduction to Jquery
An Introduction to JqueryPhil Reither
 
Responsive Web Design Patterns
Responsive Web Design PatternsResponsive Web Design Patterns
Responsive Web Design PatternsPhil Reither
 
Docker: Fire your Sysadmin and use Docker to build, ship and run any app, any...
Docker: Fire your Sysadmin and use Docker to build, ship and run any app, any...Docker: Fire your Sysadmin and use Docker to build, ship and run any app, any...
Docker: Fire your Sysadmin and use Docker to build, ship and run any app, any...Phil Reither
 

Andere mochten auch (6)

HTML5 Canvas - Let's Draw!
HTML5 Canvas - Let's Draw!HTML5 Canvas - Let's Draw!
HTML5 Canvas - Let's Draw!
 
An Introduction to Jquery
An Introduction to JqueryAn Introduction to Jquery
An Introduction to Jquery
 
Responsive Web Design Patterns
Responsive Web Design PatternsResponsive Web Design Patterns
Responsive Web Design Patterns
 
Docker: Fire your Sysadmin and use Docker to build, ship and run any app, any...
Docker: Fire your Sysadmin and use Docker to build, ship and run any app, any...Docker: Fire your Sysadmin and use Docker to build, ship and run any app, any...
Docker: Fire your Sysadmin and use Docker to build, ship and run any app, any...
 
Web Design Trends 2014
Web Design Trends 2014Web Design Trends 2014
Web Design Trends 2014
 
Top 10 Web Design Trends for 2015
Top 10 Web Design Trends for 2015Top 10 Web Design Trends for 2015
Top 10 Web Design Trends for 2015
 

Ähnlich wie WebGL - 3D in your Browser

Modify code to change cube into pyramid.Javascriptuse strict.pdf
Modify code to change cube into pyramid.Javascriptuse strict.pdfModify code to change cube into pyramid.Javascriptuse strict.pdf
Modify code to change cube into pyramid.Javascriptuse strict.pdfsaxenaavnish1
 
How do I modify this code in order to create a rotating pyramid instea.pdf
How do I modify this code in order to create a rotating pyramid instea.pdfHow do I modify this code in order to create a rotating pyramid instea.pdf
How do I modify this code in order to create a rotating pyramid instea.pdfkrishnac481
 
1. Modify code to change cube into pyramid.2. Make the pyramid int.pdf
1. Modify code to change cube into pyramid.2. Make the pyramid int.pdf1. Modify code to change cube into pyramid.2. Make the pyramid int.pdf
1. Modify code to change cube into pyramid.2. Make the pyramid int.pdfalokopticalswatchco0
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGLChihoon Byun
 
Introduction to open gl in android droidcon - slides
Introduction to open gl in android   droidcon - slidesIntroduction to open gl in android   droidcon - slides
Introduction to open gl in android droidcon - slidestamillarasan
 
A Novice's Guide to WebGL
A Novice's Guide to WebGLA Novice's Guide to WebGL
A Novice's Guide to WebGLKrzysztof Kula
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfConint29
 
Learning WebGLで学ぶWebGL入門
Learning WebGLで学ぶWebGL入門Learning WebGLで学ぶWebGL入門
Learning WebGLで学ぶWebGL入門nakamura001
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3Droxlu
 
Unconventional webapps with gwt:elemental & html5
Unconventional webapps with gwt:elemental & html5Unconventional webapps with gwt:elemental & html5
Unconventional webapps with gwt:elemental & html5firenze-gtug
 
From OCaml To Javascript At Skydeck
From OCaml To Javascript At SkydeckFrom OCaml To Javascript At Skydeck
From OCaml To Javascript At SkydeckJake Donham
 
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.jsJS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.jsiMasters
 
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksBeginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksJinTaek Seo
 
The fallowing program shows the simple transformation #define GLEW.pdf
The fallowing program shows the simple transformation #define GLEW.pdfThe fallowing program shows the simple transformation #define GLEW.pdf
The fallowing program shows the simple transformation #define GLEW.pdfarwholesalelors
 
Swift - One step forward from Obj-C
Swift -  One step forward from Obj-CSwift -  One step forward from Obj-C
Swift - One step forward from Obj-CNissan Tsafrir
 
The JavaScript Programming Primer
The JavaScript  Programming PrimerThe JavaScript  Programming Primer
The JavaScript Programming PrimerMike Wilcox
 
Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfcontact41
 

Ähnlich wie WebGL - 3D in your Browser (20)

Modify code to change cube into pyramid.Javascriptuse strict.pdf
Modify code to change cube into pyramid.Javascriptuse strict.pdfModify code to change cube into pyramid.Javascriptuse strict.pdf
Modify code to change cube into pyramid.Javascriptuse strict.pdf
 
How do I modify this code in order to create a rotating pyramid instea.pdf
How do I modify this code in order to create a rotating pyramid instea.pdfHow do I modify this code in order to create a rotating pyramid instea.pdf
How do I modify this code in order to create a rotating pyramid instea.pdf
 
1. Modify code to change cube into pyramid.2. Make the pyramid int.pdf
1. Modify code to change cube into pyramid.2. Make the pyramid int.pdf1. Modify code to change cube into pyramid.2. Make the pyramid int.pdf
1. Modify code to change cube into pyramid.2. Make the pyramid int.pdf
 
Getting Started with WebGL
Getting Started with WebGLGetting Started with WebGL
Getting Started with WebGL
 
Introduction to open gl in android droidcon - slides
Introduction to open gl in android   droidcon - slidesIntroduction to open gl in android   droidcon - slides
Introduction to open gl in android droidcon - slides
 
A Novice's Guide to WebGL
A Novice's Guide to WebGLA Novice's Guide to WebGL
A Novice's Guide to WebGL
 
HTML5 Canvas
HTML5 CanvasHTML5 Canvas
HTML5 Canvas
 
I need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdfI need help with this assignment Ive gotten abit stuck with the cod.pdf
I need help with this assignment Ive gotten abit stuck with the cod.pdf
 
Learning WebGLで学ぶWebGL入門
Learning WebGLで学ぶWebGL入門Learning WebGLで学ぶWebGL入門
Learning WebGLで学ぶWebGL入門
 
openFrameworks 007 - 3D
openFrameworks 007 - 3DopenFrameworks 007 - 3D
openFrameworks 007 - 3D
 
Marat-Slides
Marat-SlidesMarat-Slides
Marat-Slides
 
3
33
3
 
Unconventional webapps with gwt:elemental & html5
Unconventional webapps with gwt:elemental & html5Unconventional webapps with gwt:elemental & html5
Unconventional webapps with gwt:elemental & html5
 
From OCaml To Javascript At Skydeck
From OCaml To Javascript At SkydeckFrom OCaml To Javascript At Skydeck
From OCaml To Javascript At Skydeck
 
JS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.jsJS Experience 2017 - Animações simples com o three.js
JS Experience 2017 - Animações simples com o three.js
 
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeksBeginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
Beginning direct3d gameprogramming09_shaderprogramming_20160505_jintaeks
 
The fallowing program shows the simple transformation #define GLEW.pdf
The fallowing program shows the simple transformation #define GLEW.pdfThe fallowing program shows the simple transformation #define GLEW.pdf
The fallowing program shows the simple transformation #define GLEW.pdf
 
Swift - One step forward from Obj-C
Swift -  One step forward from Obj-CSwift -  One step forward from Obj-C
Swift - One step forward from Obj-C
 
The JavaScript Programming Primer
The JavaScript  Programming PrimerThe JavaScript  Programming Primer
The JavaScript Programming Primer
 
Im looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdfIm looking for coding help I dont really need this to be explained.pdf
Im looking for coding help I dont really need this to be explained.pdf
 

Kürzlich hochgeladen

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Zilliz
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...apidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityWSO2
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 

Kürzlich hochgeladen (20)

Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
WSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering DevelopersWSO2's API Vision: Unifying Control, Empowering Developers
WSO2's API Vision: Unifying Control, Empowering Developers
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Platformless Horizons for Digital Adaptability
Platformless Horizons for Digital AdaptabilityPlatformless Horizons for Digital Adaptability
Platformless Horizons for Digital Adaptability
 
Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..Understanding the FAA Part 107 License ..
Understanding the FAA Part 107 License ..
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 

WebGL - 3D in your Browser

  • 1. 3 Di n the row ser
  • 3. 1994: VRML 1994 Model & Hyperlink in Page Rednex - Cotton Eye Joe all-4-one - I swear 1997: VRML97 1997 Scripting & Interaction Aqua - Barbie Girl Hanson - mmmbop 2004: x3d 2004 xml & skinning Linkin Park - Numb Outkast - hey ya! 2007: collada 2007 Intermediate format DJ ötzi - ein Stern Rihanna - Umbrella 2011: Webgl 2011 in browser rendering lady gaga - born this way Justin bieber - Mistletoe
  • 4. WebGL iss pl attform OpenGL ES cros 2d&3d API subset of Opengl “for mobile” for JavaScript. ari, chrome, saf a r firefox, ope
  • 5. St op an en ss rm ro fo dar c t ulti- la m OpenGL d p age l angu nd wide ou 92 ar 9 eg. ly u se, e1 wow si nc
  • 6. WebGL uses <canvas> var ctx = canvas. getContext('experimental-webgl'); norm is ‘2 al canv d’ as
  • 7. WebGL runs on the graphics card.
  • 8. 1. Vertex Operations 2. Rasterization 3. Fragment operations 4. Framebuffer
  • 9. Shaders t pr ograms tha gpu run on the // -- The vertex shader // -- The fragment shader // position attribute // a uniform saying which color attribute vec3 aVertexPosition; uniform vec4 color; // convert to world space void main(void) { uniform mat4 worldMatrix; // color the pixel, YEAH! gl_FragColor = color; // convert to screen space } uniform mat4 viewProjectionMatrix; o lor returns a c void main(void) { // which pixel is this gl_Position = viewProjectionMatrix * worldMatrix * vec4(aVertexPosition, 1.0); } n retu rns a positio
  • 10. <script type="text/javascript" src="glMatrix-0.9.5.min.js"></script> <script id="shader-fs" type="x-shader/x-fragment"> var triangleVertexPositionBuffer; precision mediump float; var squareVertexPositionBuffer; void main(void) { function initBuffers() { gl_FragColor = vec4(1.0, 1.0, 1.0, 1.0); triangleVertexPositionBuffer = gl.createBuffer(); } gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); </script> var vertices = [ 0.0, 1.0, 0.0, <script id="shader-vs" type="x-shader/x-vertex"> -1.0, -1.0, 0.0, attribute vec3 aVertexPosition; 1.0, -1.0, 0.0 ]; uniform mat4 uMVMatrix; gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); uniform mat4 uPMatrix; triangleVertexPositionBuffer.itemSize = 3; triangleVertexPositionBuffer.numItems = 3; void main(void) { gl_Position = uPMatrix * uMVMatrix * vec4(aVertexPosition, 1.0); squareVertexPositionBuffer = gl.createBuffer(); } gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer); </script> vertices = [ 1.0, 1.0, 0.0, -1.0, 1.0, 0.0, <script type="text/javascript"> 1.0, -1.0, 0.0, -1.0, -1.0, 0.0 var gl; ]; function initGL(canvas) { gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW); try { squareVertexPositionBuffer.itemSize = 3; gl = canvas.getContext("experimental-webgl"); squareVertexPositionBuffer.numItems = 4; gl.viewportWidth = canvas.width; } gl.viewportHeight = canvas.height; } catch (e) { } function drawScene() { if (!gl) { gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight); alert("Could not initialise WebGL, sorry :-("); gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); } } mat4.perspective(45, gl.viewportWidth / gl.viewportHeight, 0.1, 100.0, pMatrix); mat4.identity(mvMatrix); function getShader(gl, id) { var shaderScript = document.getElementById(id); mat4.translate(mvMatrix, [-1.5, 0.0, -7.0]); if (!shaderScript) { gl.bindBuffer(gl.ARRAY_BUFFER, triangleVertexPositionBuffer); return null; gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, triangleVertexPositionBuffer.itemSize, gl.FLOAT, } false, 0, 0); setMatrixUniforms(); var str = ""; gl.drawArrays(gl.TRIANGLES, 0, triangleVertexPositionBuffer.numItems); var k = shaderScript.firstChild; while (k) { if (k.nodeType == 3) { mat4.translate(mvMatrix, [3.0, 0.0, 0.0]); str += k.textContent; gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer); } gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, squareVertexPositionBuffer.itemSize, gl.FLOAT, k = k.nextSibling; false, 0, 0); } setMatrixUniforms(); gl.drawArrays(gl.TRIANGLE_STRIP, 0, squareVertexPositionBuffer.numItems); var shader; } if (shaderScript.type == "x-shader/x-fragment") { shader = gl.createShader(gl.FRAGMENT_SHADER); } else if (shaderScript.type == "x-shader/x-vertex") { shader = gl.createShader(gl.VERTEX_SHADER); function webGLStart() { } else { var canvas = document.getElementById("lesson01-canvas"); return null; initGL(canvas); } initShaders(); initBuffers(); gl.shaderSource(shader, str); gl.compileShader(shader); gl.clearColor(0.0, 0.0, 0.0, 1.0); gl.enable(gl.DEPTH_TEST); if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) { alert(gl.getShaderInfoLog(shader)); drawScene(); return null; } } return shader; </script> } var shaderProgram; function initShaders() { mpl e “simple” exa var fragmentShader = getShader(gl, "shader-fs"); var vertexShader = getShader(gl, "shader-vs"); shaderProgram = gl.createProgram(); gl.attachShader(shaderProgram, vertexShader); a gl.attachShader(shaderProgram, fragmentShader); gl.linkProgram(shaderProgram); if (!gl.getProgramParameter(shaderProgram, gl.LINK_STATUS)) { alert("Could not initialise shaders"); } gl.useProgram(shaderProgram); shaderProgram.vertexPositionAttribute = gl.getAttribLocation(shaderProgram, "aVertexPosition"); gl.enableVertexAttribArray(shaderProgram.vertexPositionAttribute); shaderProgram.pMatrixUniform = gl.getUniformLocation(shaderProgram, "uPMatrix"); shaderProgram.mvMatrixUniform = gl.getUniformLocation(shaderProgram, "uMVMatrix"); } var mvMatrix = mat4.create(); var pMatrix = mat4.create(); function setMatrixUniforms() { gl.uniformMatrix4fv(shaderProgram.pMatrixUniform, false, pMatrix); gl.uniformMatrix4fv(shaderProgram.mvMatrixUniform, false, mvMatrix); }
  • 11. Libraries & Frameworks e the ler mak simp code http://senchalabs.github.com/philogl/ https://github.com/mrdoob/three.js/ http://www.ambiera.com/copperlicht/ http://www.khronos.org/webgl/wiki/Main_Page
  • 15. Summary WebGL 3D in the Browser is nothing new. WebGL is simple openGL that is rendered directly in the browser. It uses the graphics card and is therefore very performant. However the code can be complex and Ie does not support webgl at all. They will probably want to push directx.
  • 16. Material Used Banksy “Have a Break” http://www.flickr.com/photos/loungerie/4109421950/ Banksy “Flowing off” http://www.flickr.com/photos/loungerie/4109420324/ Banksy “They’re Coming” http://www.flickr.com/photos/97041449@N00/4115205218/ Bansky “Tourqay Robot” http://en.wikipedia.org/wiki/File:Banksy_Torquay_robot_crop.jpg Banksy “You have got to be kidding me” http://www.banksy.co.uk/ Banksy “follow your Dream” http://www.flickr.com/photos/thomashawk/6343586111/ Banksy “nola” http://www.flickr.com/photos/eddiedangerous/3045255243/ Banksy “Flower Pollard Street” http://www.flickr.com/photos/eddiedangerous/1800573742/ Banksy “what are you looking at?” http://www.flickr.com/photos/nolifebeforecoffee/124659356/ Banksy “Man and Picture of a dog” http://www.flickr.com/photos/atomicshed/141462789/ Banksy “Anti-Capitalism for sale” http://www.flickr.com/photos/jcodysimms/246024687/
  • 17. Material Used 3d teapot model http://resumbrae.com/ub/dms423_f08/10/ Metal Teapot http://www.flickr.com/photos/11273631@N08/2867342497/ furry teapot http://www.flickr.com/photos/11273631@N08/2867342461/ Television Icon http://thenounproject.com/noun/television/#icon-No416 Graphics Card http://www.flickr.com/photos/43779660@N00/218093887/ Banksy “under the Carpet” http://www.flickr.com/photos/acb/147223287/ Boxing http://www.flickr.com/photos/51035655711@N01/2826228569/