Lab 0

Due: Sunday, March 17th 2024, 23:59

Start Early!!!


Objectives:


Do the following before you proceed:


Goals:

Create a simple WebGL application. The focus is on setting up the Web GL pipeline and writing all the boilerplate code so that you can dive into the next lab without having to worry about Web GLs initialization.

Tasks:

Follow this guideline step-by-step. Make sure that you thoroughly test your program after each step so that you can find bugs easier and quicker.

Helpful Links

WebGL

A very good site to get started with WebGL is WebGL Fundamentals. There you can find a bunch of well-written tutorials, and also the source code for them.

The Mozilla Developer Network has also some code snippets and explanations to get started. There's also a list of further resources, including a beginner's tutorial.

The official WebGL site from Khronos Group could also be of interest (Especially the Specification in case you're looking for parameters etc.). They are also maintaining a wiki with a lot of useful information.

It is recommended to use an existing math and matrix library, so you don't have to code all the math functions your self. We used gl-matrix for our demos.

WebGL Demos

There is a list of demos in the Kronos maintained wiki.

Shadertoy is an interactive playground to toy around with shaders and realize amazing demos. It is all interactive, comes with (shader)sourcecode to all the demos and illustrates what is possible in shader programming. It might also crash your browser from time to time :D.

Google also has a page with WebGL Samples, and a great webgl-utils lib.

JavaScript

There are countless tutorials and resources for learning JavaScript accessible for free on the internet. A comprehensive tutorial that covers basic and advanced concepts can be found, for example, here.

Having a useful IDE or text editor can greatly enhance your productivity and help you find simple errors more easily. Most people already have a strong personal preference when it comes to IDEs - if you are not sure what to use, you can take a look at this site.

To play around a little bit and understand javascript, as well as interacting with css and html JSFiddle is a good starting point. You can interactively change your code, view the results and get some help in finding errors.

The binding of JavaScript.

Web Stuff

JavaScript wont allow you to read arbitrary files from your hard drive. While this is an important security feature, it gets into your way when writing WebGL applications that require loading resources like shaders, textures and object data.

You can work around this limitation by either telling your browser to ignore this security feature (not recommended) or to simply use a simple HTTP server while developing your application. One of the easiest ways of doing this is using Python, see this page for more info.

Another thing that might bite you is caching. HTTP allows for some caching at various locations, most notably in your browser. If your application behaves weirdly, try clearing the browser's cache, or maybe even restart the server.


Debugging

This will occupy some of your time. The main thing is to have a plan on how to debug your program. Start simple and build your program step-by-step, so you can debug each step and figure out whether there are errors in each step before you move on. Always use simple data sets at first. Google Chrome already comes with a set of tools for web development (Tools >> Developer Tools or Tools >> JavaScript Console). Be sure to get familiar with them, they are very handy.

As a general hint for debugging, there are a few principles that you can follow:

The Khronos WebGL wiki has a page about debugging as well.


Submission


Grading Criteria

Grading the labs will be based on the following:

In order to get a full mark, you need to do all of the assigned tasks AND adhere to lab procedures while creating readable and efficient code. I.e. if you accomplish only 70% of the tasks correctly, but you do not adhere to lab procedures, your final mark will be 70*(1-0.05) = 66.5%.