PDA

View Full Version : Share data between shader programs



nickels
03-19-2010, 02:25 PM
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??

Dark Photon
03-19-2010, 04:17 PM
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?
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 (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=274066#Post2740 66) ( link (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&Number=274066#Post2740 66)), those're the options.

nickels
03-22-2010, 07:56 AM
Thanks, will research.