Edit

Share via


ShaderEffect.DdxUvDdyUvRegisterIndex Property

Definition

Gets or sets a value that indicates the shader register to use for the partial derivatives of the texture coordinates with respect to screen space.

protected:
 property int DdxUvDdyUvRegisterIndex { int get(); void set(int value); };
protected int DdxUvDdyUvRegisterIndex { get; set; }
member this.DdxUvDdyUvRegisterIndex : int with get, set
Protected Property DdxUvDdyUvRegisterIndex As Integer

Property Value

The index of the register that contains the partial derivatives.

Exceptions

An attempt was made to set the DdxUvDdyUvRegisterIndex property more than one time or after initial processing of the effect.

Remarks

Use the DdxUvDdyUvRegisterIndex property to specify the shader register that contains the partial derivatives of the texture coordinates with respect to screen space. For example, if DdxUvDdyUvRegisterIndex is set to 4, the shader register c4 is used. Register c4 contains four float fields. The following High Level Shading Language (HLSL) code shows how this register is used. The nextPixelUV value represents the next pixel to the right.

float4 ddxUvDdyUv : register(c4);  
SamplerState  sampler : register(S0);  
...  
float2 nextPixelUV;  
nextPixelUV.u = ddxUvDdyUv.x + u;  
nextPixelUV.v = ddxUvDdyUv.y + v;  

tex2D(sampler, nextPixelUV);  

The following table shows how the register specified for DdxUvDdyUvRegisterIndex is filled.

Register Constant Derivative Value
x component ddx(u)
y component ddx(v)
z component ddy(u)
w component ddy(v)

Texture coordinates are denoted as (u, v). ddx(u) is the constant partial derivative of the texture coordinate component u with respect to the screen-space x-coordinate. ddy(u) is the partial derivative of the texture coordinate u with respect to the screen-space y-coordinate. Similarly, ddx(v) and ddy(v) are the corresponding screen-space derivatives for the texture coordinate component v.

Note

HLSL has the ddx and ddy instructions to calculate these values, but these instructions are not available on all PixelShader 2.0 hardware.

You may think of these constants in the following way. If you step 1 pixel to the right in screen space (in the x direction), then ddx(u) is the amount that u changes in texture space, and ddx(v) is the amount that v changes in texture space. If the effect is axis-aligned when it is rendered, then ddx(v) is 0. If the effect is rotated when it is rendered, then ddx(v) is non-zero.

Applies to

See also