GLSL Essentials

Book description

If you’re involved in graphics programming, you need to know about shaders, and this is the book to do it. A hands-on guide to the OpenGL Shading Language, it walks you through the absolute basics to advanced techniques.

  • Learn about shaders in a step-by-step, interactive manner
  • Create stunning visual effects using vertex and fragment shaders
  • Simplify your CPU code and improve your overall performance with instanced drawing through the use of geometry shaders

In Detail

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

  1. GLSL Essentials
    1. Table of Contents
    2. GLSL Essentials
    3. Credits
    4. About the Author
    5. About the Reviewers
    6. www.PacktPub.com
      1. Support files, eBooks, discount offers and more
        1. Why Subscribe?
        2. Free Access for Packt account holders
    7. Preface
      1. What this book covers
      2. What you need for this book
      3. Who this book is for
      4. Conventions
      5. Reader feedback
      6. Customer support
        1. Downloading the color images of this book
        2. Errata
        3. Piracy
        4. Questions
    8. 1. The Graphics Rendering Pipeline
      1. A brief history of graphics hardware
      2. The Graphics Rendering Pipeline
        1. Geometry stages (per-vertex operations)
        2. Fragment stages (per-fragment operations)
        3. External stages
        4. Differences between fixed and programmable designs
      3. Types of shaders
        1. Vertex shaders
        2. Fragment shaders
        3. Geometry shaders
        4. Compute shaders
      4. GPU, a vectorial and parallel architecture
      5. The shader environment
      6. Summary
    9. 2. GLSL Basics
      1. The Language
      2. Language basics
        1. Instructions
        2. Basic types
        3. Variable initializers
        4. Vector and matrix operations
        5. Castings and conversions
        6. Code comments
        7. Flow control
        8. Loops
        9. Structures
        10. Arrays
        11. Functions
        12. Preprocessor
      3. Shader input and output variables
        1. Uniform variables
        2. Other input variables
        3. Shader output variables
      4. Summary
    10. 3. Vertex Shaders
      1. Vertex shader inputs
        1. Vertex attributes
        2. Uniform variables
      2. Vertex shader outputs
      3. Drawing a simple geometry sample
        1. Distorting a geometry sample
        2. Using interpolators
        3. Simple lighting
          1. Basic lighting theory
          2. Lighting example code
      4. Summary
    11. 4. Fragment Shaders
      1. Execution model
        1. Terminating a fragment shader
      2. Inputs and outputs
      3. Examples
        1. Solid color mesh
        2. Interpolated colored mesh
        3. Using interpolators to compute the texture coordinates
        4. Phong lighting
      4. Summary
    12. 5. Geometry Shaders
      1. Geometry shaders versus vertex shaders
      2. Inputs and outputs
        1. Interface blocks
        2. Example – pass-thru shader
        3. Example – using attributes in the interface blocks
        4. A crowd of butterflies
      3. Summary
    13. 6. Compute Shaders
      1. Execution model
      2. Render to texture example
      3. Raw data computations
      4. Summary
    14. Index

Product information

  • Title: GLSL Essentials
  • Author(s): Jacobo Rodríguez
  • Release date: December 2013
  • Publisher(s): Packt Publishing
  • ISBN: 9781849698009