使用纹理的光映射Light mapping with textures

光照图是包含关于 3D 场景中照明信息的纹理或纹理组。A light map is a texture or group of textures that contains information about lighting in a 3D scene. 光照图将光和阴影的区域映射到基元上。Light maps map areas of light and shadow onto primitives. 多通道及多纹理混合使你的应用程序能够以比着色技术更逼真的外观渲染场景。Multipass and multiple texture blending enable your application to render scenes with a more realistic appearance than shading techniques.

要逼真地渲染 3D 场景,应用程序必须考虑光源对场景外观的影响。For an application to realistically render a 3D scene, it must take into account the effect that light sources have on the appearance of the scene. 虽然平面着色、高氏着色等技术在这方面是很有价值的工具,但它们可能仍不满足你的需求。Although techniques such as flat and Gouraud shading are valuable tools in this respect, they can be insufficient for your needs. Direct3D 支持多纹理混合。Direct3D supports multipass and multiple texture blending. 这些功能使你的应用程序能够渲染出比单单使用着色技术更逼真的场景。These capabilities enable your application to render scenes with a more realistic appearance than scenes rendered with shading techniques alone. 通过应用一个或多个光照图,你的应用程序可以将光和阴影的区域映射到其基元。By applying one or more light maps, your application can map areas of light and shadow onto its primitives.

光照图是包含关于 3D 场景中照明信息的纹理或纹理组。A light map is a texture or group of textures that contains information about lighting in a 3D scene. 你可以将光照信息存储在光照图的 Alpha 值或颜色值中,或同时存储在这两者之中。You can store the lighting information in the alpha values of the light map, in the color values, or in both.

如果使用多通道纹理混合实现光映射,你的应用程序应在第一遍渲染中将光照图渲染到其基元上。If you implement light mapping using multipass texture blending, your application should render the light map onto its primitives on the first pass. 它应使用第二遍渲染来渲染基本纹理。It should use a second pass to render the base texture. 高光映射是个例外。The exception to this is specular light mapping. 在这种情况下,应先渲染基本纹理,然后再添加光照图。In that case, render the base texture first; then add the light map.

多纹理混合使你的应用程序能够在一遍渲染中渲染光照图和基本纹理。Multiple texture blending enables your application to render the light map and the base texture in one pass. 如果用户的硬件了提供多纹理混合功能,你的应用程序应在执行光映射时使用它。If the user's hardware provides for multiple texture blending, your application should take advantage of it when performing light mapping. 这可显著提高应用程序的性能。This significantly improves your application's performance.

借助光照图,Direct3D 应用程序可以在渲染基元时实现各种照明效果。Using light maps, a Direct3D application can achieve a variety of lighting effects when it renders primitives. 它不仅能够映射场景中的单色光和彩色光,而且还可以添加反射高光和漫射照明等细节。It can map not only monochrome and colored lights in a scene, but it can also add details such as specular highlights and diffuse lighting.

有关使用 Direct3D 纹理混合执行光映射的信息,请参阅以下主题。Information on using Direct3D texture blending to perform light mapping is presented in the following topics.

本部分中的内容In this section

主题Topic 描述Description

单色 light 映射Monochrome light maps

当较旧的 3D 加速器板不支持使用目标像素 Alpha 值的纹理混合时,单色光映射使较旧的适配器能够执行多通道纹理混合。Monochrome light mapping enables older adapters to perform multipass texture blending, when an older 3D accelerator board doesn't support texture blending using the alpha value of the destination pixel.

颜色浅映射Color light maps

彩色光映射使用光映射中的 RGB 数据展示光线信息。A colored light map uses the RGB data in the light map for its lighting information. 如果应用程序使用彩色光映射,则其通常可以更真实地呈现 3D 场景。An application usually renders 3D scenes more realistically if it uses colored light maps.

反射光映射Specular light maps

通过光源照亮时,采用高反光材质的闪光对象会接收反射高光。When illuminated by a light source, shiny objects that use highly reflective materials receive specular highlights. 有时,相较于使用照明模块产生的反射高光,你可通过将高光映射应用至基元获取更精确的高光。Sometimes you can get more accurate highlights by applying specular light maps to primitives, rather than using the specular highlights produced by the lighting module.

漫射光映射Diffuse light maps

亚光表面具有漫反射光。Matte surfaces have diffuse light reflection. 漫反射光的亮度取决于与光源的距离以及表面法线与光源方向矢量之间的角度。The brightness of diffuse light depends on the distance from the light source and the angle between the surface normal and the light source direction vector. 纹理光照贴图可以模拟复杂的漫射照明。Texture light maps can simulate complex diffuse lighting.

 

相关主题Related topics

纹理Textures