DicomObjects.NET.V8
DicomObjects Namespace / DicomImage Class / SetExternalShader Method
A precompiled pixel shader, or null to remove the existing shader
Example



In This Topic
    SetExternalShader Method
    In This Topic
    An external DirectX pixel shader to be used for custom filtering
    Syntax
    'Declaration
     
    Public Sub SetExternalShader( _
       ByVal code() As Byte _
    ) 
    'Usage
     
    Dim instance As DicomImage
    Dim code() As Byte
     
    instance.SetExternalShader(code)
    public void SetExternalShader( 
       byte[] code
    )
    public:
    void SetExternalShader( 
       array<byte>^ code
    ) 

    Parameters

    code
    A precompiled pixel shader, or null to remove the existing shader
    Remarks
    This is an advanced technique, and those intending to use it should contact us for guidance

    To remove the shader, use this method again, with a null parameter

    Example
    A sample (in this case a simple Sobel) filter would be like this:
    // The 3D data
    MyTexture2D<float> ShaderTextureFloat: register(t0);
                
    // A simple Sampler
    SamplerState Sampler : register(s0);
                
    struct VertexShaderOutput
    {
        // The calculated position in the texture (0..1) space
        float4 Position : SV_Position;
                
        //The position of the pixel in X,Y integers
        float2 TextureUV : TEXCOORD0;
    };
                
    float main(VertexShaderOutput input) : SV_Target
    {
        float2 pos = input.TextureUV;
                
        // simplified Sobel filter 
                
        float x0 = ShaderTextureFloat.SampleLevel(Sampler, pos - ddx(pos), 0);
        float x1 = ShaderTextureFloat.SampleLevel(Sampler, pos + ddx(pos), 0);
        float y0 = ShaderTextureFloat.SampleLevel(Sampler, pos - ddy(pos), 0);
        float y1 = ShaderTextureFloat.SampleLevel(Sampler, pos + ddy(pos), 0);
    	return sqrt((x1 - x0) * (x1 - x0) + (y1 - y0) * (y1 - y0));
    }
    Requirements

    Target Platforms: .NET CLR 3.5 or higher

    See Also