Reputation: 55
I have some questions about computer graphics:
How can I compute diffuse shading with multiple light in java ?
How can I compute ambiant shading with multiple light in java ?
Upvotes: 0
Views: 301
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