PDA

View Full Version : Multiple lights in pixel shader (2+) and runing out of registers



M/\dm/\n
05-16-2005, 06:05 AM
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...

zed
05-16-2005, 11:55 AM
Originally posted by M/\dm/\n:
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

LarsMiddendorf
05-16-2005, 01:49 PM
You can store all the light parameters in a texture.

Korval
05-16-2005, 04:50 PM
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.

M/\dm/\n
05-16-2005, 08:48 PM
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???

zed
05-16-2005, 11:12 PM
Originally posted by M/\dm/\n:
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???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

_michal
05-19-2005, 12:46 AM
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.

execom_rt
05-19-2005, 02:14 AM
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.