Partial transparency rendering issue

Hi,

I’m using a vtkLookupTable to make some label semi-transparent in a vtkpolydata, with label data in a point data array. But the the transparency is not rendered correctly when camera turned to certain angle.

I uploaded a video to show the issue: vtk-js_label_transparency_issue.mov - Google Drive

In the video, when the camera is above the model, the label supposed to be transparent is only darkened but not transparent. When the camera moves below the model, it start to render the transparency correctly.

Here’s my code generating the lookup table. Where labelRGBA is a map from labels to RGBA arrays.

function CreateLabelLUT(labelRGBA) {
  const numberOfColors = labelRGBA.size;
  const tableBuffer = new Uint8Array(4 * numberOfColors);
  const range = GetLabelRange(labelRGBA);
  const lut = vtkLookupTable.newInstance();
  lut.setIndexedLookup(true);
  lut.setRange(range[0], range[1]);
  lut.setNumberOfColors(numberOfColors);

  // make sure label number is mapped to the table
  for (let i = 0; i < numberOfColors; i++) {
    lut.setAnnotation(i, i);
  }

  let offset = 0;
  for (const [key, value] of labelRGBA) {
    for (let i = 0; i < 4; i++)
      tableBuffer[offset++] = value[i] * 255;
  }

  const table = vtkDataArray.newInstance({
    numberOfComponents: 4,
    size: 4 * numberOfColors,
    dataType: 'Uint8Array',
    name: "LabelLUT",
    values: tableBuffer,
  });

  lut.setTable(table);

  return lut;
}

Is it a bug? Or is there anything I could change in the LUT configuration?

it looks as if your actor is considered opaque. did you try to call setForceTranslucent(true) on your actor ?

Hi Julien, thanks for the reply! Forcing translucent works but it sets all labels transparent to some degree. Is there anyway to only make some label transparent while others are opaque?

You might need to separate out the the parts of the geometry that are opaque into a separate actor.

OK Thanks! But it would be nice to have the Alpha granularity based on index at point/cell data level. Is it something by design or would there be any change later?