Microsoft DirectX 8.1 (pixel shader versions 1.0, 1.1, 1.2, 1.3, 1.4)

texkill

texkill src

Cancels rendering of the current pixel if any of the first three components (UVW) of the texture coordinates is less than zero.

Registers

Argument Description RegistersVersion
vn cn tn rn
src Source register x 1.0, 1.1, 1.2, 1.3
x x 1.4 phase 2 only

To learn more about registers, see Registers.

Remarks

texkill does not sample any texture. It operates on the first three components of the texture coordinates given by the source register number. For ps 1.4, texkill operates on the data in the first three components of the source register.

You can use this instruction to implement arbitrary clip planes in the rasterizer.

When using vertex shaders, the application is responsible for applying the perspective transform. This can cause problems for the arbitrary clipping planes because if it contains anisomorphic scale factors, the clip planes need to be transformed as well. Therefore, it is best to provide an unprojected vertex position to use in the arbitrary clipper, which is the texture coordinate set identified by the texkill operator.

// This instruction is used as follows:
texkill tn

// The pixel masking is accomplished as follows:
if ( any of the first 3 components of TextureCoordinates(stage n)UVWQ < 0 )
  cancel pixel render

For ps 1.0, 1.1, 1.2, and 1.3, texkill operates on the texture coordinate set given by the source register number. In version 1.4, however, texkill operates on the data contained in the texture coordinate iterator register (tn) or in the temporary register (rn) that has been specified as the source.

When multisampling is enabled, any antialiasing effect achieved on polygon edges due to multisampling will not be achieved along any edge that has been generated by texkill. The pixel shader runs once per pixel.

Example

This example is for illustration only.

// This example masks out pixels that have negative texture coordinates. The pixel 
// colors are interpolated from vertex colors provided in the vertex data.
// The shader is shown below.
ps.1.0       // version instruction
texkill t0   // Mask out pixel using texture coordinates from stage 0.
mov r0, v0   // Move the diffuse color in v0 to r0.

// The rendered output from the pixel shader is shown below. It shows 
// vertex color data applied to a plane. The texture coordinate data
// is declared in the vertex data declaration in this example.

struct CUSTOMVERTEX
{
    FLOAT x, y, z;
    DWORD color;
    FLOAT tu1, tv1;
};

#define D3DFVF_CUSTOMVERTEX (D3DFVF_XYZ|D3DFVF_DIFFUSE|D3DFVF_TEX1|D3DTEXCOORD2(0))

static CUSTOMVERTEX g_Vertices[]=
{
    //  x      y     z    color         u1,    v1  
    { -1.0f, -1.0f, 0.0f, 0xffff0000, -0.5f,  1.0f, },
    {  1.0f, -1.0f, 0.0f, 0xff00ff00,  0.5f,  1.0f, },
    {  1.0f,  1.0f, 0.0f, 0xff0000ff,  0.5f,  0.0f, },
    { -1.0f,  1.0f, 0.0f, 0xffffffff, -0.5f,  0.0f, },

};

// The texture coordinates range from -0.5 to 0.5 in u, and 0.0 to 1.0 in v.
// This instruction causes the negative u values get masked out.
// The first image shows the vertex colored applied to the quad without the
// texkill instruction applied.
// The second image shows the result of the texkill instruction. The pixel colors
// from the texture coordinates below 0 (where x goes from -0.5 to 0.0) are masked
// out. The background color (white) is used where the pixel color is masked.