More of the Graphics Pipeline




CS116b/CS216

Chris Pollett

Jan 29, 2014

Outline

Introduction

Computing vertex coordinates in the Eye Frame

Setting up shaders.

Code to Send Matrices to a Shader

Example Vertex Shader

#version 130

uniform mat4 uProjMatrix;
uniform mat4 uModelViewMatrix;
uniform mat4 uNormalMatrix;

in vec3 aPosition;
in vec3 aNormal;

out vec3 vNormal;
out vec3 vPosition;

void main() {
  vNormal = vec3(uNormalMatrix * vec4(aNormal, 0.0));

  // send position (eye coordinates) to fragment shader
  vec4 tPosition = uModelViewMatrix * vec4(aPosition, 1.0);
  vPosition = vec3(tPosition);
  gl_Position = uProjMatrix * tPosition;
}

Setting up a Vertex Buffer

Drawing a Vertex Buffer