Sign in to follow this  
Simon_Roth

Sending thousands of uniforms to a shader. (3.2 -4.0)

Recommended Posts

Simon_Roth    149
Hi

I'm trying to get a lot of light data into a shader to perform deferred lighting.

The lighting system populates the screen with 32*32 tiles, which are drawn instanced onto the screen. Each tile needs to be fed the data for 8 point lights.

I'm struggling to get my head around how to get the data to the shader in GLSL. Currently I have a large UBO with all the tile light arrays in, and can rebind the UBO at the correct data struct for each tile. However, when doing this, I can't use a single instanced call. So thats not fast enough.

Is there any way I can just bind the whole UBO? Trying to define a large array in GLSL (understandably) causes the shader not to link.

I know I can do this relatively easily by packing the data into a texture, but I'd like to know if there is a more intuative way that fits the uniform paradigm.

Share this post


Link to post
Share on other sites
elanthis    126
Texture buffer objects exist specifically to solve this problem. They're pretty straight forward to use and easy to look up on the OpenGL wiki.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this