|
@@ -385,6 +385,16 @@ export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
|
|
|
return defines;
|
|
|
}
|
|
|
|
|
|
+ private static readonly ORTHO_DEPTH_PROJECTION = [
|
|
|
+ 1, 0, 0,
|
|
|
+ 0, 1, 0,
|
|
|
+ 0, 0, 1];
|
|
|
+
|
|
|
+ private static readonly PERSPECTIVE_DEPTH_PROJECTION = [
|
|
|
+ 0, 0, 0,
|
|
|
+ 0, 0, 0,
|
|
|
+ 1, 1, 1];
|
|
|
+
|
|
|
private _createSSAOPostProcess(ratio: number): void {
|
|
|
this._sampleSphere = this._generateHemisphere();
|
|
|
|
|
@@ -401,7 +411,7 @@ export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
|
|
|
[
|
|
|
"sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
|
|
|
"base", "range", "projection", "near", "far", "texelSize",
|
|
|
- "xViewport", "yViewport", "maxZ", "minZAspect", "orthoProjection"
|
|
|
+ "xViewport", "yViewport", "maxZ", "minZAspect", "depthProjection"
|
|
|
],
|
|
|
samplers,
|
|
|
ratio, null, Texture.BILINEAR_SAMPLINGMODE,
|
|
@@ -425,7 +435,7 @@ export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
|
|
|
effect.setFloat("near", this._scene.activeCamera.minZ);
|
|
|
effect.setFloat("far", this._scene.activeCamera.maxZ);
|
|
|
if (this._scene.activeCamera.mode === Camera.PERSPECTIVE_CAMERA) {
|
|
|
- effect.setInt("orthoProjection", 0);
|
|
|
+ effect.setMatrix3x3("depthProjection", SSAO2RenderingPipeline.PERSPECTIVE_DEPTH_PROJECTION);
|
|
|
effect.setFloat("xViewport", Math.tan(this._scene.activeCamera.fov / 2) * this._scene.getEngine().getAspectRatio(this._scene.activeCamera, true));
|
|
|
effect.setFloat("yViewport", Math.tan(this._scene.activeCamera.fov / 2));
|
|
|
} else {
|
|
@@ -435,7 +445,7 @@ export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
|
|
|
const orthoRight = this._scene.activeCamera.orthoRight ?? halfWidth;
|
|
|
const orthoBottom = this._scene.activeCamera.orthoBottom ?? -halfHeight;
|
|
|
const orthoTop = this._scene.activeCamera.orthoTop ?? halfHeight;
|
|
|
- effect.setInt("orthoProjection", 1);
|
|
|
+ effect.setMatrix3x3("depthProjection", SSAO2RenderingPipeline.ORTHO_DEPTH_PROJECTION);
|
|
|
effect.setFloat("xViewport", (orthoRight - orthoLeft) * 0.5);
|
|
|
effect.setFloat("yViewport", (orthoTop - orthoBottom) * 0.5);
|
|
|
}
|