GLSL Essentials
eBook - ePub

GLSL Essentials

  1. 116 pages
  2. English
  3. ePUB (mobile friendly)
  4. Available on iOS & Android
eBook - ePub

GLSL Essentials

About this book

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.

Approach

This book is a practical guide to the OpenGL Shading Language, which contains several real-world examples that will allow you to grasp the core concepts easily and the use of the GLSL for graphics rendering applications.

Who this book is for

If you want upgrade your skills, or are new to shader programming and want to learn about graphic programming, this book is for you. If you want a clearer idea of shader programming, or simply want to upgrade from fixed pipeline systems to state-of-the-art shader programming and are familiar with any C-based language, then this book will show you what you need to know.

Tools to learn more effectively

Saving Books

Saving Books

Keyword Search

Keyword Search

Annotating Text

Annotating Text

Listen to it instead

Listen to it instead

Information

Year
2013
eBook ISBN
9781849698009
Edition
1

GLSL Essentials


Table of Contents

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

GLSL Essentials

Copyright © 2013 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information.
First published: December 2013
Production Reference: 1181213
Published by Packt Publishing Ltd.
Livery Place
35 Livery Street
Birmingham B3 2PB, UK.
ISBN 978-1-84969-800-9
www.packtpub.com
Cover Image by Jacobo RodrĂ­guez Villar ()

Credits

Author
Jacobo RodrĂ­guez
Reviewers
Dimitrios Christopoulos
Toni AscĂł GonzĂĄlez
Oscar Ripolles
Acquisition Editors
Antony Lowe
Rebecca Pedley
Commissioning Editors
Subho Gupta
Priyanka Shah
Sharvari Tawde
Technical Editors
Venu Manthena
Gaurav Thingalaya
Project Coordinator
Amey Sawant
Proofreaders
Maria Gould
Paul Hindle
Indexer
Priya Subramani
Graphics
Ronak Dhruv
Production Coordinator
Shantanu Zagade
Cover Work
Shantanu Zagade

About the Author

Jacobo RodrĂ­guez is a real-time computer graphics programmer living in the north of Spain. He has working experience with computer graphics, digital photogrammetry, computer vision, and video game development. Jacobo has worked for cutting-edge technology companies such as Metria Digital and Blit Software, and has also worked as an entrepreneur and freelancer for a variety of clients of platforms such as PC, iOS, PlayStation 3, PlayStation Vita, and PlayStation Portable. Jacobo has been working and learning at the same time for the last 20 years in the computer graphics field in roles ranging from junior programmer to project manager, passing through R&D director as well. Jacobo has always been very committed to the computer graphics community, having released for free the OpenGL Shader Designer: the first application in the world (even before NVIDIA with FX Composer or ATI with RenderMonkey) designed to visually develop and program GLSL shaders, as well as some OpenGL programming tutorials, all forming part of the Official OpenGL SDK.

About the Reviewers

Dimitrios Christopoulos studied Computer Engineering and Informatics and holds a Master of Science degree in Virtual Reality and Computer Graphics. He has 16+ years of experience in 3D computer graphics with a strong specialty in C/C++/OpenGL and Linux. Dimi has worked for European Union research projects, Indie game productions, and museums producing games, educational applications, and cultural heritage productions for desktops and virtual reality installations such as Domes, Caves, Reality Centers, and Powerwalls. His research interests include virtual reality, human computer interaction, computer graphics, and games, with numerous publications in relevant conferences and journals. Dimitrios has been an author of the book More OpenGL Programming, Course Technology PTR, and has contributed to OpenGL Programming, Prima Tech, and has been a reviewer for OpenGL Development Cookbook, Packt Publishing.
Toni AscĂł GonzĂĄlez holds a Master's degree in Computer Science specializing in real-time graphics and OpenGL. For the past 16 years, he has been programming graphics applications from virtual reality to video games. He founded a virtual reality company in Barcelona, and dedicated eight years to develop a state-of-the-art, real-time software for architectural visualization. After that experience, he moved to Bravo Game Studios and developed video games for mobile platforms and portable consoles. Currently, he applies his experience in 3D and real-time graphics in the virtual gambling field.

Table of contents

  1. GLSL Essentials

Frequently asked questions

Yes, you can cancel anytime from the Subscription tab in your account settings on the Perlego website. Your subscription will stay active until the end of your current billing period. Learn how to cancel your subscription
No, books cannot be downloaded as external files, such as PDFs, for use outside of Perlego. However, you can download books within the Perlego app for offline reading on mobile or tablet. Learn how to download books offline
Perlego offers two plans: Essential and Complete
  • Essential is ideal for learners and professionals who enjoy exploring a wide range of subjects. Access the Essential Library with 800,000+ trusted titles and best-sellers across business, personal growth, and the humanities. Includes unlimited reading time and Standard Read Aloud voice.
  • Complete: Perfect for advanced learners and researchers needing full, unrestricted access. Unlock 1.4M+ books across hundreds of subjects, including academic and specialized titles. The Complete Plan also includes advanced features like Premium Read Aloud and Research Assistant.
Both plans are available with monthly, semester, or annual billing cycles.
We are an online textbook subscription service, where you can get access to an entire online library for less than the price of a single book per month. With over 1 million books across 990+ topics, we’ve got you covered! Learn about our mission
Look out for the read-aloud symbol on your next book to see if you can listen to it. The read-aloud tool reads text aloud for you, highlighting the text as it is being read. You can pause it, speed it up and slow it down. Learn more about Read Aloud
Yes! You can use the Perlego app on both iOS and Android devices to read anytime, anywhere — even offline. Perfect for commutes or when you’re on the go.
Please note we cannot support devices running on iOS 13 and Android 7 or earlier. Learn more about using the app
Yes, you can access GLSL Essentials by Jacobo Rodriguez in PDF and/or ePUB format, as well as other popular books in Informatik & Computergraphiken. We have over one million books available in our catalogue for you to explore.