7

I have a task to visualize 3D field of scalars using Helix Toolkit. The input array contains double values without limitations, but usually somewhere between [-50000, +50000]. The scalar value affect a color of a cube: The minimum value have a blue color, 0 - white, maximum - red. All other colors values are interpolated corresponding the value.

Right now I'm trying to understand how Color Transfer Map works in HelixToolkit.Wpf.SharpDX. For that I've created a simple field of 2x2x1 scalars.

MainWindow.xaml

<hx:Viewport3DX
    Name="view1"
    Grid.Row="1"
    BackgroundColor="SkyBlue"
    Camera="{Binding Camera}"
    EffectsManager="{Binding EffectsManager}"
    EnableDesignModeRendering="True"
    UseDefaultGestures="False"
    CameraRotationMode="Trackball">
    <hx:Viewport3DX.InputBindings>
        <KeyBinding Key="B" Command="hx:ViewportCommands.BackView" />
        <KeyBinding Key="F" Command="hx:ViewportCommands.FrontView" />
        <KeyBinding Key="U" Command="hx:ViewportCommands.TopView" />
        <KeyBinding Key="D" Command="hx:ViewportCommands.BottomView" />
        <KeyBinding Key="L" Command="hx:ViewportCommands.LeftView" />
        <KeyBinding Key="R" Command="hx:ViewportCommands.RightView" />
        <KeyBinding Command="hx:ViewportCommands.ZoomExtents" Gesture="Control+E" />
        <MouseBinding Command="hx:ViewportCommands.Rotate" Gesture="RightClick" />
        <MouseBinding Command="hx:ViewportCommands.Zoom" Gesture="MiddleClick" />
        <MouseBinding Command="hx:ViewportCommands.Pan" Gesture="LeftClick" />
    </hx:Viewport3DX.InputBindings>
    <hx:VolumeTextureModel3D VolumeMaterial="{Binding VolumeMaterial}" />
</hx:Viewport3DX>

MainWindowViewModel.cs

public MainWindowViewModel()
{
    Nx = 2;
    Ny = 2;
    Nz = 1;

    var m = new VolumeTextureDiffuseMaterial();

    var data = new[] {0.0f, 0.25f, 0.5f, 1.0f};

    var gradients = VolumeDataHelper.GenerateGradients(data, Nx, Ny, Nz, 1);
    m.Texture = new VolumeTextureGradientParams(gradients, Nx, Ny, Nz);
    m.TransferMap = new[]
        {Colors.Red.ToColor4(), Colors.Blue.ToColor4(), Colors.Lime.ToColor4(), Color4.White};
    m.SampleDistance = 0.1;
    m.Freeze();

    VolumeMaterial = m;
}

I was expecting to have 4 distinct cubes with different colors, something like (maybe with gradient between cubes due to interpolation and sampling): Desired

But I keep getting this weird triangular color mix: Actual

How exactly color transfer map array works? How can I achieve the desired result with cubes using the volume rendering of HelixToolkit.SharpDX?

6
  • Remember: if Helix, or any other package for that matter, gets way too heavy and complex for a relatively simple use case, you can always do it yourself...:O) Commented Jun 27, 2019 at 22:35
  • And HERE a sample 5x5x5 volume rendering using only alpha channel between layers, same color obviously. No 3rd party libs, just plain WPF. Commented Jun 29, 2019 at 0:30
  • 9x9x9 five-colored layers. Commented Jun 29, 2019 at 12:01
  • 15x15x15 PIXELATED SPHERE. Commented Jun 29, 2019 at 13:18
  • @jsanalytics, what are you trying to achieve with your demos? You don't provide any code or smth like that. Pure WPF3D requires to implement so many elementary things manually (like trackball mouse rotation and so on). Moreover, WPF3D struggles with high load (e.g. 1000x1000x1000 cubes). That's why HelixToolkit.SharpDX is used in our project. Many things are already implemented here and DirectX makes it possible to draw very complicated scenes at 60 fps. Commented Jun 29, 2019 at 18:18

1 Answer 1

3

You can try to refer to this tutorial. Tutorial 1 and Tutorial 2

This is how Helixtoolkit used to implement the volume rendering.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.