|
@@ -53,6 +53,19 @@ function getDepthMergeRenderable(ctx: WebGLContext, depthTexturePrimitives: Text
|
|
return createComputeRenderable(renderItem, values);
|
|
return createComputeRenderable(renderItem, values);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+type Props = {
|
|
|
|
+ postprocessing: PostprocessingProps
|
|
|
|
+ marking: MarkingProps
|
|
|
|
+ transparentBackground: boolean;
|
|
|
|
+}
|
|
|
|
+
|
|
|
|
+type RenderContext = {
|
|
|
|
+ renderer: Renderer;
|
|
|
|
+ camera: Camera | StereoCamera;
|
|
|
|
+ scene: Scene;
|
|
|
|
+ helper: Helper;
|
|
|
|
+}
|
|
|
|
+
|
|
export class DrawPass {
|
|
export class DrawPass {
|
|
private readonly drawTarget: RenderTarget;
|
|
private readonly drawTarget: RenderTarget;
|
|
|
|
|
|
@@ -264,25 +277,25 @@ export class DrawPass {
|
|
renderer.renderBlendedTransparent(scene.primitives, camera, null);
|
|
renderer.renderBlendedTransparent(scene.primitives, camera, null);
|
|
}
|
|
}
|
|
|
|
|
|
- private _render(renderer: Renderer, camera: ICamera, scene: Scene, helper: Helper, toDrawingBuffer: boolean, transparentBackground: boolean, postprocessingProps: PostprocessingProps, markingProps: MarkingProps) {
|
|
|
|
|
|
+ private _render(renderer: Renderer, camera: ICamera, scene: Scene, helper: Helper, toDrawingBuffer: boolean, props: Props) {
|
|
const volumeRendering = scene.volumes.renderables.length > 0;
|
|
const volumeRendering = scene.volumes.renderables.length > 0;
|
|
- const postprocessingEnabled = PostprocessingPass.isEnabled(postprocessingProps);
|
|
|
|
- const antialiasingEnabled = AntialiasingPass.isEnabled(postprocessingProps);
|
|
|
|
- const markingEnabled = MarkingPass.isEnabled(markingProps);
|
|
|
|
|
|
+ const postprocessingEnabled = PostprocessingPass.isEnabled(props.postprocessing);
|
|
|
|
+ const antialiasingEnabled = AntialiasingPass.isEnabled(props.postprocessing);
|
|
|
|
+ const markingEnabled = MarkingPass.isEnabled(props.marking);
|
|
|
|
|
|
const { x, y, width, height } = camera.viewport;
|
|
const { x, y, width, height } = camera.viewport;
|
|
renderer.setViewport(x, y, width, height);
|
|
renderer.setViewport(x, y, width, height);
|
|
renderer.update(camera);
|
|
renderer.update(camera);
|
|
|
|
|
|
- if (transparentBackground && !antialiasingEnabled && toDrawingBuffer) {
|
|
|
|
|
|
+ if (props.transparentBackground && !antialiasingEnabled && toDrawingBuffer) {
|
|
this.drawTarget.bind();
|
|
this.drawTarget.bind();
|
|
renderer.clear(false);
|
|
renderer.clear(false);
|
|
}
|
|
}
|
|
|
|
|
|
if (this.wboitEnabled) {
|
|
if (this.wboitEnabled) {
|
|
- this._renderWboit(renderer, camera, scene, transparentBackground, postprocessingProps);
|
|
|
|
|
|
+ this._renderWboit(renderer, camera, scene, props.transparentBackground, props.postprocessing);
|
|
} else {
|
|
} else {
|
|
- this._renderBlended(renderer, camera, scene, !volumeRendering && !postprocessingEnabled && !antialiasingEnabled && toDrawingBuffer, transparentBackground, postprocessingProps);
|
|
|
|
|
|
+ this._renderBlended(renderer, camera, scene, !volumeRendering && !postprocessingEnabled && !antialiasingEnabled && toDrawingBuffer, props.transparentBackground, props.postprocessing);
|
|
}
|
|
}
|
|
|
|
|
|
if (postprocessingEnabled) {
|
|
if (postprocessingEnabled) {
|
|
@@ -294,7 +307,7 @@ export class DrawPass {
|
|
}
|
|
}
|
|
|
|
|
|
if (markingEnabled) {
|
|
if (markingEnabled) {
|
|
- const markingDepthTest = markingProps.ghostEdgeStrength < 1;
|
|
|
|
|
|
+ const markingDepthTest = props.marking.ghostEdgeStrength < 1;
|
|
if (markingDepthTest) {
|
|
if (markingDepthTest) {
|
|
this.marking.depthTarget.bind();
|
|
this.marking.depthTarget.bind();
|
|
renderer.clear(false);
|
|
renderer.clear(false);
|
|
@@ -305,7 +318,7 @@ export class DrawPass {
|
|
renderer.clear(false);
|
|
renderer.clear(false);
|
|
renderer.renderMarkingMask(scene.primitives, camera, markingDepthTest ? this.marking.depthTarget.texture : null);
|
|
renderer.renderMarkingMask(scene.primitives, camera, markingDepthTest ? this.marking.depthTarget.texture : null);
|
|
|
|
|
|
- this.marking.update(markingProps);
|
|
|
|
|
|
+ this.marking.update(props.marking);
|
|
this.marking.render(camera.viewport, postprocessingEnabled ? this.postprocessing.target : this.colorTarget);
|
|
this.marking.render(camera.viewport, postprocessingEnabled ? this.postprocessing.target : this.colorTarget);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -323,7 +336,7 @@ export class DrawPass {
|
|
}
|
|
}
|
|
|
|
|
|
if (antialiasingEnabled) {
|
|
if (antialiasingEnabled) {
|
|
- this.antialiasing.render(camera, toDrawingBuffer, postprocessingProps);
|
|
|
|
|
|
+ this.antialiasing.render(camera, toDrawingBuffer, props.postprocessing);
|
|
} else if (toDrawingBuffer) {
|
|
} else if (toDrawingBuffer) {
|
|
this.drawTarget.bind();
|
|
this.drawTarget.bind();
|
|
|
|
|
|
@@ -338,16 +351,17 @@ export class DrawPass {
|
|
this.webgl.gl.flush();
|
|
this.webgl.gl.flush();
|
|
}
|
|
}
|
|
|
|
|
|
- render(renderer: Renderer, camera: Camera | StereoCamera, scene: Scene, helper: Helper, toDrawingBuffer: boolean, transparentBackground: boolean, postprocessingProps: PostprocessingProps, markingProps: MarkingProps) {
|
|
|
|
- renderer.setTransparentBackground(transparentBackground);
|
|
|
|
|
|
+ render(ctx: RenderContext, props: Props, toDrawingBuffer: boolean) {
|
|
|
|
+ const { renderer, camera, scene, helper } = ctx;
|
|
|
|
+ renderer.setTransparentBackground(props.transparentBackground);
|
|
renderer.setDrawingBufferSize(this.colorTarget.getWidth(), this.colorTarget.getHeight());
|
|
renderer.setDrawingBufferSize(this.colorTarget.getWidth(), this.colorTarget.getHeight());
|
|
renderer.setPixelRatio(this.webgl.pixelRatio);
|
|
renderer.setPixelRatio(this.webgl.pixelRatio);
|
|
|
|
|
|
if (StereoCamera.is(camera)) {
|
|
if (StereoCamera.is(camera)) {
|
|
- this._render(renderer, camera.left, scene, helper, toDrawingBuffer, transparentBackground, postprocessingProps, markingProps);
|
|
|
|
- this._render(renderer, camera.right, scene, helper, toDrawingBuffer, transparentBackground, postprocessingProps, markingProps);
|
|
|
|
|
|
+ this._render(renderer, camera.left, scene, helper, toDrawingBuffer, props);
|
|
|
|
+ this._render(renderer, camera.right, scene, helper, toDrawingBuffer, props);
|
|
} else {
|
|
} else {
|
|
- this._render(renderer, camera, scene, helper, toDrawingBuffer, transparentBackground, postprocessingProps, markingProps);
|
|
|
|
|
|
+ this._render(renderer, camera, scene, helper, toDrawingBuffer, props);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|