Multiple lights in pixel shader (2+) and runing out of registers

I’m trying to implement multiple light shader, and currently I’m hitting limit of varyings, as far as I unerstand.
How do you write shader with 8+ lights???
Each needs at least position passed from vsh to fsh…

Originally posted by M/\dm/
:
How do you write shader with 8+ lights???
Each needs at least position passed from vsh to fsh…[/QB]
today, using 8 lights in one pass cant work unless u use a simplistic lighting model (no shadows etc)
my recommendation is draw one light == one pass, more flexible

You can store all the light parameters in a texture.

I would not suggest drawing one light per pass unless your light is highly complex (or your shadowing algorithm requires it). Instead, simply draw as many lights as you can get away with in each pass. That way, you minimize the quantity of time you have to spend doing T&L work.

What is the maximal number of parameters I can pass from vsh to fsh, so far I see 32 as max? Do they include vertex pos, color, textures?

I thought there is a way to use arrays of lights, but seems that I’m hitting limit…
What was all the multi light per pass hype in FarCry about then??? Do they do like 2 lights per pass too???
What about uniforms, my implementation can keep up to 256 uniforms (both vsh, fsh), should I stick to them???

Originally posted by M/\dm/
:
[b]What is the maximal number of parameters I can pass from vsh to fsh, so far I see 32 as max? Do they include vertex pos, color, textures?

I thought there is a way to use arrays of lights, but seems that I’m hitting limit…
What was all the multi light per pass hype in FarCry about then??? Do they do like 2 lights per pass too???
What about uniforms, my implementation can keep up to 256 uniforms (both vsh, fsh), should I stick to them???[/b]
32 floats on gffx, what u can do is instead of in the vertex shader do some of the calculations in the fragment shader (gonna be slower)
farcry is not very advanced lightingwise

I got the same problem.
I dont see any solution than having different shaders for 8 and less lights (passing via varyings) and for more than 8 (passing via uniforms).
It depends on the scene, but try to sort geometry wrt numer of lights that affect every polygon. It should be the case that there are few polygons to render in uniform mode.

You can create a cube map, renders the lights on it, use that cube map as ‘light source’, so you are not limited by the number of lights.

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