[DirectX 10] Multiple ligths

Started by
13 comments, last by mind in a box 13 years, 11 months ago
I want to create a shader to handle multiple lights... This is my idea (one pass): -Create an array of lights (specifying light type, position, direction, etc); -Pass the array to the shader; -Create a loop and keep adding the diffuse/specular colour of each light to each pixel; Is this technique good or what should I change? Is there any good whitepaper/doc talking about multiple lights?
Advertisement
At the very beginning of my own engine, I tried that, too. If you really know the light you will use, it is *may* a way. But if you want the user to create some lights, it's just horrible.

When you need many dynamic lights, you may take a look at this article: Deferred Rendering Demystified

When you need not so many dynamic lights, you could use forward rendering. This is done by drawing the mesh for each light on top of the other again and blending it together. So, if you have 4 lights, the mesh would be renderd 5 times: 1 Diffuse, 4 lights. Thats pretty slow for many of them.

If you don't need any dynamic lights, it is best to pre process some lightmaps. This means: Calculate the lighting once, save it to lightmaps and put them on the meshes. I never did that before, so I don't know how to do that. ;)

I hope this helped :)
For what ive read so far, there is a problem with semi-transparent objects...
How are they rendered in Deferred rendering??
I know this problem, too. Maybe you can render them with forward rendering?
Also, I don't really know what happens when you draw them like any other object. When I think about it, there shouldn't be a problem but that the light color will not modulate with you glass/water/whatever. And your light will go through walls anyways.

Please correct me if I am wrong. Haven't tested it so far...
Btw, in your engine do you use deferred or forward rendering?
I'm building in Deferred Lighting at the moment. I think this is the better solution, as I need many dynamic lights. Forward rendering is simple, but too slow for my needs.

What kind of game do you make? Do you need *many* lights? Or just a few?
I wanna create a first or third person shooter (I haven't decided yet), just a little level. So I will need a parallel directional light (the sun), and some point/spot lights. But I want to set up my engine to be able to handle good graphics from the beginning so I think I will try to implement deferred rendering.

Do you know any good article about Deferred rendering in DiretcX 10, because that article "Deferred rendering demystified isn't directX 10 at all

How long did it took you to implement DR?
I'm currently on it, and I also use DirectX10. Anyways, the steps are the same. Set up MRTs, render GBuffer/Depth,etc. Render it to full screen quads, calculate them together. I'm at the step with the FullScreen quads. As I got there I moved on with post processing, to have a good interface for that. Also I will use it to finish my deferred lighting pipeline. Getting there took me some hours of work, but not THAT long.

For a first person shooter deferred lighting is best (For dynamic use)!
Ok, I will try to implement DR.
Thank's for your help

P.S. Do you use any book like ShaderX series to learn techniques? Because I was thinking about buying Shader X7
No, I did not use any book for that. But you can check out GPU gems from nvida:
http://http.developer.nvidia.com/GPUGems3/gpugems3_part01.html

there was an article about that. Maybe it was the 2nd part. I don't know now. Anyways, it is a good resourde :)

This topic is closed to new replies.

Advertisement