object seems wrong rendered when transparency are used

I used vtkGlyph3DMapper to create several cubes. I use RGBA to set the color for each cube.

When I set (255, 0, 0, 255) for all the cubes, the render result is below

When I set different alpha, from 0 to 255, the render result is below

When I set alpha = 50 for the first cube, and 255 for the rest, the result is below

I find 2 problem:
(1) If one of the object is semi-transparent or totally transparent, other objects become transparent too.
(2) If one of the object is semi-transparent or totally transparent, anti-alias seems not work again.

How can I solve these 2 problems? It’s make me crazy (I have to use glyph because I need to render a large amount of objects)

#include <vtkActor.h>
#include <vtkCamera.h>
#include <vtkCubeSource.h>
#include <vtkFloatArray.h>
#include <vtkGlyph3DMapper.h>
#include <vtkNamedColors.h>
#include <vtkNew.h>
#include <vtkPointData.h>
#include <vtkPoints.h>
#include <vtkPolyData.h>
#include <vtkRenderWindow.h>
#include <vtkRenderWindowInteractor.h>
#include <vtkRenderer.h>
#include <vtkUnsignedCharArray.h>
#include <vtkInteractorStyleTrackballCamera.h>
#include <random>

vtkNew<vtkPoints> points;
vtkNew<vtkFloatArray> scaleFactors;
vtkNew<vtkFloatArray> orientation;
vtkNew<vtkNamedColors> namedColors;
vtkNew<vtkUnsignedCharArray> colors;

void Init()
{
    scaleFactors->SetNumberOfComponents(3);
    scaleFactors->SetName("Scale Factors");

    orientation->SetNumberOfComponents(3);
    orientation->SetName("orientation");

    colors->SetName("Colors");
    colors->SetNumberOfComponents(4);

    for (int i = 0; i < 10; i++)
    {
        points->InsertNextPoint(i * 3, 0, 0);
        scaleFactors->InsertNextTuple3(1, 1, 1);
        orientation->InsertNextTuple3(0, 0, 0);
        if (i == 0)
        {
            colors->InsertNextTuple4(255, 0, 0, 0);
        }
        else
        {
            colors->InsertNextTuple4(255, 0, 0, 255);
        }

        // colors->InsertNextTuple4(255, 0, 0, 255);
        // if (i > 3)
        // {
        //     colors->InsertNextTuple4(rand() % 255, rand() % 255, rand() % 255, 100);
        // }
        // else
        // {
        //     colors->InsertNextTuple4(rand() % 255, rand() % 255, rand() % 255, 30);
        // }
    }
}

int main(int, char* [])
{
    Init();
    vtkNew<vtkPolyData> poly_data;
    poly_data->SetPoints(points);
    poly_data->GetPointData()->AddArray(colors);
    poly_data->GetPointData()->AddArray(scaleFactors);
    poly_data->GetPointData()->AddArray(orientation);

    // Create anything you want here, we will use a cube for the demo.
    vtkNew<vtkCubeSource> cubeSource;

    vtkNew<vtkGlyph3DMapper> glyph3Dmapper;
    glyph3Dmapper->SetSourceConnection(cubeSource->GetOutputPort());
    glyph3Dmapper->SetInputData(poly_data);
    glyph3Dmapper->SetScalarModeToUsePointFieldData();
    glyph3Dmapper->SetScaleArray("Scale Factors");
    glyph3Dmapper->SetScaleModeToScaleByVectorComponents();
    glyph3Dmapper->SelectColorArray("Colors");
    glyph3Dmapper->SetOrientationModeToRotation();
    glyph3Dmapper->SetOrientationArray("orientation");
    glyph3Dmapper->Update();

    vtkNew<vtkActor> actor;
    actor->SetMapper(glyph3Dmapper);

    // Create a renderer, render window, and interactor.
    vtkNew<vtkRenderer> renderer;
    vtkNew<vtkRenderWindow> renderWindow;
    renderWindow->AddRenderer(renderer);
    renderWindow->SetWindowName("Glyph3DMapper");

    vtkNew<vtkRenderWindowInteractor> renderWindowInteractor;
    renderWindowInteractor->SetRenderWindow(renderWindow);
    vtkNew<vtkInteractorStyleTrackballCamera> style;
    renderWindowInteractor->SetInteractorStyle(style);

    // Add the actor to the scene.
    renderer->AddActor(actor);
    renderer->SetBackground(namedColors->GetColor3d("SlateGray").GetData());

    // Position the camera.
    vtkSmartPointer<vtkCamera> camera =
            vtkSmartPointer<vtkCamera>::New();
    camera->SetParallelProjection(true);
    camera->SetPosition(20, 0, 100);
    camera->SetFocalPoint(20, 0, 0);
    renderer->SetActiveCamera(camera);
    renderer->ResetCamera();

    // Render and interact.
    renderWindow->Render();
    renderWindowInteractor->Initialize();
    renderWindowInteractor->Start();
    return EXIT_SUCCESS;
}

If you have transparent actors in the renderer then you may need to enable depth peeling for correct appearance. I don’t know if the changing in antialiasing behavior is expected or not.

Thanks Andras. I find a old vtk document and enable depth peeling by

        renderWindow->SetAlphaBitPlanes(1);
        renderWindow->SetMultiSamples(0);
        renderer->SetUseDepthPeeling(1);
        renderer->SetMaximumNumberOfPeels(100);
        renderer->SetOcclusionRatio(1.0);

When open depth peeling, the problem 1 is solved. But the problem 2 still exist. I tried FXAA, the result is not so good. And SSAA will get a totally wrong render result.

(1) If one of the object is semi-transparent or totally transparent, other objects become transparent too.
(2) If one of the object is semi-transparent or totally transparent, anti-alias seems not work again.

I’m pretty sure that when there’s translucent object in the scene, the MultiSample Anti-alias doesn’t work on translucent object. Can anyone help me ?