The Lessons

I’ve been creating a series of lessons as a way of teaching myself WebGL. The first ten are based on the well-known NeHe OpenGL tutorials, but I’ve diverged since then. Here are the ones so far.

Lesson 0 thumbnail Lesson 0: Getting Started shows you how to download, install and configure a web browser that can show WebGL content, and gives links to a set of pages that show what it can do.
Lesson 1 thumbnail Lesson 1: A Triangle and a Square gives you an overview of how WebGL works, with enough code to simply draw a static triangle and a square on the screen.
Lesson 2 thumbnail Lesson 2: Adding Colour builds on lesson 1, and adds colour to the triangle and the square.
Lesson 3 thumbnail Lesson 3: A Bit of Movement builds on lesson 2, making the triangle and the square spin around.
Lesson 4 thumbnail Lesson 4: Some Real 3D Objects builds on lesson 3, bringing us into the third dimension fully by replacing the triangle with a pyramid and the square with a cube.
Lesson 5 thumbnail Lesson 5: Introducing Textures shows how you can use an image file to “skin” your 3D objects, giving you a quick and easy way to make them look more interesting.
Lesson 6 thumbnail Lesson 6: Keyboard Input and Texture Filters builds on lesson 6, showing you some more advanced ways to use textures, and also gives some pointers on how to read the keyboard in a way appropriate for 3D scenes and for games.
Lesson 7 thumbnail Lesson 7: Basic Directional and Ambient Lighting introduces the two simplest forms of lighting.
Lesson 8 thumbnail Lesson 8: The Depth Buffer, Transparency and Blending shows one way in which you can simulate transparent materials in WebGL, teaching you a little more theory along the way.
Lesson 9 thumbnail Lesson 9: Improving the Code Structure With Lots of Moving Objects uses simple object-oriented techniques to give us number of independently-animated objects moving around the screen at the same time.
Lesson 10 thumbnail Lesson 10: Loading a World, and the Most Basic Kind of Camera uses techniques from the previous lesson, along with a new trick to simulate a camera that moves around the scene, and demonstrates a kind of nano-Doom :-)
Lesson 11 thumbnail Lesson 11: Spheres, Rotation Matrices, and Mouse Events shows how to draw spheres, and how to write code so that the user can spin them using the mouse.
Lesson 12 thumbnail Lesson 12: point lighting shows how implement lighting that seems to come from points within your 3D scene.
Lesson 13 thumbnail WebGL Lesson 13: per-fragment lighting and multiple programs describes a way of doing more realistic lighting at the cost of more processing time for the graphics card.
Lesson 14 thumbnail WebGL Lesson 14: specular highlights and loading a JSON model makes the lighting even better by adding specular highlights, and also shows how to use load up models of 3D objects from JSON files.
Lesson 15 thumbnail WebGL Lesson 15: specular maps shows how to use specular maps, which give your scenes greater realism by making it easy to specify how reflective an object is at every point on its surface, just as normal textures allow you to specify its detailed colour.

23 Responses to “The Lessons”

  1. [...] being said, there are already tutorials popping up, and Khronos has a page showing off some live examples of what’s being done with the [...]

  2. [...] tutorials can be found here. My code is based entirely on his excellent work.  Please be aware that since he posted his [...]

  3. [...] WebGL Tutorials (Inglese) January 28th, 2010 in WebGL | tags: WebGL [...]

  4. [...] Learning WebGL (tags: 3d browser html5 learning programming tutorial webdev) [...]

  5. R4Y says:

    Long time no see.

    Wow, Much more Nice Lessons than several months ago.

    I am back to learn.

    Keep going~~!

  6. Varun says:

    Thanks for Great tutorial :)
    I really appreciate the work done by the author for providing such explanatory tutorial to get started with OpenGL ES 2.0 and Webgl.

    Thanks again…….

  7. giles says:

    Thanks, guys!

  8. Varun says:

    Any chances of a tutorial that explains text rendering?

  9. giles says:

    @Varun — check out http://murfy.de/read/webgl-text-rendering

    (I’ll do one of my own sometime, though.)

  10. [...] 学习webGL资讯比较全的网站 http://learningwebgl.com/blog/ 一系列课程: http://learningwebgl.com/blog/?page_id=1217 从这个课程中翻译的中文资料(只有3章) [...]

  11. [...] if you want to know more about WebGL and are  going to do some lessons, [...]

  12. Vani says:

    Great Lessons and its a good start for me!!!

  13. [...] WebGL es un interesante estándar que permite con JS y desde el navegador, sin necesidad de plugins usar gráficos 3D acelerados por hardware con OpenGL 2.0, en esta pagina podremos desde ya aprender a como usar WebGL [...]

  14. giles says:

    Thanks, Vani — glad you like the lessons!

  15. Tad says:

    Thanks for the tutorials — I’m working on an astronomy education project. I’m something of a beginner at JavaScript, and I’m wondering how I can move the fragment/vertex shaders to an external file. Thanks in advance for your time!

  16. giles says:

    Hi Tad — if you look at the way lesson 10 uses to load up the world file using XmlHttpRequest, you could probably adapt getShader/initShaders so that they use something similar.

  17. [...] unlike OpenGL in C++, you must write your own shader programs; I suggest using samples from learningwebgl.com at least to get started. However, once you have a functioning WebGL canvas, it is easy to pick up [...]

  18. Nathan says:

    These are great tutorials. I appreciate the effort, I have been working through them and yesterday all of the images on animated objects worked, but today they don’t? I noticed this as I was just about to start lesson 7, and clicked a couple others. L6 seems to still show crate.gif, but anything that rotates does not show the image. I am guessing there was another “demo breaking” update.

  19. Nathan says:

    I have noticed that going through your tutorials, when I remove the generateMipmap, and use gl.LINEAR only, they are starting to work. Looks like something changed with the MIPMAP?

    Where do you monitor changes in the code that could potentially break demos?

  20. giles says:

    Hi Nathan,

    Glad you like the lessons, sorry to hear that they’re not working for you. I track changes to the spec on the “Public WebGL” list, where the working group discuss a lot of the changes they’re making. I don’t think anything new has his the spec since Chrome dropped the WebGLXXXArray array types. However, I updated everything to match this change on the 16th, which I see is when you made this comment — so perhaps you just need to upgrade your browser?

    Cheers,

    Giles

  21. giles says:

    Nathan — another possibility — on a different thread, pianom4n reports that he’s having a problem with mipmaps on a Radeon 4200 HD — sounds rather like what you mention in your second comment, and he was able to fix it up updating his drivers.

  22. Nathan says:

    Thanks for the tip, I put the MIMAP back in the code I was trying, and that works, as well as the textures loading on your site. I am trying to combine what I learn here with the O3D project. Thanks again!

  23. giles says:

    Cool, glad it helped!

Leave a Reply

Subscribe to RSS Feed Follow me on Twitter!