Graphics Reference
In-Depth Information
Summary
We have seen that GLSL is a language that looks familiar enough to be used
easily, but that it has a significant number of new features that make writing
shaders possible—and that are easy enough to use that it's straightforward to
get started by writing shaders that do interesting things. Like OpenGL, it has
enough capability that you will likely never run out of ways to add sophistica-
tion and new features to your shaders, or to create every effect that it can give
you. This chapter should familiarize you with the basic operation of GLSL and
should be a useful reference for you, but only when you actually begin to use
the language to write shaders will you really understand the graphical power
it gives you.
Exercises
1. For the following table of operator and operand type, indicate which
operator can legally operate on the operands given. For each one that is
legal, create an example of the two operands and show the result of the
operation.
Operator
Left Operand
Right Operand
Result
+
mat2
float
:
+
vec3
ivec3
:
*
vec2
mat2
:
*
mat3x4
mat4x3
:
2. For the following table of functions and parameter type(s), indicate
whether the function can legally act on the parameter(s) given. For each
case where the function can legally act, identify the type of the return
value, give an example of the function applied to the parameter(s) and
show the returned value of the function.
Function name
Parameter(s)
a.
pow
vec4, vec4
b.
mod
vec3, float
c.
cross
vec3, vec3
d.
outerProduct
mat2x3, mat3x4
e.
notEqual
float, vec4
 
Search WWH ::




Custom Search