O'Reilly logo

Mastering SFML Game Development by Raimondas Pupius

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Multi-pass shading

Much like C/C++ code, GLSL does support the use of data arrays. Using them can seem like an obvious choice to just push information about multiple light streams into the shader and have it all done in one pass. Unlike C++, however, GLSL needs to know the sizes of these arrays at compile time, which is very much like C. At the time of writing, dynamic size arrays aren't supported. While this information can put a damper on a naive plan of handling multiple light sources with ease, there are still options to choose from, obviously.

One approach to combat this may be to have a very large, statically sized array of data. Only some of that data would be filled in and the shader would process it by looping over the array while using ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required