zoukankan      html  css  js  c++  java
  • DirectX 中的 Light 和 Material

      

    一、Light

    D3DLIGHT9能设置的光照类型有以下三种,分别是方向光、点光和聚光.

    D3DLIGHT_DIRECTIONAL Creates a directional light, a light that comes from everywhere at once, but shines only in one direction.
    D3DLIGHT_POINT Creates a point light, a light that emanates equally in all directions from one exact point.
    D3DLIGHT_SPOT Creates a spot light, a light that emanates in one direction from one exact point.

       在SetRenderState(D3DRS_AMBIENT, D3DCOLOR_XRGB(239, 239, 239)中,D3DRS_AMBIENT指环境光,经常设置成灰色或白色,这样应该会使得对物体的颜色控制更加容易,(结合Material属性)

      Ambient lights do just what they say: they make ambient light. Ambient lights are relatively simple. The only real adjustable property of anambient light is its color, as it has no specific source or direction.Usually this color is white or gray. The darker the gray, the darker theenvironment seems to be. Using pure white ambient light is the equivalent to just not using lights at all.

    二、Material

      material.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);    // set diffuse color to white
          material.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f);    // set ambient color to white
          d3ddev->SetMaterial(&material);    // set the globably-used material to &material

             

    Diffuse:This sets the color of diffuse light that will reflect off the surfaces rendered. The color put in here only has an effect on diffuse light. No other type.For simplicity (and realism) we will set all the diffuse values of this material to 1.0f.

    Ambient:Because we also have ambient light in our scene, we will need to include a material color for that type of lighting as well. We will set these values to 1.0f, just as in diffuse.

    注意:What happens is we set a material, and then any vertex drawn after that will be drawn with that material. It will be drawn that way until we set a different material.

              

  • 相关阅读:
    为什么你投十份简历,只有一两家公司约你?又或者为什么你每投一份简历都能获得面试机会?
    JAVA程序1,1,2,3,5,8,13,21....第30个是什么...?
    1-2+3-4+5-6+7......+n的几种实现
    分层应用——如何实现登录?
    初识三层
    VB.NET视频总结——后续篇
    操作系统小结
    VB.NET视频总结——基础篇
    台湾与大陆的计算机术语翻译差异
    VB.NET概述
  • 原文地址:https://www.cnblogs.com/StudipBird/p/3194392.html
Copyright © 2011-2022 走看看