Data flow today! How to get information from your program into the graphics card! CPU program to shaders Vertex shader to Fragment shader Can't go from vertex shader to vertex shader Or fragment shader to fragment shader No sideways data movements! Vertex shaders go first, then fragment You can't control the order of vertex shaders Or fragment shaders Fine for 3D, hard for general purpose Computer shaders are also governed by rules First: Data Types in GLSL float int bool It does have double, in OpenGL 4.0+ Didn't before that Graphics cards are bad at 64-bit floating point AMD was ahead here least I looked No implicit conversion from float to int or int to float No requirement for particular bit sizes (up to the GPU manufacturer) But, int is at least 16 No bitwise operations vec2 (and 3 and 4), and ivec, and bvec Vectors have members x, y, z and w Also r, g, b, and a Also s, t, p, and q (for texture coordinates) "swizzling" Can also use array notation mat2, mat3, and mat4 Column-major Can treat it as an array of columns which are vectors Double-index works samplers: Won't make sense until we talk about textures struct and arrays work Constructor notation, NOT C static casts Qualifiers: const: Like in C attribute: Frequently changing, from application to vertex shader Can't modify these in the shader uniform: Infrequently changing, from application to either type of shader Can't modify these in the shader either varying: Information passed from a vertex shader to a fragment shader This is obsolete, but you might see these in older tutorials Replaced with in/out declarations Easy to update older shaders Vertex shader writes these, per vertex Fragment shader can read them, interpolated between vertices Fragment shader can't write these attribute, uniform, and varying have global scope in the shader Without a qualifier: "normal" Global scope is shared between shaders of a type (vertex or fragment) Other stuff: No goto or switch Calling: in, out, inout, but NOT by reference (copy at beginning and/or end) swizzling and vector components It's kind of a hassle to have the programs embedded in the C code. Loading from a file (we already did) We can change them without recompiling the program! Could have put it in a string Lab today: Make a Christmas Tree with Instanced Rendering! Don't add any more vertices for this, unless you want to make it non-flat 25% EC bonus on the assignment if you do make the tree non-flat Do the assignment normal first Make at least 10 layers I'll draw a picture of what I'm hoping for on the board Don't have to decorate the tree