Benjamin Guignabert пре 8 година
родитељ
комит
70e7ee9e51

Разлика између датотеке није приказан због своје велике величине
+ 1250 - 1250
dist/preview release/babylon.d.ts


Разлика између датотеке није приказан због своје велике величине
+ 1250 - 1250
dist/preview release/babylon.module.d.ts


+ 4 - 6
src/PostProcess/babylon.ssao2RenderingPipeline.ts

@@ -117,10 +117,10 @@
             this._depthTexture = scene.enableGeometryRenderer().getGBuffer().depthTexture; 
             this._depthTexture = scene.enableGeometryRenderer().getGBuffer().depthTexture; 
             this._normalTexture = scene.enableGeometryRenderer().getGBuffer().textures[1];
             this._normalTexture = scene.enableGeometryRenderer().getGBuffer().textures[1];
 
 
-            this._originalColorPostProcess = new PassPostProcess("SSAOOriginalSceneColor", combineRatio, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
-            this._createSSAOPostProcess(ssaoRatio);
+            this._originalColorPostProcess = new PassPostProcess("SSAOOriginalSceneColor", 1.0, null, Texture.BILINEAR_SAMPLINGMODE, scene.getEngine(), false);
+            this._createSSAOPostProcess(1.0);
             this._createBlurPostProcess(ssaoRatio);
             this._createBlurPostProcess(ssaoRatio);
-            this._createSSAOCombinePostProcess(combineRatio);
+            this._createSSAOCombinePostProcess(ssaoRatio);
 
 
             // Set up pipeline
             // Set up pipeline
             this.addEffect(new PostProcessRenderEffect(scene.getEngine(), this.SSAOOriginalSceneColorEffect, () => { return this._originalColorPostProcess; }, true));
             this.addEffect(new PostProcessRenderEffect(scene.getEngine(), this.SSAOOriginalSceneColorEffect, () => { return this._originalColorPostProcess; }, true));
@@ -243,7 +243,7 @@
             this._ssaoPostProcess = new PostProcess("ssao2", "ssao2",
             this._ssaoPostProcess = new PostProcess("ssao2", "ssao2",
                                                     [
                                                     [
                                                         "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
                                                         "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
-                                                        "base", "range", "viewport", "projection", "near", "far",
+                                                        "base", "range", "projection", "near", "far",
                                                         "xViewport", "yViewport"
                                                         "xViewport", "yViewport"
                                                     ],
                                                     ],
                                                     ["randomSampler", "normalSampler"],
                                                     ["randomSampler", "normalSampler"],
@@ -251,8 +251,6 @@
                                                     this._scene.getEngine(), false,
                                                     this._scene.getEngine(), false,
                                                     "#define SAMPLES " + numSamples + "\n#define SSAO");
                                                     "#define SAMPLES " + numSamples + "\n#define SSAO");
 
 
-            var viewport = new Vector2(0, 0);
-
             this._ssaoPostProcess.onApply = (effect: Effect) => {
             this._ssaoPostProcess.onApply = (effect: Effect) => {
                 if (this._firstUpdate) {
                 if (this._firstUpdate) {
                     effect.setArray3("sampleSphere", sampleSphere);
                     effect.setArray3("sampleSphere", sampleSphere);

+ 5 - 1
src/Shaders/ssao2.fragment.fx

@@ -124,6 +124,10 @@ vec4 linearUpsample(sampler2D image, vec2 uv, float resolution, vec2 direction)
 	return color;
 	return color;
 }
 }
 
 
+float gaussianKernel[16] = float[16](
+0.001014, 0.003314, 0.009248, 0.022042, 0.044857, 0.077951, 0.115676, 0.146586, 0.146586, 0.115676, 0.077951, 0.044857, 0.022042, 0.009248, 0.003314, 0.001014
+);
+
 void main()
 void main()
 {
 {
 	float texelsize = 1.0 / outSize;
 	float texelsize = 1.0 / outSize;
@@ -147,7 +151,7 @@ void main()
 
 
 		float sampleDepth = texture2D(depthSampler, samplePos).r;
 		float sampleDepth = texture2D(depthSampler, samplePos).r;
 		float linearSampleDepth = - perspectiveDepthToViewZ(sampleDepth, near, far);
 		float linearSampleDepth = - perspectiveDepthToViewZ(sampleDepth, near, far);
-		float weight = clamp(1.0 / ( 0.01 + abs(linearDepth - linearSampleDepth)), 0.0, 100.0);
+		float weight = clamp(1.0 / ( 0.003 + abs(linearDepth - linearSampleDepth)), 0.0, 30.0) * gaussianKernel[i];
 
 
 		result += texture2D(textureSampler, samplePos).r * weight;
 		result += texture2D(textureSampler, samplePos).r * weight;
 		weightSum += weight;
 		weightSum += weight;