OUTPUT REGISTERS

The output registers are where your vertex shader will place its results for further processing down the pipeline. The output registers are write only, and have a letter o prefix for "output." Only the output position registers have to be written to by the vertex shader; the others are optional.

oPos: The Output Position Registers

The oPos register consists of one four-element floating point vector that is expected to contain the vertex position in homogenous clip-space coordinates. The vertex shader must write to the output position register. These are homogenous coordinates, so the w element must be written to as well.

oD0, oD1: The Output Data Registers

The output data registers are two four-element floating point vectors, and are typically used to hold the diffuse (oD0) and specular (oD1) color values generated from the shader. Both of these registers are (possibly) interpolated between the vertices of the triangle before being passed to the pixel shader as color registers v0 and v1.

If you are also using a pixel shader, then there is absolutely no reason that these values have to be color values. If you want to pass one or two four-element vectors (possibly interpolated) to your pixel shader, the output destination registers are the way you'd do it. As long as the pixel shader generates some color value as output, it doesn't have to come from the vertex data. But keep in mind that those registers are usually lower precision and clamped to the [0,1] range.

oTn: The Output Texture Coordinate Registers

There are eight texture coordinate registers represented as eight four-element floating point vectors. They should contain the texture coordinates to be used by the pipeline for this vertex.

Write only as many register elements as there are texture coordinates in the input texture map. For example, for a 2D texture you would write only to the .xy elements using a mask. When texture projection is enabled, you'll need to write to all elements of the texture register.

For PS 1.4 or later you should not select the D3DTTFF_PROJECTED flag when using the programmable pipeline. This flag instructs the pipeline to divide all the elements by the last element (a perspective divide in the hardware) before rasterization takes place, and is intended to be used as part of the FFP for projected textures.

Texture coordinates for a singly tiled texture will usually be in the range [0,1]. If you are tiling a large area, you might run into a situation where your texture coordinates run into large multiples of this range. This limit can be found for a particular device by examining the MaxTextureRepeat member of the D3DCAPS structure. Note that the MaxTextureRepeat value's interpretation is affected by the D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE capability bit.

However, if the texture coordinates are to be read by a pixel shader using the texcoord or texcrd instructions, then the texture coordinate range might depend on the instruction and the pixel shader version since the pixel shader registers have less precision than the vertex shader registers. Pixel shaders version 2.0 have higher precision.

oFog: The Output Fog Register

The output fog register is a single floating point value indicating the vertex fog intensity. Note that this is used by vertex fog (the render state D3DRS_FOGVERTEXMODE is set and D3DRS_FOGENABLE is true), not table fog. The value in the register is the fog factor to be interpolated and then routed to the fog blend. Use the oFog.x element to set this value. On output from the shader, the fog register is clamped to the [0,1] range. The vertex fog value is used after the pixel shader. The value is inaccessible to the pixel shader.

oPts: The Output Point Size Register

The output point size register. Only the oPts.x element is used. The point size maximum can be determined by examining the MaxPointSize member of the D3DCAPS8 structure. If this value is 1.0, then you can't modify the point size. A typical value is 64, which translates to 64 pixels—independent of screen resolution.



Real-Time Shader Programming(c) Covering Directx 9. 0
Real-Time Shader Programming (The Morgan Kaufmann Series in Computer Graphics)
ISBN: 1558608532
EAN: 2147483647
Year: 2005
Pages: 104
Authors: Ron Fosner

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net