Please, does anybody have a clue, how to correctly render transparent
objects in parallel?

I attach the modified version of
http://www.vtk.org/Wiki/VTK/MultiPass_Rendering_With_IceT and screenshots
of the render windows for MPI rank 0,1,2 (from left to right), first with
SetOpacity(1), second with SetOpacity(0.5). In the second case, you see the
artifacts in the blue segment, and (worse) that rank 0 shows a black window
instead of the composite image.

Thank you
Kai

On Mon, Apr 25, 2016 at 5:41 PM, Kai Winter <[email protected]> wrote:

> Hello,
> is it possible to extend the example at
> http://www.vtk.org/Wiki/VTK/MultiPass_Rendering_With_IceT for parallel
> rendering including transparent objects?
>
> I have tried to modify the above example by first setting
>   actor->GetProperty()->SetOpacity(0.3);
> after creation of the actor, and, second, adding
>   vtkSmartPointer<vtkTranslucentPass> translucent =
> vtkSmartPointer<vtkTranslucentPass>::New();
>   passes->AddItem(translucent);
> after the original line "passes->AddItem(opaque);".
>
> The result is for example, when running with 3 MPI processes:
> The sphere segments in the partial Renderers of process 1 and 2 are
> transparent (but show some artefacts).
> The composite Renderer of process 0 doesn't show any sphere, just the
> black background!
> When the opacity is set to 1, the sphere segments are composited in three
> colors on process 0 as expected.
>
> What is required to correctly perform parallel rendering including
> transparency?
> (I am using ParaView-v5.0.1, compiled from source on Ubuntu 15.04)
>
> Thank you
> Kai
>
>
// A simple example that demonstrate how to use the vtkIceTCompositePass and
// supporting classes to render a sphere in parallel.
// This only uses the minimal set of functionality and hence does not support
// opacity < 1.0.
 
 
#include <vtkAutoInit.h>
VTK_MODULE_INIT(vtkRenderingOpenGL);

#include "vtkActor.h"
#include "vtkProperty.h"
#include "vtkCamera.h"
#include "vtkCameraPass.h"
#include "vtkIceTCompositePass.h"
#include "vtkLightsPass.h"
#include "vtkMPIController.h"
#include "vtkOpaquePass.h"
#include "vtkTranslucentPass.h"
#include "vtkPieceScalars.h"
#include "vtkPolyDataMapper.h"
#include "vtkPSphereSource.h"
#include "vtkRenderer.h"
#include "vtkOpenGLRenderer.h"
#include "vtkRenderPassCollection.h"
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
#include "vtkSequencePass.h"
#include "vtkSmartPointer.h"
#include "vtkSynchronizedRenderers.h"
#include "vtkSynchronizedRenderWindows.h"

