Hi,
I have a couple more higher level / design type of questions. Please excuse me if these questions sounds basic or stupid, as I am still fairly new to game development and am still getting the hang of how things work.
I am putting together a basic 3D engine to use for a card game. I have gotten the basics working and have even managed to getsimple shadows working (thanks to @kosmonautgames for the pointers).
However, up to this point I have been using the BasicEffect class and have now started looking into building a real light system (well… since I started looking into shadows).
I am a little confused as to how people approach multiple lights. I understand that there are a couple basic light types viz.
Ambient light general all around lighting
Directional light e.g. Sun
Point lights e.g. light bulbs
Spot lights
My questions are:
How do you figure out how many lights of each type can / should be supported, and how are all the lights “accumulated”? I’ve read a number of differing and confusing options for multiple lights.
Some folk tend to use a single shader which can support an array of light types, but I’ve also read that using branching and loops in shaders is a no-no, so this approach is not ideal (or is this assertion incorrect?).
I’ve also read that some people create separate shaders per light type e.g. PointLightShader.fx etc, and then call each one multiple times for each instance of the light.
There are other confusing topics light light sorting, picking lights based on the ones that impact the model, which lights cast shadows etc.
Then there seems to be a separate issue of how you render lights based on deferred rendering vs. forward rendering.
If you built a lighting system, what was your approach, and why did you choose the way you did? Also did you support both deferred and forward rendering, or did you pick one way and stick with it?
A separate question was regarding the material on a model. I currently don’t see any way to retrieve material information from a model i.e. emissive properties, shininess, diffuse etc. How do people obtain this information? Do you need to write your own custom pipeline processor? Is there a reason material information isn’t defined in the XNA model class?
Thanks in advance!