瀏覽代碼

Added passCube pp

David Catuhe 6 年之前
父節點
當前提交
22e02ec8db

文件差異過大導致無法顯示
+ 1792 - 1764
Playground/babylon.d.txt


+ 2 - 1
Tools/Gulp/config.json

@@ -794,7 +794,8 @@
             ],
             "shaders": [
                 "postprocess.vertex",
-                "pass.fragment"
+                "pass.fragment",
+                "passCube.fragment"
             ]
         },
         "additionalPostProcess_blur": {

文件差異過大導致無法顯示
+ 1792 - 1764
dist/preview release/babylon.d.ts


文件差異過大導致無法顯示
+ 1 - 1
dist/preview release/babylon.js


文件差異過大導致無法顯示
+ 73 - 1
dist/preview release/babylon.max.js


文件差異過大導致無法顯示
+ 73 - 1
dist/preview release/babylon.no-module.max.js


文件差異過大導致無法顯示
+ 1 - 1
dist/preview release/babylon.worker.js


文件差異過大導致無法顯示
+ 75 - 3
dist/preview release/es6.js


+ 19 - 0
dist/preview release/viewer/babylon.viewer.d.ts

@@ -1844,6 +1844,25 @@ declare module BabylonViewer {
     }
 }
 declare module BabylonViewer {
+    export interface IDefaultRenderingPipelineConfiguration {
+        sharpenEnabled?: boolean;
+        bloomEnabled?: boolean;
+        bloomThreshold?: number;
+        depthOfFieldEnabled?: boolean;
+        depthOfFieldBlurLevel?: BABYLON.DepthOfFieldEffectBlurLevel;
+        fxaaEnabled?: boolean;
+        imageProcessingEnabled?: boolean;
+        defaultPipelineTextureType?: number;
+        bloomScale?: number;
+        chromaticAberrationEnabled?: boolean;
+        grainEnabled?: boolean;
+        bloomKernel?: number;
+        hardwareScaleLevel?: number;
+        bloomWeight?: number;
+        hdr?: boolean;
+        samples?: number;
+        glowLayerEnabled?: boolean;
+    }
 }
 declare module BabylonViewer {
     export interface IGroundConfiguration {

文件差異過大導致無法顯示
+ 1 - 1
dist/preview release/viewer/babylon.viewer.js


文件差異過大導致無法顯示
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 20 - 1
dist/preview release/viewer/babylon.viewer.module.d.ts

@@ -1990,7 +1990,26 @@ declare module 'babylonjs-viewer/configuration/interfaces/colorGradingConfigurat
 }
 
 declare module 'babylonjs-viewer/configuration/interfaces/defaultRenderingPipelineConfiguration' {
-    
+    import { DepthOfFieldEffectBlurLevel } from 'babylonjs';
+    export interface IDefaultRenderingPipelineConfiguration {
+        sharpenEnabled?: boolean;
+        bloomEnabled?: boolean;
+        bloomThreshold?: number;
+        depthOfFieldEnabled?: boolean;
+        depthOfFieldBlurLevel?: DepthOfFieldEffectBlurLevel;
+        fxaaEnabled?: boolean;
+        imageProcessingEnabled?: boolean;
+        defaultPipelineTextureType?: number;
+        bloomScale?: number;
+        chromaticAberrationEnabled?: boolean;
+        grainEnabled?: boolean;
+        bloomKernel?: number;
+        hardwareScaleLevel?: number;
+        bloomWeight?: number;
+        hdr?: boolean;
+        samples?: number;
+        glowLayerEnabled?: boolean;
+    }
 }
 
 declare module 'babylonjs-viewer/configuration/interfaces/groundConfiguration' {

+ 1 - 0
dist/preview release/what's new.md

@@ -28,6 +28,7 @@
 
 ### Core Engine
 
+- Added new `PassCubePostProcess` to render cube map content ([Deltakosh](https://github.com/deltakosh))
 - Added support for utility layer for SkeletonViewer ([Deltakosh](https://github.com/deltakosh))
 - Improved shader precision detection ([Deltakosh](https://github.com/deltakosh))
 - Added support for bone matrix texture. Now skeletons will use a texture instead of uniforms when possible ([Deltakosh](https://github.com/deltakosh))

+ 63 - 0
src/PostProcess/babylon.passPostProcess.ts

@@ -18,4 +18,67 @@ module BABYLON {
             super(name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation);
         }
     }
+
+    /**
+     * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
+     */
+    export class PassCubePostProcess extends PostProcess {
+        private _face = 0;
+
+        /**
+         * Gets or sets the cube face to display.
+         *  * 0 is +X
+         *  * 1 is -X
+         *  * 2 is +Y
+         *  * 3 is -Y
+         *  * 4 is +Z
+         *  * 5 is -Z
+         */
+        public get face(): number {
+            return this._face;
+        }
+
+        public set face(value: number) {
+            if (value < 0 || value > 5) {
+                return;
+            }
+
+            this._face = value;
+            switch (this._face) {
+                case 0:
+                    this.updateEffect("#define POSITIVEX");
+                    break;
+                case 1:
+                    this.updateEffect("#define NEGATIVEX");
+                    break;
+                case 2:
+                    this.updateEffect("#define POSITIVEY");
+                    break;
+                case 3:
+                    this.updateEffect("#define NEGATIVEY");
+                    break;
+                case 4:
+                    this.updateEffect("#define POSITIVEZ");
+                    break;
+                case 5:
+                    this.updateEffect("#define NEGATIVEZ");
+                    break;
+            }
+        }
+
+        /**
+         * Creates the PassCubePostProcess
+         * @param name The name of the effect.
+         * @param options The required width/height ratio to downsize to before computing the render pass.
+         * @param camera The camera to apply the render pass to.
+         * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
+         * @param engine The engine which the post process will be applied. (default: current engine)
+         * @param reusable If the post process can be reused on the same frame. (default: false)
+         * @param textureType The type of texture to be used when performing the post processing.
+         * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
+         */
+        constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera> = null, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType: number = Engine.TEXTURETYPE_UNSIGNED_INT, blockCompilation = false) {
+            super(name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation);
+        }
+    }
 }

+ 27 - 0
src/Shaders/passCube.fragment.fx

@@ -0,0 +1,27 @@
+// Samplers
+varying vec2 vUV;
+uniform samplerCube textureSampler;
+
+void main(void) 
+{
+	vec2 uv = vUV * 2.0 - 1.0;
+
+#ifdef POSITIVEX
+	gl_FragColor = textureCube(textureSampler, vec3(1.001, uv.y, uv.x));
+#endif
+#ifdef NEGATIVEX
+	gl_FragColor = textureCube(textureSampler, vec3(-1.001, uv.y, uv.x));
+#endif
+#ifdef POSITIVEY
+	gl_FragColor = textureCube(textureSampler, vec3(uv.y, 1.001, uv.x));
+#endif
+#ifdef NEGATIVEY
+	gl_FragColor = textureCube(textureSampler, vec3(uv.y, -1.001, uv.x));
+#endif
+#ifdef POSITIVEZ
+	gl_FragColor = textureCube(textureSampler, vec3(uv, 1.001));
+#endif
+#ifdef NEGATIVEZ
+	gl_FragColor = textureCube(textureSampler, vec3(uv, -1.001));
+#endif
+}