Title: Shader Example
1Shader Example
- Ref GDC 2004 Bill Licea-Kane (ATI Research)
2Content
- Helloworld
- Brick (Ch.6, orangebook)
- Spheremap
- ShaderGen
3Shader Examples from Lighthouse3D
Hello World This pair of vertex/fragment shaders
is about the smallest pair we can write. It
performs only the standard vertex transformation,
and sets the same color for all pixels. It shows
several ways of achieving the vertex
transformation, and introduces the some of the
matrices provided available in GLSL.
Color Shader A simple example of how to get the
color specified in an OpenGL application, using
glColor, all the way to the fragment shader.
Flatten Shader This is a simple example of vertex
manipulation. It starts out by flattening a
teapot, and it ends up with a vertex shader that
animates a wavy teapot, based on a uniform
variable to keep track of time.
Toon Shader In this tutorial it will be shown the
impact of placing certain computations on the
vertex shader vs. the fragment shader. It uses
varying variables to establish communication
between shaders, and shows how to access an
OpenGL lights position.
Lighting Shaders Lighting according to the
"Mathematics of OpenGL" (chapter of the Red Book)
lighting is presented in here. The tutorials
starts with a directional light per vertex, i.e.
as in OpenGL fixed functionality, and then moves
on to per pixel implementations of directional,
point and spot lights, all according to the Red
Book equations.
Texturing This tutorial starts from basic
texturing, accessing texture coordinates and
texels, and moves on to a multitexturing example
where one of the texture units is applied to give
a glow in the dark effect.
4Sphere Map (from Spec)
5Sphere Map (Idea)
6Porting to Shaders
7Argument Normalization
Let caller normalize
8(No Transcript)
9(z1)
10(No Transcript)
11(x2y2z2)
12(No Transcript)
13Built-in Functions
14(No Transcript)
15M in Denominator only
16 pre-invert M
Multiplication better than division
17Constant Folding
18(No Transcript)
19Scale and Bias
20(No Transcript)
21Built-in Functions
22(No Transcript)
23Remove temporary scalar
24(No Transcript)
25Built-in?!
26(No Transcript)
27Function Parameters
28(No Transcript)
29Add terse comments
30(No Transcript)
31Homework
- Implement sphere map w/o shaders
- Implement sphere map w/ shaders
- Implement cubemap w/ and w/o shaders
- Implement dynamic cubemap