Sign in to follow this  
kslam

Light and shadow

Recommended Posts

How to calculate the diffuse, ambient, emission, specular light and infinite, point, spot light? Are they in scalar form or in RGB(x,x,x) form ? any formula and algorithm example ?

Share this post


Link to post
Share on other sites
Diffuse, ambient, emission, and specular determine how a single polygon will be affected by light rays.

Infinte, point and spot properties determine what kind of rays a light source will emit.

The lighting step produces colors, so they are best stored in RGB form, rather than as a scalar (unless all your lights are monochrome).

An infinite light will produce parallel light rays, so the "light" vector will always be the same. A point light produces radial light rays, so the "light" vector will be a vector from the point light to the considered point. Also, the type of light source will determine various attenuation factors for the rays.

Ambient light is the same for all objects. Diffuse lighting is in fact the sum of diffuse lightings for all light sources that affect the polygon. For each point, the diffuse lighting intensity for a light is:

light intensity * (normal vector DOT light vector)

You can google for much more details about the various light types, lighting types, and formulas. Also, API references and related documents (for DirectX and OpenGL) contain many useful remarks about these formulas, and may be found lying around on the web.

Share this post


Link to post
Share on other sites
Here's the simplified lighting equation :-

Color = Ambient + Diffuse + Specular + Emmisive

where,

Ambient = Material_Ambient * Light_Ambient
Diffuse = Material_Diffuse * Light_Diffuse * Dot(Normal, LightDirection)
Specular = Material_Specular * Pow(Dot(Normal, HalfAngle), SpecularPower) * Light_Specular
Emissive = Material_Emissive

HalfAngle = normalize(ViewDirection + LightDirection)

All values except the dot products are in vector form.

For a spot light, the diffuse and specular terms must be set to zero if the dot product between the light-to-vertex vector and the actual light direction is greater than the cone angle of the spot light.

Share this post


Link to post
Share on other sites
May you show me some simplified code of the lighting equation below. Because I got some problem to convert the equation to code form.

Ambient = Material_Ambient * Light_Ambient
Diffuse = Material_Diffuse * Light_Diffuse * Dot(Normal, LightDirection)
Specular = Material_Specular * Pow(Dot(Normal, HalfAngle), SpecularPower) * Light_Specular
Emissive = Material_Emissive

Thank you.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this