Coordinate System and Geometry-2

Direct3D渲染原理
本文介绍了Direct3D中的渲染原理,包括多边形的三角形组成、栅格化规则、点和线的渲染规则等内容,并详细阐述了Direct3D如何通过三角形插值来实现颜色、纹理坐标等数据的平滑过渡。

 3D Primitives

Direct3D中多边形都是由三角形组成,因三角形中三个顶点永远共面,对于不共面的图形进行渲染效率很差。因此,在Direct3D中各种几何体都是用三角形图元来构成的。

Rasterization Rules(栅格化规则)

Triangle Rasterization Rules:Direct3D使用top-left filling 来填充几何图形,屏幕设备上每个象素的中间点是其决定性点,如果中点在图形中则这个象素就在这个图形中。另外,象素的中点都是在整数坐标。

Point and Line Rules:

Points are rendered the same as point sprites, which are both rendered as screen-aligned quadrilaterals and thus adhere to the same rules as polygon rendering.

Point Sprite Rules:

Point sprites and patch primitives are rasterized as if the primitives were first tessellated into triangles and the resulting triangles rasterized.

Rectangles

Throughout Microsoft Direct3D and Microsoft Windows programming, objects on the screen are referred to in terms of bounding rectangles. The sides of a bounding rectangle are always parallel to the sides of the screen. Managed code applications should use the Rectangle  structure, in the System.Drawing  namespace, for storing rectangle information and when blitting to the screen or performing collision detection.

Triangle Interpolation

During rendering, the pipeline interpolates vertex data across each triangle. Several types of data can be interpolated.

  • Diffuse color
  • Specular color
  • Diffuse alpha (triangle opacity)
  • Specular alpha
  • Fog factor (taken from specular alpha for fixed function vertex pipeline and from fog register for programmable vertex pipeline)
  • Texture coordinates

The interpolation of the vertex data is dependent on the current shading mode-flat or Gourand.

The color and specular interpolated values are treated differently, depending on the color model. In the RGB color model, the system uses the red, green, and blue color components in the interpolation.

The alpha component of a color is treated as a separate interpolated value because device drivers can implement transparency in two different ways: by using texture blending or by using stippling.

Vector,Vertices and Quaternions

Throughout Microsoft Direct3D, vertices describe position and orientation. Each vertex in a primitive is described by a vector that gives its position, color, texture coordinates, and a normal vector that gives its orientation.

Quaternions add a fourth element to the [x,y,z] values that define a three-component vector. Quaternions are an alternative to the matrix methods that are typically used for 3-D rotations. A quaternion represents an axis in 3-D space and a rotation around that axis. For example, a quaternion might represent a (1,1,2) axis and a rotation of 1 radian. Quaternions carry valuable information, but their true power comes from the two operations that you can perform on them: composition and interpolation.

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值