Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is it possible to make lighting in a normal effect work like the lighting in the basic effect?

With a basic effect it's really easy:

BasicEffect effect; effect.EnableDefaultLighting();

share|improve this question

You can make any configuration of BasicEffect yourself, such as the so-called "default lighting". But really, XNA's BasicEffect is not basic at all. Having so many different options means that the actual shader is constructed of many interchangeable fragments. It's quite complex internally.

However, if you don't want your shader to work in a variety of ways, it's much simpler. You can implement your own so that it combines a specific set of features and always uses them. Directional lighting plus ambient lighting is very easy, and google will surely give you a workable example.

You will have to do the work that the built-in class does for you when it prepares to use the shader. You will need to assign a light direction and color, and define and ambient color and intensity. It's more lines of code than using BasicEfect, but the shader will be your own to customize and experiment as you please.

share|improve this answer
Well, that's the problem. I want to use a custom effect file to draw a part of a model and I also need lighting like the basic lighting... – user1990950 Apr 5 '13 at 14:09
@user1990950 That seems reasonable. Other than doing the work, what is the problem? – Seth Battin Apr 7 '13 at 5:43

Your Answer


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.