• 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.

              

  • 相关阅读:
    PostgreSQL数据库逻辑复制实践
    CentOS7通过yum安装postgreSQL
    MongoDB动态建表方案(官方原生驱动)
    7大常用开源数据库利弊全对比
    错误:由于系统时间错误证书验证失败导致更新不成功
    deppin更新提示“由于没有公钥,无法验证下列签名”
    Debian 9 Vim无法使用鼠标右键复制 解决方法
    PHP版滑动时间窗口算法
    RabbitMQ PHP 代码示例
    创建或修改 docker 容器内部文件
  • 原文地址:https://www.cnblogs.com/StudipBird/p/3194392.html
Copyright © 2020-2023  润新知