int main(int argc, char**argv)
{
  //---------------------------------------------------------------------------
  // Initialize MPI.
 
  vtkMPIController* controller = vtkMPIController::New();
  controller->Initialize(&argc, &argv);
  vtkMultiProcessController::SetGlobalController(controller);
 
  // Get information about the group of processes involved.
  int my_id = controller->GetLocalProcessId();
  int num_procs = controller->GetNumberOfProcesses();
 
  //---------------------------------------------------------------------------
  // Create Visualization Pipeline.
  // This code is common to all processes.
  vtkSmartPointer<vtkPSphereSource> sphere = vtkSmartPointer<vtkPSphereSource>::New();
  sphere->SetThetaResolution(50);
  sphere->SetPhiResolution(50);
 
  // Gives separate colors for each process. Just makes it easier to see how the
  // data is distributed among processes.
  vtkSmartPointer<vtkPieceScalars> piecescalars =
    vtkSmartPointer<vtkPieceScalars>::New();
  piecescalars->SetInputConnection(sphere->GetOutputPort());
  piecescalars->SetScalarModeToCellData();
 
  vtkSmartPointer<vtkPolyDataMapper> mapper = vtkSmartPointer<vtkPolyDataMapper>::New();
  mapper->SetInputConnection(piecescalars->GetOutputPort());
  mapper->SetScalarModeToUseCellFieldData();
  mapper->SelectColorArray("Piece");
  mapper->SetScalarRange(0, num_procs-1);
  // This sets up the piece-request. This tells vtkPSphereSource to only
  // generate part of the data on this processes.
  mapper->SetPiece(my_id);
  mapper->SetNumberOfPieces(num_procs);
 
  vtkSmartPointer<vtkActor> actor = vtkSmartPointer<vtkActor>::New();
  actor->GetProperty()->SetOpacity(0.5);
  actor->SetMapper(mapper);
 
  //vtkSmartPointer<vtkRenderer> renderer = vtkSmartPointer<vtkRenderer>::New();
  vtkSmartPointer<vtkOpenGLRenderer> renderer = vtkSmartPointer<vtkOpenGLRenderer>::New();
  renderer->AddActor(actor);
 
  vtkSmartPointer<vtkRenderWindow> renWin = vtkSmartPointer<vtkRenderWindow>::New();
  renWin->AddRenderer(renderer);
 
  //---------------------------------------------------------------------------
  // Setup the render passes. This is just a very small subset of necessary
  // render passes needed to render a opaque sphere.
  vtkSmartPointer<vtkCameraPass> cameraP = vtkSmartPointer<vtkCameraPass>::New();
  vtkSmartPointer<vtkSequencePass> seq = vtkSmartPointer<vtkSequencePass>::New();
  vtkSmartPointer<vtkOpaquePass> opaque = vtkSmartPointer<vtkOpaquePass>::New();
  vtkSmartPointer<vtkTranslucentPass> translucent = vtkSmartPointer<vtkTranslucentPass>::New();
  vtkSmartPointer<vtkLightsPass> lights = vtkSmartPointer<vtkLightsPass>::New();
  vtkSmartPointer<vtkRenderPassCollection> passes =
    vtkSmartPointer<vtkRenderPassCollection>::New();
  passes->AddItem(lights);
  passes->AddItem(opaque);
  passes->AddItem(translucent);
  seq->SetPasses(passes);
 
  // Each processes only has part of the data, so each process will render only
  // part of the data. To ensure that root node gets a composited result (or in
  // case of tile-display mode all nodes show part of tile), we use
  // vtkIceTCompositePass.
  vtkSmartPointer<vtkIceTCompositePass> iceTPass =
    vtkSmartPointer<vtkIceTCompositePass>::New();
  iceTPass->SetController(controller);
 
  // this is the pass IceT is going to use to render the geometry.
  iceTPass->SetRenderPass(seq);
 
  // insert the iceT pass into the pipeline.
  cameraP->SetDelegatePass(iceTPass);
  renderer->SetPass(cameraP);
 
  //---------------------------------------------------------------------------
  // In parallel configurations, typically one node acts as the driver i.e. the
  // node where the user interacts with the window e.g. mouse interactions,
  // resizing windows etc. Typically that's the root-node.
  // To ensure that the window parameters get propagated to all processes from
  // the root node, we use the vtkSynchronizedRenderWindows.
  vtkSmartPointer<vtkSynchronizedRenderWindows> syncWindows =
    vtkSmartPointer<vtkSynchronizedRenderWindows>::New();
  syncWindows->SetRenderWindow(renWin);
  syncWindows->SetParallelController(controller);
 
  // Since there could be multiple render windows that could be synced
  // separately, to identify the windows uniquely among all processes, we need
  // to give each vtkSynchronizedRenderWindows a unique id that's consistent
  // across all the processes.
  syncWindows->SetIdentifier(231);
 
  // Now we need to ensure that the render is synchronized as well. This is
  // essential to ensure all processes have the same camera orientation etc.
  // This is done using the vtkSynchronizedRenderers class.
  vtkSmartPointer<vtkSynchronizedRenderers> syncRenderers =
    vtkSmartPointer<vtkSynchronizedRenderers>::New();
  syncRenderers->SetRenderer(renderer);
  syncRenderers->SetParallelController(controller);
 
  //---------------------------------------------------------------------------
  // Now start the event loop on the root node, on the satellites, we start the
  // vtkMultiProcessController::ProcessRMIs() so those processes start listening
  // to commands from the root-node.
 
  if (my_id==0)
    {
    vtkSmartPointer<vtkRenderWindowInteractor> iren =
      vtkSmartPointer<vtkRenderWindowInteractor>::New();
    iren->SetRenderWindow(renWin);
    iren->Start();
 
    controller->TriggerBreakRMIs();
    controller->Barrier();
    }
  else
    {
    controller->ProcessRMIs();
    controller->Barrier();
    }
 
  controller->Finalize();
  vtkMultiProcessController::SetGlobalController(NULL);
  controller->Delete();
  return 0;
}
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the ParaView Wiki at: 
http://paraview.org/Wiki/ParaView

Search the list archives at: http://markmail.org/search/?q=ParaView

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/paraview

Reply via email to