Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Save more on your purchases now! discount-offer-chevron-icon
Savings automatically calculated. No voucher code required.
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
GLSL Essentials

You're reading from   GLSL Essentials 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.

Arrow left icon
Product type Paperback
Published in Dec 2013
Publisher Packt
ISBN-13 9781849698009
Length 116 pages
Edition 1st Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Jacobo Rodriguez Jacobo Rodriguez
Author Profile Icon Jacobo Rodriguez
Jacobo Rodriguez
Arrow right icon
View More author details
Toc

Shader input and output variables


Until now, we've been speaking about the language itself; how it's similar to the C programming language, but focusing specially on the differences. That was only the language part. Now it's time to see some of the functional parts of GLSL and cover an important topic: the inputs and outputs of the shaders.

Uniform variables

Suppose, you want to create a shader that makes use of a simple light. Well, shaders don't know about lights or any other high-level concept. Shaders only know about math and programming. So, if the language doesn't have support for lights, how would I use the light's position or color in a shader?

You need to pass those variables from your application to your shader and perform the lighting calculations inside the shader.

A parameter that is passed from the application to the shaders is called a uniform variable. Those variables are always read-only (constant), global to the shaders that form the current executable program.

The procedure...

You have been reading a chapter from
GLSL Essentials
Published in: Dec 2013
Publisher: Packt
ISBN-13: 9781849698009
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $19.99/month. Cancel anytime