Book Image

GLSL Essentials

By : Jacobo Rodriguez
Book Image

GLSL Essentials

By: Jacobo Rodriguez

Overview of this book

Shader programming has been the largest revolution in graphics programming. OpenGL Shading Language (abbreviated: GLSL or GLslang), is a high-level shading language based on the syntax of the C programming language.With GLSL you can execute code on your GPU (aka graphics card). More sophisticated effects can be achieved with this technique.Therefore, knowing how OpenGL works and how each shader type interacts with each other, as well as how they are integrated into the system, is imperative for graphic programmers. This knowledge is crucial in order to be familiar with the mechanisms for rendering 3D objects. GLSL Essentials is the only book on the market that teaches you about shaders from the very beginning. It shows you how graphics programming has evolved, in order to understand why you need each stage in the Graphics Rendering Pipeline, and how to manage it in a simple but concise way. This book explains how shaders work in a step-by-step manner, with an explanation of how they interact with the application assets at each stage. This book will take you through the graphics pipeline and will describe each section in an interactive and clear way. You will learn how the OpenGL state machine works and all its relevant stages. Vertex shaders, fragment shaders, and geometry shaders will be covered, as well some use cases and an introduction to the math needed for lighting algorithms or transforms. Generic GPU programming (GPGPU) will also be covered. After reading GLSL Essentials you will be ready to generate any rendering effect you need.
Table of Contents (13 chapters)

Index

A

  • array / Arrays
  • attributes
    • used, in interface blocks / Example – using attributes in the interface blocks

B

  • basic lighting theory / Basic lighting theory
  • basic types / Basic types
  • break statement / Flow control
  • buffer keyword / Raw data computations

C

  • cast types / Castings and conversions
  • clipping / Geometry stages (per-vertex operations)
  • code comments / Code comments
  • compute shaders / Compute shaders
  • conversions / Castings and conversions
  • crowd of butterflies example / A crowd of butterflies

E

  • EmitVertex() function / Example – pass-thru shader
  • EndPrimitive() function / Example – pass-thru shader
  • examples
    • solid color mesh / Solid color mesh
    • interpolated colored mesh / Interpolated colored mesh
    • interpolators, using to compute texture coordinates / Using interpolators to compute the texture coordinates
    • Phong lighting / Phong lighting
    • pass-thru shader / Example – pass-thru shader
    • attributes, using in interface blocks / Example – using attributes in the interface blocks
  • execution model
    • about / Execution model, Execution model
    • fragment shader, terminating / Terminating a fragment shader
  • external stages / External stages

F

  • fill rate / Execution model
  • fixed design
    • and programmable design, difference between / Differences between fixed and programmable designs
  • Flat Shading / Basic lighting theory
  • flow control / Flow control
  • fragment shader
    • terminating / Terminating a fragment shader
  • fragment shaders / Fragment shaders
  • fragment stages / Fragment stages (per-fragment operations)
  • functions / Functions

G

  • geometry sample
    • drawing / Drawing a simple geometry sample
    • distorting / Distorting a geometry sample
    • interpolators, using / Using interpolators
  • geometry shader / Geometry stages (per-vertex operations)
  • geometry shaders / Geometry shaders
    • versus vertex shaders / Geometry shaders versus vertex shaders
  • geometry stages
    • vertex data / Geometry stages (per-vertex operations)
    • textures / Geometry stages (per-vertex operations)
    • vertex shader / Geometry stages (per-vertex operations)
    • geometry shader / Geometry stages (per-vertex operations)
    • clipping / Geometry stages (per-vertex operations)
    • perspective division / Geometry stages (per-vertex operations)
    • viewport transform / Geometry stages (per-vertex operations)
  • glDispatchCompute function / Render to texture example
  • gl_Position / Uniform variables
  • Gouraud Shading / Basic lighting theory
  • GPU
    • about / GPU, a vectorial and parallel architecture
  • graphics hardware
    • history / A brief history of graphics hardware
  • Graphics Rendering Pipeline
    • about / A brief history of graphics hardware
    • geometry stages / Geometry stages (per-vertex operations)
    • fragment stages / Fragment stages (per-fragment operations)
    • external stages / External stages
    • fixed and programmable designs, difference / Differences between fixed and programmable designs

I

  • input layout
    • options for / Inputs and outputs
  • inputs
    • about / Inputs and outputs
  • input variables / Other input variables
  • instructions / Instructions
  • interface blocks
    • about / Interface blocks
    • attributes, using / Example – using attributes in the interface blocks
  • interpolated colored mesh / Interpolated colored mesh
  • interpolators
    • about / Using interpolators
    • using / Using interpolators

L

  • Language basics
    • instructions / Instructions
    • basic types / Basic types
    • variable initializers / Variable initializers
    • vector operation / Vector and matrix operations
    • matrix operation / Vector and matrix operations
    • cast types / Castings and conversions
    • conversions / Castings and conversions
    • code comments / Code comments
    • flow control / Flow control
    • loops / Loops
    • structures / Structures
    • array / Arrays
    • functions / Functions
    • preprocessor / Preprocessor
  • layout keyword / Inputs and outputs
  • lighting example code / Lighting example code
  • loops / Loops

M

  • matrix operation / Vector and matrix operations

N

  • Normal mapping / Basic lighting theory

O

  • OpenGL
    • URL / The Language
  • OpenGL Shading Language (GLSL) / A brief history of graphics hardware
  • output layer
    • options for / Inputs and outputs
  • outputs
    • about / Inputs and outputs
  • output variables / Shader output variables

P

  • pass-thru shader / Example – pass-thru shader
  • perspective division / Geometry stages (per-vertex operations)
  • Phong lighting / Phong lighting
  • Phong lighting model
    • about / Basic lighting theory
  • Phong Shading / Basic lighting theory
  • position attribute / Interpolated colored mesh
  • preprocessor / Preprocessor
  • programmable design
    • and fixed design, difference between / Differences between fixed and programmable designs

R

  • raw data
    • computing / Raw data computations

S

  • shaders environment
    • about / The shader environment
  • shaders types
    • about / Types of shaders
    • vertex shaders / Vertex shaders
    • fragment shaders / Fragment shaders
    • geometry shaders / Geometry shaders
    • compute shaders / Compute shaders
  • shader variables
    • uniform variables / Uniform variables
    • input variables / Other input variables
    • output variables / Shader output variables
  • Simple lighting
    • basic lighting theory / Basic lighting theory
    • lighting example code / Lighting example code
  • solid color mesh / Solid color mesh
  • structures / Structures

T

  • texture example
    • rendering to / Render to texture example

U

  • uniform variables / Uniform variables, Uniform variables

V

  • variable initializers / Variable initializers
  • vector operation / Vector and matrix operations
  • vertex array object (VAO) / Vertex attributes
  • vertex attribute
    • about / Vertex attributes
    • examples / Vertex attributes
  • vertex data / Geometry stages (per-vertex operations)
  • vertex shader
    • about / Geometry stages (per-vertex operations)
  • Vertex shader input
    • vertex attribute / Vertex attributes
    • uniform variables / Uniform variables
  • Vertex shader output
    • about / Vertex shader outputs
  • vertex shaders / Vertex shaders
    • versus geometry shaders / Geometry shaders versus vertex shaders
  • viewport transform / Geometry stages (per-vertex operations)