'DeclarationPublic Sub SetExternalShader( _ ByVal code() As System.Byte _ )
public void SetExternalShader( System.byte[] code )
Parameters
- code
- A precompiled pixel shader, or null to remove the existing shader
'DeclarationPublic Sub SetExternalShader( _ ByVal code() As System.Byte _ )
public void SetExternalShader( System.byte[] code )
To remove the shader, use this method again, with a null parameter
// 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)); }
// Load a precompiled HLSL shader from a file byte[] sobelShaderCode = File.ReadAllBytes("your_precompiled_HLSL_shader.cso"); DicomImage image = new DicomImage("your_dicom_image.dcm"); image.SetExternalShader(sobelShaderCode); // To remove the shader and restore default rendering image.SetExternalShader(null);