Share data between shader programs

I am calling many shader programs or the same program over and over to draw my various models. I want to dispatch my lighting info (for several lights) to the shader program, but it seems wasteful to do this over and over.

How to send the data to the gpu once and then access it from the same shader on multiple calls and/or multiple shaders?

Is this what uniform blocks do?

I can envision using a texture to store the lighting info??

UBOs you mean? (Uniform Buffer Objects). Yes. Textures as well, including TBOs (Texture Buffer Objects) though the data values aren’t nicely identified and named for readable use in the shader (e.g. texelFetchBuffer( tex, 5 ).xyz, vs. the more readable LightHalfVector).

Until we get something like ARB_explicit_uniform_location ( link), those’re the options.

Thanks, will research.

This topic was automatically closed 183 days after the last reply. New replies are no longer allowed.