THE EVOLUTION OF THE WEB

March, 2015 — SXSW INTERACTIVE — Austin, TX., U.S.A.
how will we create for the web of the future?

Hi

I'm CJ Gammon

caniuse.com

<h1>Header</h1>
<p>This is a paragraph.</p>
simplify the creation of more complex content
native vs web
performance

CPU

central processing unit

let's look at native

GPU

graphics processing unit

CPU vs GPU
let's use the
gpu in CSS
transform: translateZ(0);
we shouldn't have to resort to hacks
will-change: opacity;

graphics

high level extras

CSS & SVG

we need a 2d
drawing API
let's look at native

Core Graphics

2d Canvas

we need a lower
level graphics API
let's look at native

OpenGL

WebGL

webgl
with great power comes great complexity
webgl
var gl;

function initGL(canvas) {
	try {
		gl = canvas.getContext("experimental-webgl");
		gl.viewportWidth = canvas.width;
		gl.viewportHeight = canvas.height;
	} catch (e) {}
}

function getShader(gl, id) {
	var shaderScript = document.getElementById(id);
	if (!shaderScript) {
		return null;
	}

	var str = "";
	var k = shaderScript.firstChild;
	while (k) {
		if (k.nodeType == 3) {
			str += k.textContent;
		}
		k = k.nextSibling;
	}

	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);
	} else {
		return null;
	}

	gl.shaderSource(shader, str);
	gl.compileShader(shader);

	if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
		alert(gl.getShaderInfoLog(shader));
		return null;
	}

	return shader;
}

var shaderProgram;

function initShaders() {
	var fragmentShader = getShader(gl, "shader-fs");
	var vertexShader = getShader(gl, "shader-vs");

	shaderProgram = gl.createProgram();
	gl.attachShader(shaderProgram, vertexShader);
	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);
}

var squareVertexPositionBuffer;

function initBuffers() {

	squareVertexPositionBuffer = gl.createBuffer();
	gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer);
	vertices = [
		1.0,  1.0,  0.0,
		-1.0,  1.0,  0.0,
		1.0, -1.0,  0.0,
		-1.0, -1.0,  0.0
		];
	gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
 	squareVertexPositionBuffer.itemSize = 3;
	squareVertexPositionBuffer.numItems = 4;
}

function drawScene() {
	gl.viewport(0, 0, gl.viewportWidth, gl.viewportHeight);
	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);

	mat4.translate(mvMatrix, [0.0, 0.0, -7.0]);
	gl.bindBuffer(gl.ARRAY_BUFFER, squareVertexPositionBuffer);
	gl.vertexAttribPointer(shaderProgram.vertexPositionAttribute, 
		squareVertexPositionBuffer.itemSize, gl.FLOAT, false, 0, 0);
	setMatrixUniforms();
	gl.drawArrays(gl.TRIANGLE_STRIP, 0, squareVertexPositionBuffer.numItems);
}

function webGLStart() {
	var canvas = document.getElementById("mycanvas");
	initGL(canvas);
	initShaders();
	initBuffers();

 	gl.clearColor(0.0, 0.0, 0.0, 1.0);
	gl.enable(gl.DEPTH_TEST);

	drawScene();
}
webgl
let's simplify
three.js
canvas = document.getElementById('mycanvas');
renderer = new THREE.WebGLRenderer({canvas: canvas});
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(45, 500 / 500, 1, 1000);
light = new THREE.PointLight(0xffffff);
scene.add(light);

geometry = new THREE.CubeGeometry(1, 1, 1);
material = new THREE.MeshLambertMaterial();
cube = new THREE.Mesh(geometry, material);
cube.position.z = -7;
scene.add(cube);
				
renderer.render(scene, camera);
three.js
canvas = document.getElementById('mycanvas');
renderer = new THREE.WebGLRenderer({canvas: canvas});
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(45, 500 / 500, 1, 1000);
light = new THREE.PointLight(0xffffff);
scene.add(light);

geometry = new THREE.CubeGeometry(1, 1, 1);
material = new THREE.MeshLambertMaterial();
cube = new THREE.Mesh(geometry, material);
cube.position.z = -7;
scene.add(cube);

renderer.render(scene, camera);
three.js
canvas = document.getElementById('mycanvas');
renderer = new THREE.WebGLRenderer({canvas: canvas});
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(45, 500 / 500, 1, 1000);
light = new THREE.PointLight(0xffffff);
scene.add(light);

geometry = new THREE.CubeGeometry(1, 1, 1);
material = new THREE.MeshLambertMaterial();
cube = new THREE.Mesh(geometry, material);
cube.position.z = -7;
scene.add(cube);

renderer.render(scene, camera);
three.js
canvas = document.getElementById('mycanvas');
renderer = new THREE.WebGLRenderer({canvas: canvas});
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(45, 500 / 500, 1, 1000);
light = new THREE.PointLight(0xffffff);
scene.add(light);

geometry = new THREE.CubeGeometry(1, 1, 1);
material = new THREE.MeshLambertMaterial();
cube = new THREE.Mesh(geometry, material);
cube.position.z = -7;
scene.add(cube);

renderer.render(scene, camera);
three.js
canvas = document.getElementById('mycanvas');
renderer = new THREE.WebGLRenderer({canvas: canvas});
scene = new THREE.Scene();
camera = new THREE.PerspectiveCamera(45, 500 / 500, 1, 1000);
light = new THREE.PointLight(0xffffff);
scene.add(light);

geometry = new THREE.CubeGeometry(1, 1, 1);
material = new THREE.MeshLambertMaterial();
cube = new THREE.Mesh(geometry, material);
cube.position.z = -7;
scene.add(cube);

renderer.render(scene, camera);
three.js
examples are
your friends
hardware
get user media
gamepad api
gamepad api
leap motion
leap motion
hybrids
use the best tool
for the job

virtual reality

virtual reality

stereoscopic

virtual reality

webVR API

augmented reality

augmented reality

JSARToolkit

augmented reality
google street view
google street view?
review

animation,
graphics
& peripherals

libraries make it easier

designers?

custom tools

bit.ly/cameratool

blender

three.js plugin

Photoshop

generator

word girl

Flash

Custom Platforms

tools simplify
the complex

thanks

http://bit.ly/sxweb2015

@cjgammon

resources
The World Wide Web: A very short personal history What became of the Browser Editor MDN: requestAnimationFrame Greensock Animation Platform THREE.js Leap Motion THREE.js VR Renderer Mozilla VR Initiative Photoshop Generator Custom Workflows Flash Custom Platforms
@CJGAMMON
#adobeSXSW

Hi, this site tries to show off some cutting edge features that are not supported in your browser. Maybe try viewing it in chrome.
Thanks.