4
\$\begingroup\$

I'm trying to build a deferred rendering technique in an OpenGL engine, but I can't figure how I could get more than the limit of 32 lights.

I use an array in my shader, feed light properties into this array then loop through it and compute lightning, but I can't get more than 32 items into my array.

What is a better alternative to this?

\$\endgroup\$
2
\$\begingroup\$

You can send all the data that you want in a texture.

\$\endgroup\$
0
\$\begingroup\$

You use multiple passes and additive blending to solve this.

Traditionally this performs better than using an array and looping over every light, because that approach involves branching and causes pressure on shader register and instruction counts - both of which will impact performance.

It also integrates better with shadows because when drawing shadows you're going to want to draw in the order shadow, light, shadow, light, etc. With the state and shader changes involved here you'll be doing multiple passes anyway.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.