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;
Multiple SurfaceGridSeries3D and transparency
Moderator: Queue Moderators
Multiple SurfaceGridSeries3D and transparency
- Attachments
-
- twosurfaces_onetransparent.jpg (161.81 KiB) Viewed 15556 times
-
- twosurfaces.jpg (179.68 KiB) Viewed 15556 times
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Multiple SurfaceGridSeries3D and transparency
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
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
Re: Multiple SurfaceGridSeries3D and transparency
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:
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.
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);
}
Thanks
Greg.
- ArctionPasi
- Posts: 1367
- Joined: Tue Mar 26, 2013 10:57 pm
- Location: Finland
- Contact:
Re: Multiple SurfaceGridSeries3D and transparency
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
Re: Multiple SurfaceGridSeries3D and transparency
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.
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.