programming4us
programming4us
MULTIMEDIA

Programming with DirectX : Basic Lighting Information - Diffuse Light , Specular Light , Blinn-Phong Specular Model

- Free product key for windows 10
- Free Product Key for Microsoft office 365
- Malwarebytes Premium 3.7.1 Serial Keys (LifeTime) 2019

A lighting algorithm is the specific mathematical operation performed on a surface to shade it to produce the desired lighting effect. Lighting algorithms can be used to represent the different values of the lighting equation. Commonly this includes, but is not limited to, the following lighting values.

  • Ambient

  • Diffuse

  • Specular


Ambient Light

The ambient value of the lighting equation is used for various purposes. In simple lighting algorithms, it is often used to add a fill color to lighten the scene. This fill color is a way to simulate basic area light by using nothing more than a single color value. This does not lead to realistic lighting conditions and is just a value used to brighten the scene.

On the other hand, the ambient value can be used as the occluding factor. This means the ambient value is used to store a percentage of how many surfaces in the scene can possibly block light rays from reaching the surface. This technique is known as ambient occlusion.

In ambient occlusion you essentially trace many rays from the surface being evaluated into the scene. The percentage of those rays that hit some surface in the scene is recorded and used as the ambient occlusion value. This value is multiplied by the other lighting terms to create shadows in the scene. These shadows appear soft when many rays going in many different directions from the surface are used. This is because some points on a surface might be lit differently than others, creating a smooth gradient of gray values across the surface.

Regardless of whether the algorithm used involves nothing more than adding a static color value to the scene or is as complicated as ambient occlusion, the ambient value itself is generally used to simulate light coming to the surface from the environment. Global illumination algorithms go a step further to account for light bouncing off of a surface and evaluate the resulting color bleed onto the surface. An example of this is to take a bright blue ball and place it on a plain sheet of paper. If you place a bright light on top of the ball so that the light is shinning down on it, the white piece of paper should have some tints of blue on it because the blue reflecting off of the ball is reaching the paper. This color bleeding effect is common in global illumination.

Diffuse Light

The diffuse lighting value is light that has reached a surface and has reflected off of it evenly, or at least it seems even. When light hits a surface, it is scattered back into the scene. The smoother the surface is, the more light reflects in the direction from which it came. Surfaces such as mirrors are extremely smooth, and lights reflect back so that a mirror image appears on the surface. For surfaces that are not as smooth, light often hits microscopic grooves along the surface that cause the light to scatter in different directions. Since so much light is hitting such a surface from so many different angles, diffusely lit surfaces look as if light is being evenly reflected in all directions.

Specular Light

Specular light is light that hits a smooth surface and reflects sharply in specific directions. With diffuse light, the millions of light rays in nature strike the surface and scatter in so many different directions that objects look evenly lit regardless of the viewing angle as far as light reflection is concerned.

With specular light the sharp reflection of light, instead of the scattering reflection, in many angles is what creates a highlight on the surface. Mirrors are so smooth that the light can create clear reflections on them. For objects that are smooth enough to reflect light more sharply than others, highlights appear that can be seen from certain orientations. Since light reflects more sharply in some directions than others, the appearance of the highlight can change depending on your viewing angle. This differs from diffuse light, because a diffusely lit object looks the same regardless of the viewing angle (aside from shadows, but we’ll assume shadows are not present), but an object reflecting specular highlights looks different as the object’s orientation or the viewing orientation changes. This is similar to rotating a plastic soda bottle while standing in sunlight. The highlights from the light hitting the object shimmer and change as the orientation changes since the reflection isn’t evenly dispersed in all directions.

Lambert Diffuse Model

The Lambertian reflection model is used to simulate light rays striking a surface and reflecting back into the scene, where the brightness of a point on that surface looks the same regardless of where the observer is located. In other words, Lambertian reflection is ideal for diffuse light, where the nature of diffuse light is to illuminate a surface so that it looks the same around all angles.

The Lambert equation for diffuse light is fairly straightforward and very popular. To calculate the diffuse contribution, you need the light vector and the surface normal. With these two pieces of information you can calculate the dot product between them, and the resulting floating-point value is what you use as the diffuse contribution. This is commonly referred to as N dot L, where N is the normal and L is the light vector. You take this dot product value and multiply it by the surface color, material color (e.g., textures etc.), and so forth.

Blinn-Phong Specular Model

The Blinn-Phong reflection model is used to perform real-time lighting in computer graphics. The Blinn-Phong reflection model is actually a modification of the Phong reflection model. A reflection model can be thought of as an algorithm that is used to describe how light reflects off of objects.

The Blinn-Phong reflection model is used to create the specular contribution of the lighting equation. The steps to create the specular contribution using the Blinn-Phong model are as follows.

