user1743323
user1743323

Reputation: 55

diffuse shading and ambiant shading

I have some questions about computer graphics:

Upvotes: 0

Views: 301

Answers (1)

Nico Schertler
Nico Schertler

Reputation: 32627

Independently of how many lights there are, the lighting is computed as follows:

ambient = material.ambient * light.ambient
diffuse = material.diffuse * light.diffuse * dot(normal, direction_to_light)

The direction and normal vectors must be normalized. Furthermore, if the dot() is less than zero, the resulting diffuse color is just black.

If you have multiple lights, each light is added to the result. So e.g.

result = ambient_light1 + diffuse_light1 + ambient_light2 + diffuse_light2 ...

Upvotes: 2

Related Questions