Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I'm working on a deferred shader, and I want to use instancing to draw point lights.

From what I understand, I can send the instance data through the vertex shader and pass it through unchanged to the pixel shader. Is this the correct way to do it, or can I send the instance data straight to the pixel shader somehow?

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

can I send the instance data straight to the pixel shader somehow?

What would that mean, exactly? The values your fragment (or pixel if you insist) shader gets are per-vertex values interpolated across the face of the primitive, and constant uniform values that do not change within a draw call.

There is no way to magic a vertex stage input into a vertex stage output. There must be a vertex shader and it must write that input into the output.

I want to use instancing to draw point lights.

You probably do not. Instancing usually isn't a performance win unless you're talking about thousands of instances. If you only have 20 point lights, it's not going to be worthwhile.

At the very least, you should profile it before committing to it.

share|improve this answer
    
I'm thinking thousands of lights, yeah. –  Rei Miyasaka Jul 20 '12 at 6:43
1  
@Rei: If you're using thousands of lights, it would be better to have a fragment shader that loops over some number of lights, rather than using instancing to pass parameters. That way, the fixed per-sample cost is reduced (reverse transforming back into eye-space). For example, you might have shaders that do 1, 5, 10, 25, and 100 lights, or whatever fits in the shader. –  Nicol Bolas Jul 20 '12 at 7:08
    
Oh I see, that would also make it so that I don't have to worry about choosing a size for the vertex buffer holding all the lights. Thanks! –  Rei Miyasaka Jul 20 '12 at 8:38
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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