1.
Retrieve the normal vector.

2.
Compute the light vector as the light’s position minus the vertex position and normalize it.

3.
Compute the view vector as the light’s position minus the camera’s position and normalize it.

4.
Compute the half vector that is necessary for the Blinn-Phong algorithm as the light vector plus the view vector.

5.
The specular value is the dot product of the normal and the half vector raised to a specific power (this power is known as the specular power and is used for shininess).

To use the Blinn-Phong reflection model, the first pieces of data necessary are the normal, the view vector, and the light vector. The normal is the surface normal. The view vector is the vector that describes the direction from the camera’s position to the point being shaded, which allows the specular contribution to be view-based. The last vector, the light vector, is a vector from the light’s position to the point being shaded. If these vectors are calculated in the vertex shader and sent to the pixel shader, the results can be interpolated to point not from the original vertex position but from the pixel’s point being shaded. You could also calculate them in the pixel shader, but the interpolated values from the vertex shader work just as well.

Once you have these vectors, you calculate a new vector called the half vector. This vector is used instead of finding the reflection vector as is done in the Phong reflection model. It is faster to calculate than the method used in the Phong reflection model. Like the diffuse contribution that is calculated using N dot L, the specular value is found using N dot H, where N is the normal and H is the half vector. Raising this value by a power, known as the specular power, allows us to control the amount of shine an object has.

Materials

Material is a term used to describe the representation of a surface. For example, a brick wall in a video game might have as part of the “brick” material a texture image of bricks, a normal map used for bump mapping to increase the detail of the bricks, a diffuse modifier, and anything else the artist creates to make the wall look like a brick wall.

These days a material is a collection of pieces of data used to create the look of a surface. In the early days of 3D graphics, most games used textures as the main or sole source of the material. Materials can include, but are not limited to, the following.

  • Decal color texture map

  • Normal map

  • Alpha map

  • Diffuse color

  • Specular color

  • Emissive color

  • Ambient color

  • Vertex shader

  • Pixel shader

  • Geometry shader

In today’s games, materials are complex assets, and some game engines have their own material systems built into the rendering system. With the amount of content that goes into games, materials will most likely continue to grow in complexity as the amount of data necessary to represent certain surfaces increases.

Other  
  •  Programming with DirectX : Light Types - Directional Lights,Point Lights,Spot Lights, Area Lights
  •  Programming with DirectX : Overview of Lighting - Pros and Cons of Per-Vertex Lighting, Per-Pixel Lighting
  •  What Will 2014 Bring To Tech Lovers?
  •  DirectX 10 Game Programming : Direct3D - Textures and Details (part 3) - Drawing the Textured Object
  •  DirectX 10 Game Programming : Direct3D - Textures and Details (part 1) - Adding Support for Texture Mapping - Texturing Coordinates and Sampling
  •  DirectX 10 Game Programming : Direct3D - Textures and Details (part 1) - Adding Support for Texture Mapping - The Vertex Format
  •  DirectX 10 Game Programming : Shaders and Effects - Geometry Shaders
  •  Adobe Photoshop CS5 : Managing Color from Monitor to Print - Working with Rendering Intents
  •  Adobe Photoshop CS5 : Managing Color from Monitor to Print - Changing from Additive (RGB) to Subtractive (CMYK) Color
  •  Adobe Photoshop CS5 : Managing Color from Monitor to Print - Setting Up Soft-Proof Colors
  •  
    Top 10
    Free Mobile And Desktop Apps For Accessing Restricted Websites
    MASERATI QUATTROPORTE; DIESEL : Lure of Italian limos
    TOYOTA CAMRY 2; 2.5 : Camry now more comely
    KIA SORENTO 2.2CRDi : Fuel-sipping slugger
    How To Setup, Password Protect & Encrypt Wireless Internet Connection
    Emulate And Run iPad Apps On Windows, Mac OS X & Linux With iPadian
    Backup & Restore Game Progress From Any Game With SaveGameProgress
    Generate A Facebook Timeline Cover Using A Free App
    New App for Women ‘Remix’ Offers Fashion Advice & Style Tips
    SG50 Ferrari F12berlinetta : Prancing Horse for Lion City's 50th
    - Messages forwarded by Outlook rule go nowhere
    - Create and Deploy Windows 7 Image
    - How do I check to see if my exchange 2003 is an open relay? (not using a open relay tester tool online, but on the console)
    - Creating and using an unencrypted cookie in ASP.NET
    - Directories
    - Poor Performance on Sharepoint 2010 Server
    - SBS 2008 ~ The e-mail alias already exists...
    - Public to Private IP - DNS Changes
    - Send Email from Winform application
    - How to create a .mdb file from ms sql server database.......
    programming4us programming4us
    programming4us
     
     
    programming4us