Multiple SurfaceGridSeries3D and transparency

A forum dedicated to WPF version of LightningChart Ultimate.

Moderator: Arction_LasseP

Greg9504
Posts: 38
Joined: Fri Dec 06, 2013 4:51 pm

Multiple SurfaceGridSeries3D and transparency

Post by Greg9504 » Wed Dec 07, 2016 8:45 pm

Is there anyway around this problem:

I have multiple surfaces, I want the user to be able to vary the transparency of a surface. However when I do this the surface is not transparent, see the example screen shots. This seems related to the order that the surface was added to the View3D. In the example the top surface was added first. If I were to change the transparency of the bottom surface (added second) then everything appears to work.

The code to set the transparency is
gridSeries.Data[i, j].Color.A = surface.AlphaValue;
Attachments
twosurfaces_onetransparent.jpg
twosurfaces_onetransparent.jpg (161.81 KiB) Viewed 9626 times
twosurfaces.jpg
twosurfaces.jpg (179.68 KiB) Viewed 9626 times

User avatar
ArctionPasi
Posts: 1366
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland

Re: Multiple SurfaceGridSeries3D and transparency

Post by ArctionPasi » Thu Dec 08, 2016 5:33 am

Hi Greg,

The rendering order matters here. Alpha test is made against stuff already rendered on the backbuffer. The Surface series are rendered in the order they exist in the View3D.SurfaceGridSeries collection. Please change the order of the collection, that should help :)
LightningChart Support Team, PT

Greg9504
Posts: 38
Joined: Fri Dec 06, 2013 4:51 pm

Re: Multiple SurfaceGridSeries3D and transparency

Post by Greg9504 » Fri Dec 09, 2016 4:23 am

Just changing the rendering order doesn't work. What happens when their are 3 surfaces??? Vary the transparency of the middle surface and you wont be able to see either the surface below or above, depending on what order they were added.

If you notice there is a slider used to vary the alpha transparency. This means that on each property change event I need to:

- removal all surfaces
- rerender all other surfaces
- update alpha value for selected surface
- rerender surface.

Hopefully it wont be slow... just tested this code:

Code: Select all

private void UpdateSurfaceAlpha(SurfaceModel surface, IntensitySurfaceGridSeries3D gridSeries)
        {
            SurfaceGridSeries3DCollection allseries = new SurfaceGridSeries3DCollection();
            allseries.AddRange(m_chart.View3D.SurfaceGridSeries3D);
            //remov all surfaces
            m_chart.View3D.SurfaceGridSeries3D.Clear();
            //add back all surfaces but the one that the alpha is changing
            foreach (SurfaceGridSeries3D series in allseries)
            {
                if (series != gridSeries)
                {
                    m_chart.View3D.SurfaceGridSeries3D.Add(series);
                }
            }
            //modify the alpha value of the series
            for (int i = 0; i < gridSeries.Data.GetLength(0); i++)
            {
                for (int j = 0; j < gridSeries.Data.GetLength(1); j++)
                {
                    gridSeries.Data[i, j].Color.A = surface.AlphaValue;
                }
            }
            gridSeries.InvalidateData();//this must be done to get the updated alpha value
            m_chart.View3D.SurfaceGridSeries3D.Add(gridSeries);

        }
and it appears to run fast enough to vary the transparency with the slider. At least with 2 surfaces, will have to test with more to be sure.

Thanks
Greg.

User avatar
ArctionPasi
Posts: 1366
Joined: Tue Mar 26, 2013 10:57 pm
Location: Finland

Re: Multiple SurfaceGridSeries3D and transparency

Post by ArctionPasi » Fri Dec 09, 2016 3:13 pm

Transparency has serious limitations in 3D. It depends on the object order in the series collections and camera angle. You can use max 1 transparent or translucent series in the chart.
LightningChart Support Team, PT

Greg9504
Posts: 38
Joined: Fri Dec 06, 2013 4:51 pm

Re: Multiple SurfaceGridSeries3D and transparency

Post by Greg9504 » Fri Dec 09, 2016 4:52 pm

Hello Pasi,

I now see the problem even with my changes. Not sure why you didn't mention this first. So no alpha blending. Should mention this in the documentation.