I am rendering a volume and I tried to set the shade to 1 just like https://kitware.github.io/vtk-js/examples/TestVolumeTypes.html but the example showed an obvious different while mine did not. I was just curious if there are other things I need to set up too in order to see a difference.
Can you please post a code snippet of what you are doing? That way we can have a better idea of what you are doing and what needs to be changed.
const reader = vtkXMLImageDataReader.newInstance();
const volumeMapper = vtkVolumeMapper.newInstance();
const volumeActor = vtkVolume.newInstance();
const cropFilter = vtkImageCropFilter.newInstance();
reader
.setUrl(`./${fileName}`, {loadData:true, progressCallback,})
.then(() => {
const data = reader.getOutputData();
*** Processing the data a little bit and set it to a labelmap ***
cropFilter.setInputData(labelMap);
const lookupTable = vtkColorTransferFunction.newInstance();
const ofun = vtkPiecewiseFunction.newInstance();
ofun.addPoint((max/2), 1.0);
ofun.addPoint(0, 0);
ofun.addPoint((max), 0.0);
lookupTable.setNumberOfValues(dataRange[1]- dataRange[0]+1);
lookupTable.setDiscretize(true);
volumeActor.getProperty().setShade(1);
volumeActor.getProperty().setUseGradientOpacity(0, false);
volumeActor.getProperty().setOpacityMode(0,1)
volumeActor.getProperty().setAmbient(0.0);
volumeActor.getProperty().setDiffuse(0.0);
volumeActor.getProperty().setSpecular(0.8);
volumeActor.getProperty().setSpecularPower(30.0);
volumeActor.getProperty().setRGBTransferFunction(0, lookupTable);
volumeActor.getProperty().setScalarOpacity(0, ofun);
volumeMapper.setInputConnection(cropFilter.getOutputPort());
const sampleDistance =
0.7 *
Math.sqrt(
data
.getSpacing()
.map((v) => v * v)
.reduce((a, b) => a + b, 0)
);
volumeMapper.setSampleDistance(sampleDistance);
volumeActor.setMapper(volumeMapper);
renderer.addVolume(volumeActor);
}
Here is a snippet of it, I removed some of the data processing I was doing which basically just took values that are extremely large or small and mapped them to be closer to the dataset.
I solved the issue it was because I added
volumeActor.getProperty().setOpacityMode(0,1)
Which I think somehow caused the renderer to override the shading.