天行健 君子当自强而不息

     摘要: Direct3D纹理对象生成后,纹理对象指针指向的纹理资源指针还没有被有效赋值,如果想要通过磁盘图形文件载入纹理,那么必须将磁盘图形文件的内容载入Direct3D纹理资源,因为不同的文件具有不同的格式,所以为了将文件内容载入到Direct3D纹理资源,就要了解各种图形文件的格式,并针对不同的格式编写不同的代码将文件内容载入到纹理资源中。

从磁盘文件生成并载入纹理相当繁琐,它涉及到各种图形文件的存储格式。幸运的是,Direct3D扩展实用库函数D3DXCreateTextureFromFile()为我们提供了从磁盘图形文件创建纹理并载入纹理内容的快捷方法。  阅读全文
posted @ 2008-05-05 14:20 lovedday 阅读(1638) | 评论 (0)编辑 收藏
     摘要: 为了使渲染的图形看起来更真实,Direct3D提供了在物体表面绘制纹理的功能。一般说来,纹理是表示物体表面细节的一幅或几幅二维图形,也称纹理贴图(texture)。当把纹理按照特定的方式映射到物体表面的时候,能使物体看上去更加真实。当前流行的图形系统中,纹理绘制已经成为一种必不可少的渲染方法。在理解纹理映射时,可以将纹理看作应用程序在物体表面的像素颜色。在真实世界中,纹理表示一个对象的颜色、图案以及触觉特征。但在Direct3D 中,纹理只表示对象表面的彩色图案,它不能改变对象的几何形式。更进一步说,它只是一种高强度计算行为。  阅读全文
posted @ 2008-05-05 13:43 lovedday 阅读(2517) | 评论 (0)编辑 收藏
     摘要: Ambient lighting provides constant lighting for a scene. It lights all object vertices the same because it is not dependent on any other lighting factors such as vertex normals, light direction, light position, range, or attenuation. It is the fastest type of lighting but it produces the least realistic results. Direct3D contains a single global ambient light property that you can use without creating any light. Alternatively, you can set any light object to provide ambient lighting.   阅读全文
posted @ 2008-05-05 11:44 lovedday 阅读(1505) | 评论 (0)编辑 收藏
     摘要: Emissive lighting is described by a single term.

Emissive Lighting = Ce  阅读全文
posted @ 2008-05-05 11:42 lovedday 阅读(692) | 评论 (0)编辑 收藏
     摘要: Modeling specular reflection requires that the system not only know in what direction light is traveling, but also the direction to the viewer's eye. The system uses a simplified version of the Phong specular-reflection model, which employs a halfway vector to approximate the intensity of specular reflection.  阅读全文
posted @ 2008-05-05 11:10 lovedday 阅读(910) | 评论 (0)编辑 收藏
     摘要: After adjusting the light intensity for any attenuation effects, the lighting engine computes how much of the remaining light reflects from a vertex, given the angle of the vertex normal and the direction of the incident light. The lighting engine skips to this step for directional lights because they do not attenuate over distance. The system considers two reflection types, diffuse and specular, and uses a different formula to determine how much light is reflected for each. After calculating th  阅读全文
posted @ 2008-05-05 10:40 lovedday 阅读(648) | 评论 (0)编辑 收藏
     摘要: Ambient lighting provides constant lighting for a scene. It lights all object vertices the same because it is not dependent on any other lighting factors such as vertex normals, light direction, light position, range, or attenuation. It is the fastest type of lighting but it produces the least realistic results. Direct3D contains a single global ambient light property that you can use without creating any light. Alternatively, you can set any light object to provide ambient lighting. The ambient  阅读全文
posted @ 2008-05-05 10:02 lovedday 阅读(1136) | 评论 (0)编辑 收藏
     摘要: 在三维图形程序中使用光照效果能够有效地增强场景的真实感。在Direct3D中,通过计算场景中的光线和物体表面材质反射光线颜色的数学交互,可使光线模型接近于真实世界的照明系统。

在真实世界中,光线在到达眼睛之前经过了物体表面的多次反射,每次反射时,物体表面都会吸收一些光,有些被随机反射扩散出去,其余的到达下一个物体的表面或眼睛。真实世界中光线反射的效果就是光线跟踪算法需要模拟实现的。尽管光线跟踪算法能够创建非常逼真的与自然界中观察到极为相似的景象,但是还没有实时程序能够完成这些运算。考虑到实时渲染的需要,Direct3D使用更简单的方法进行光照计算。Direct3D光照计算模型包括4种:环境光、漫反射光、镜面反射光和自发光。它们的结合能灵活高效地解决三维图形程序中的光照问题。  阅读全文
posted @ 2008-05-05 09:32 lovedday 阅读(1938) | 评论 (0)编辑 收藏
     摘要: 在示例程序MultiLights中一共使用了三个光源,分别是漫反射方向光光源、漫反射点光源、镜面反射方向光光源,而且可以控制分别使用三个光源和同时使用三个光源的显示效果。为了测试不同光源的光照效果,在示例程序中通过键盘上的数字键来控制3个光源的启用。  阅读全文
posted @ 2008-05-04 16:05 lovedday 阅读(957) | 评论 (0)编辑 收藏
     摘要: 在程序中可以根据需要按以下步骤添加光照效果:

(1)激活光照运算。

(2)设置物体表面材质。材质属性是针对整个图形系统的,如果场景中的物体具有不同的材质属性,在渲染物体前要分别设置其材质属性。

(3)设置光源。Direct3D在一个场景中最多支持8个光源,对每个设置好的光源还要设置是否启用。  阅读全文
posted @ 2008-05-04 14:59 lovedday 阅读(655) | 评论 (0)编辑 收藏
仅列出标题
共136页: First 7 8 9 10 11 12 13 14 15 Last 

公告

导航

统计

常用链接

随笔分类(178)

3D游戏编程相关链接

搜索

最新评论