wpf3dlineargradientbrush

LinearGradientBrush not behaving as supposed


I have a LinearGradientBrush defined for use in plotting a texture in a MeshGeometry3D, as follows. The idea is that values at the absolute ends of the brush should be plotted in Silver:

    <LinearGradientBrush x:Key="GrayOmitOutOfRangeIncreasing"   StartPoint="0,0.5" 
                                                                EndPoint="1,0.5" >
        <GradientStop Color="Silver" Offset="0.00" />
        <GradientStop Color="#000064" Offset="0.00000000000000014" />
        <GradientStop Color="#000091" Offset="0.043" />
        <GradientStop Color="#0000BE" Offset="0.087" />
        <GradientStop Color="#3C00B2" Offset="0.130" />
        <GradientStop Color="#7800A5" Offset="0.173" />
        ... and other gradient stops...
        <GradientStop Color="#FCE800" Offset="0.913" />
        <GradientStop Color="#FCF200" Offset="0.957" />
        <GradientStop Color="#FCFC00" Offset="0.99999" />
        <GradientStop Color="Silver" Offset="0.99999979" />
        <GradientStop Color="Silver" Offset="1" />
    </LinearGradientBrush>

Instead, the values, which are transformed to a range between 0 and 1 before being plotted, are taking on a shading of the neighboring color, as in the picture below:

enter image description here

How can I get the image I want?


Solution

  • Look at how they're defined:

        <GradientStop Color="#FCFC00" Offset="0.99999" />
        <GradientStop Color="Silver" Offset="0.99999979" />
        <GradientStop Color="Silver" Offset="1" />
    

    This means that ... what, 0.001% of the mesh will be a gradient from FCFC00 to silver. That's not going to be detectable. Move the penultimate silver gradient stop to maybe 0.98 or something, and see if that gets you closer.