Trevor Baron 7 роки тому
батько
коміт
b20f5b3c9c

+ 5 - 4
src/PostProcess/babylon.circleOfConfusionPostProcess.ts

@@ -1,8 +1,9 @@
 module BABYLON {
     export class CircleOfConfusionPostProcess extends PostProcess {
-        fStop = 4; // Aperture = focalLength/fStop
-        focusDistance = 15; // in scene units (eg. meter)
-        focalLength = 10; // in scene units/1000 (eg. millimeter)
+        lensSize = 50 // in scene units/1000 (eg. millimeter)
+        fStop = 1.4; // Aperture = lensSize/fStop
+        focusDistance = 15000; // in scene units/1000 (eg. millimeter)
+        focalLength = 500; // in scene units/1000 (eg. millimeter)
 
         
         constructor(name: string, depthTexture: RenderTargetTexture, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT) {
@@ -11,7 +12,7 @@ module BABYLON {
                 effect.setTexture("depthSampler", depthTexture);
                 
                 // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
-                var aperture = this.focalLength/this.fStop;
+                var aperture = this.lensSize/this.fStop;
                 var cocPrecalculation = ((aperture * this.focalLength)/((this.focusDistance - this.focalLength)));// * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
                 
                 effect.setFloat('focusDistance', this.focusDistance);

+ 1 - 1
src/Shaders/circleOfConfusion.fragment.fx

@@ -14,7 +14,7 @@ uniform float cocPrecalculation;
 
 float sampleDistance(const in vec2 offset) {
     float depth = texture2D(depthSampler, offset).r;	// depth value from DepthRenderer: 0 to 1
-	return near + (far - near)*depth;		            // actual distance from the lens
+	return (near + (far - near)*depth)*1000.0;		            // actual distance from the lens in scene units/1000 (eg. millimeter)
 }
 
 void main(void)