Playing around with fragment shaders in WebGL

WebGL is a graphics library for web browsers, based on a version of OpenGL for embedded devices, OpenGL ES. The library allows for customized real-time 3d graphics rendering in modern browsers, including the use of shaders. There is a variety of scenarios in which you would want to make use of such a library. Consider, for example, browser games, 3D maps and product views. The simple WebGL interface is accessible via JavaScript and even whole frameworks are available, such as three.js (for an introduction, see Johannes Brosi’s great article from earlier this month).

As Christmas holidays are approaching, it is nice to have some toys to play around with. In this tutorial, I will provide a basis for fiddling around and experimenting with WebGL and fragment shaders, since it turned out to be a lot of fun to play around with them, and the basic concept is relatively easy to grasp. This article basically follows my own way of coming to play around with fragment shaders in WebGL. The idea was generated shortly before the Mayflower/Liip Barcamp, where David Sora Parra and I organized a collaborative session in which we wanted to generate some coding fun by discovering the unknown together. Weiterlesen

Eine Einführung in ThreeJS (WebGL)

Auf PCs und Macs haben anspruchsvolle 3D-Grafiken schon vor einer ganzen Weile Einzug gehalten. In Form von Fotogalerien, Produktkonfiguratoren und -ansichten und natürlich in Form von Spielen. Auch der mobile Bereich ist technisch mittlerweile auf dem Stand, aufwendige 3D-Grafiken berechnen zu können.

Nun stellt sich bei der Planung einer entsprechenden Anwendung oder eines Spieles aber die Frage, auf welche Programmiersprachen und Frameworks gesetzt werden sollte. Insbesondere, wenn das Produkt dann auf mehreren Plattformen erscheinen soll.

Mit diesem Artikel möchte ich eine Einführung in das JavaScript-Framework ThreeJS geben und zeigen, wie einfach es sein kann, mit vertrauten Web-Werkzeugen und dem richtigen Framework durchaus auch anspruchsvollere 3D-Anwendungen zu schreiben. Am Beispiel von CocoonJS werde ich kurz erklären, wie diese dann nicht nur auf Desktop-Browsern, sondern auch auf mobilen Endgeräten genutzt und in die Stores gestellt werden können.

Weiterlesen