Programming Shaders
The language in which shaders are programmed depends on the target environment. The official OpenGL and OpenGL ES shading language is OpenGL Shading Language, also known as GLSL, and the official Direct3D shading language is High Level Shader Language, also known as HLSL. However, Cg is a third-party shading language developed by Nvidia that outputs both OpenGL and Direct3D shaders.
Example: GLSL program for shading normals without light or texture
// Vertex Shader varying vec4 color; void main { // Treat the normal (x, y, z) values as (r, g, b) color components. color = vec4(clamp(abs((gl_Normal + 1.0) * 0.5), 0.0, 1.0), 1.0); gl_Position = ftransform; } // Fragment Shader varying vec4 color; void main { gl_FragColor = color; }Read more about this topic: Shader
Famous quotes containing the word programming:
“If there is a price to pay for the privilege of spending the early years of child rearing in the drivers seat, it is our reluctance, our inability, to tolerate being demoted to the backseat. Spurred by our success in programming our children during the preschool years, we may find it difficult to forgo in later states the level of control that once afforded us so much satisfaction.”
—Melinda M. Marshall (20th century)