Share via


TextureLoader.FillTexture Method ()

Uses a user-provided function or a compiled high-level shader language (HLSL) function to fill each texel of each mip level of a given texture.

Overload List

public static void FillTexture(CubeTexture, Fill3DTextureCallback);
public static void FillTexture(CubeTexture, TextureShader);
public static void FillTexture(Texture, Fill2DTextureCallback);
public static void FillTexture(Texture, TextureShader);
public static void FillTexture(VolumeTexture, Fill3DTextureCallback);
public static void FillTexture(VolumeTexture, TextureShader);

Remarks

If the param_GraphicsStream_compiledCode parameter is used, the HLSL function must contain the following semantics:

  • One input parameter must use a POSITION semantic.
  • One input parameter must use a PSIZE semantic.
  • The function must return a parameter that uses the COLOR semantic.

The following is a C# code example of such an HLSL function:

[C#]float4 TextureGradientFill(
  float2 vTexCoord : POSITION, 
  float2 vTexelSize : PSIZE) : COLOR 
  {
    float r,g, b, xSq,ySq, a;
    xSq = 2.f*vTexCoord.x-1.f; xSq *= xSq;
    ySq = 2.f*vTexCoord.y-1.f; ySq *= ySq;
    a = sqrt(xSq+ySq);
    if (a > 1.0f) {
        a = 1.0f-(a-1.0f);
    }
    else if (a < 0.2f) {
        a = 0.2f;
    }
    r = 1-vTexCoord.x;
    g = 1-vTexCoord.y;
    b = vTexCoord.x;
    return float4(r, g, b, a);

  };

Note that the input parameters can be in any order, but both input semantics must be represented.

Exceptions

InvalidCallException

The method call is invalid. For example, a method's parameter might contain an invalid value.

NotAvailableException

This device does not support the queried technique.