D3d materials and lighting

Source: Internet
Author: User

In our daily life, we see ambient light, diffuse light, reflective plane light, and the light emitted by the object. Therefore, we must describe the response to these light when defining the material.

Let's take a look at the definition of the material structure:

 

Typedef struct _ d3dmaterial9 {
D3dcolorvalue diffuse;/* diffuse color rgba */
D3dcolorvalue ambient;/* ambient color RGB */
D3dcolorvalue specular;/* specular 'shininess '*/
D3dcolorvalue emissive;/* emissive color RGB */
Float power;/* sharpness if specular highlight */
} D3dmaterial9;

 

Typedef struct _ d3dcolorvalue {float R; float g; float B; float;
} D3dcolorvalue;

 

Diffuse: specifies the amount of diffuse light reflected on the surface.

Ambient: specifies the amount of ambient light reflected on the surface.

Specular: specifies the number of border light emitted from the surface.

Emissive: This is used to add a color to the surface to specify the color of the light emitted by the object itself.

 

Each value in the material is in the d3dcolorvalue structure. This structure actually reflects how much the color of a certain light is reflected by this material.

D3dmaterial9 matrl;

Matrl. Diffuse. r = 0.5f;

Matrl. Diffuse. B = 1.0f;

Matrl. Diffuse. G = 0.0f;

The result is the diffuse reflection light. This material will reflect half of the red light, all the blue light, and all the green light absorption.

 

 

It is also very important that you can turn on the light source when rendering a model, while you can turn off the light source when rendering another model. in the past, my understanding was that after a light source was selected in the scenario, all models in the scenario were always affected. the light source can be turned on at any time to turn off the light source. you can set another light source at any time.

 

 

 

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.