Direct3d basics-material d3dmaterial9

Source: Internet
Author: User

The two main elements of illumination are the light source and the object's material. The material attribute of the object's surface determines the color of light it can reflect and the amount of light it can reflect.

I. Definition of materials in direct3d

Materials in d3d are represented by the d3dmaterial9 structure:

Typedef struct d3dmaterial9 ...{
D3dcolorvalue diffuse;
D3dcolorvalue ambient;
D3dcolorvalue specular;
D3dcolorvalue emissive;
Float power;
} D3dmaterial9, * lpd3dmaterial9;
  • Diffuse-specifies the diffuse reflection of the surface.
  • Ambient-specifies the ambient light reflected on the surface.
  • Specular-specifies the mirrored light reflected on the surface.
  • Emissive-the surface itself emits light.
  • The value of the power-mirror highlight is the sharpness of the highlight. A larger value indicates a greater difference between the intensity of the highlight and the surrounding brightness.

The total brightness of the surface vertices is:

I indicates the color value of an object. The above expression indicates the total color of the object = ambient light of the Object reflection + diffuse light of the Object reflection + reflected light of the mirror + self-emitting light.

II. Application of Materials

Function idirect3ddevice9: setmaterial () to set the current material attribute of direct3d:

Hresult setmaterial (
Const d3dmaterial9 * pmaterial
);

 

References:
Frank D. Luna: Introduction to 3D game programming with DirectX 9.0
Weng yunbing: getting started with 3D game programming (directx9.0)
Chen Ka: directx9 3D graphics program design

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.