Skip to content

Commit

Permalink
Merge pull request Kitware#1928 from boucaud/backport-LIC-fixes
Browse files Browse the repository at this point in the history
fix(surfacelicmapper): backport LIC fixes from VTK
  • Loading branch information
finetjul authored May 26, 2021
2 parents 97e7334 + bebaf31 commit e240148
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion Sources/Rendering/OpenGL/SurfaceLIC/SurfaceLICMapper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ function vtkOpenGLSurfaceLICMapper(publicAPI, model) {

shaders.Fragment = FSSource;
superClass.replaceShaderValues(shaders, ren, actor);
model.lastBoundBO.set({ lastLightComplexity: prevComplexity }, true);
if (prevComplexity > 0) {
model.lastBoundBO.set({ lastLightComplexity: prevComplexity }, true);
}
};

publicAPI.setMapperShaderParameters = (cellBO, ren, actor) => {
Expand Down Expand Up @@ -122,6 +124,7 @@ function vtkOpenGLSurfaceLICMapper(publicAPI, model) {
[gl.BLEND]: gl.isEnabled(gl.BLEND),
[gl.DEPTH_TEST]: gl.isEnabled(gl.DEPTH_TEST),
[gl.SCISSOR_TEST]: gl.isEnabled(gl.SCISSOR_TEST),
[gl.CULL_FACE]: gl.isEnabled(gl.CULL_FACE),
};
};

Expand All @@ -131,6 +134,7 @@ function vtkOpenGLSurfaceLICMapper(publicAPI, model) {
apply(gl.BLEND);
apply(gl.DEPTH_TEST);
apply(gl.SCISSOR_TEST);
apply(gl.CULL_FACE);
};

publicAPI.renderPiece = (ren, actor) => {
Expand Down Expand Up @@ -199,6 +203,20 @@ function vtkOpenGLSurfaceLICMapper(publicAPI, model) {
return;
}

// apply faceCulling
const gl = model.context;
const backfaceCulling = actor.getProperty().getBackfaceCulling();
const frontfaceCulling = actor.getProperty().getFrontfaceCulling();
if (!backfaceCulling && !frontfaceCulling) {
model.openGLRenderWindow.disableCullFace();
} else if (frontfaceCulling) {
model.openGLRenderWindow.enableCullFace();
gl.cullFace(gl.FRONT);
} else {
model.openGLRenderWindow.enableCullFace();
gl.cullFace(gl.BACK);
}

const windowSize = model.openGLRenderWindow.getSize();
const size = windowSize.map((i) =>
Math.round(i * licInterface.getViewPortScale())
Expand All @@ -223,6 +241,7 @@ function vtkOpenGLSurfaceLICMapper(publicAPI, model) {
publicAPI.pushState(model.context);
model.VBOBuildTime.modified();
model.openGLLicInterface.completedGeometry();
model.context.disable(model.context.CULL_FACE);
model.openGLLicInterface.applyLIC();
model.openGLLicInterface.combineColorsAndLIC();
model.openGLLicInterface.copyToScreen(windowSize);
Expand Down

0 comments on commit e240148

Please sign in to comment.