Browse Source

Initial commit - #6012 for reflection texture block

David Catuhe 6 years ago
parent
commit
d46d8f0b96

+ 70 - 56
Playground/babylon.d.txt

@@ -47125,7 +47125,62 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
+     * Contains position and normal vectors for a vertex
+     */
+    export class PositionNormalVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /**
+         * Creates a PositionNormalVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3);
+        /**
+         * Clones the PositionNormalVertex
+         * @returns the cloned PositionNormalVertex
+         */
+        clone(): PositionNormalVertex;
+    }
+    /**
+     * Contains position, normal and uv vectors for a vertex
+     */
+    export class PositionNormalTextureVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /** the uv of the vertex (default: 0,0) */
+        uv: Vector2;
+        /**
+         * Creates a PositionNormalTextureVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         * @param uv the uv of the vertex (default: 0,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3, 
+        /** the uv of the vertex (default: 0,0) */
+        uv?: Vector2);
+        /**
+         * Clones the PositionNormalTextureVertex
+         * @returns the cloned PositionNormalTextureVertex
+         */
+        clone(): PositionNormalTextureVertex;
+    }
+}
+declare module BABYLON {
+    /**
+     * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
      * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
      * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
      * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
@@ -47143,6 +47198,7 @@ declare module BABYLON {
          * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
          */
         static readonly MODE_SIDEBYSIDE: number;
+        private _halfDome;
         private _useDirectMapping;
         /**
          * The video texture being displayed on the sphere
@@ -47161,6 +47217,10 @@ declare module BABYLON {
          */
         protected _mesh: Mesh;
         /**
+         * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
+         */
+        private _halfDomeMask;
+        /**
          * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
          * Also see the options.resolution property.
          */
@@ -47174,6 +47234,14 @@ declare module BABYLON {
          */
         videoMode: number;
         /**
+         * Is the video a 180 degrees video (half dome) or 360 video (full dome)
+         *
+         */
+        /**
+        * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
+        */
+        halfDome: boolean;
+        /**
          * Oberserver used in Stereoscopic VR Mode.
          */
         private _onBeforeCameraRenderObserver;
@@ -47192,6 +47260,7 @@ declare module BABYLON {
             poster?: string;
             faceForward?: boolean;
             useDirectMapping?: boolean;
+            halfDomeMode?: boolean;
         }, scene: Scene);
         private _changeVideoMode;
         /**
@@ -51530,61 +51599,6 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Contains position and normal vectors for a vertex
-     */
-    export class PositionNormalVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /**
-         * Creates a PositionNormalVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3);
-        /**
-         * Clones the PositionNormalVertex
-         * @returns the cloned PositionNormalVertex
-         */
-        clone(): PositionNormalVertex;
-    }
-    /**
-     * Contains position, normal and uv vectors for a vertex
-     */
-    export class PositionNormalTextureVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /** the uv of the vertex (default: 0,0) */
-        uv: Vector2;
-        /**
-         * Creates a PositionNormalTextureVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         * @param uv the uv of the vertex (default: 0,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3, 
-        /** the uv of the vertex (default: 0,0) */
-        uv?: Vector2);
-        /**
-         * Clones the PositionNormalTextureVertex
-         * @returns the cloned PositionNormalTextureVertex
-         */
-        clone(): PositionNormalTextureVertex;
-    }
-}
-declare module BABYLON {
-    /**
      * Block used to expose an input value
      */
     export class InputBlock extends NodeMaterialBlock {

+ 70 - 56
dist/preview release/babylon.d.ts

@@ -47888,7 +47888,62 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
+     * Contains position and normal vectors for a vertex
+     */
+    export class PositionNormalVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /**
+         * Creates a PositionNormalVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3);
+        /**
+         * Clones the PositionNormalVertex
+         * @returns the cloned PositionNormalVertex
+         */
+        clone(): PositionNormalVertex;
+    }
+    /**
+     * Contains position, normal and uv vectors for a vertex
+     */
+    export class PositionNormalTextureVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /** the uv of the vertex (default: 0,0) */
+        uv: Vector2;
+        /**
+         * Creates a PositionNormalTextureVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         * @param uv the uv of the vertex (default: 0,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3, 
+        /** the uv of the vertex (default: 0,0) */
+        uv?: Vector2);
+        /**
+         * Clones the PositionNormalTextureVertex
+         * @returns the cloned PositionNormalTextureVertex
+         */
+        clone(): PositionNormalTextureVertex;
+    }
+}
+declare module BABYLON {
+    /**
+     * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
      * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
      * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
      * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
@@ -47906,6 +47961,7 @@ declare module BABYLON {
          * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
          */
         static readonly MODE_SIDEBYSIDE: number;
+        private _halfDome;
         private _useDirectMapping;
         /**
          * The video texture being displayed on the sphere
@@ -47924,6 +47980,10 @@ declare module BABYLON {
          */
         protected _mesh: Mesh;
         /**
+         * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
+         */
+        private _halfDomeMask;
+        /**
          * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
          * Also see the options.resolution property.
          */
@@ -47937,6 +47997,14 @@ declare module BABYLON {
          */
         videoMode: number;
         /**
+         * Is the video a 180 degrees video (half dome) or 360 video (full dome)
+         *
+         */
+        /**
+        * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
+        */
+        halfDome: boolean;
+        /**
          * Oberserver used in Stereoscopic VR Mode.
          */
         private _onBeforeCameraRenderObserver;
@@ -47955,6 +48023,7 @@ declare module BABYLON {
             poster?: string;
             faceForward?: boolean;
             useDirectMapping?: boolean;
+            halfDomeMode?: boolean;
         }, scene: Scene);
         private _changeVideoMode;
         /**
@@ -52331,61 +52400,6 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Contains position and normal vectors for a vertex
-     */
-    export class PositionNormalVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /**
-         * Creates a PositionNormalVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3);
-        /**
-         * Clones the PositionNormalVertex
-         * @returns the cloned PositionNormalVertex
-         */
-        clone(): PositionNormalVertex;
-    }
-    /**
-     * Contains position, normal and uv vectors for a vertex
-     */
-    export class PositionNormalTextureVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /** the uv of the vertex (default: 0,0) */
-        uv: Vector2;
-        /**
-         * Creates a PositionNormalTextureVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         * @param uv the uv of the vertex (default: 0,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3, 
-        /** the uv of the vertex (default: 0,0) */
-        uv?: Vector2);
-        /**
-         * Clones the PositionNormalTextureVertex
-         * @returns the cloned PositionNormalTextureVertex
-         */
-        clone(): PositionNormalTextureVertex;
-    }
-}
-declare module BABYLON {
-    /**
      * Block used to expose an input value
      */
     export class InputBlock extends NodeMaterialBlock {

File diff suppressed because it is too large
+ 1 - 1
dist/preview release/babylon.js


File diff suppressed because it is too large
+ 51 - 19
dist/preview release/babylon.max.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/babylon.max.js.map


+ 153 - 125
dist/preview release/babylon.module.d.ts

@@ -49949,6 +49949,74 @@ declare module "babylonjs/Helpers/sceneHelpers" {
         }
     }
 }
+declare module "babylonjs/Maths/math.vertexFormat" {
+    import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
+    /**
+     * Contains position and normal vectors for a vertex
+     */
+    export class PositionNormalVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /**
+         * Creates a PositionNormalVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3);
+        /**
+         * Clones the PositionNormalVertex
+         * @returns the cloned PositionNormalVertex
+         */
+        clone(): PositionNormalVertex;
+    }
+    /**
+     * Contains position, normal and uv vectors for a vertex
+     */
+    export class PositionNormalTextureVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /** the uv of the vertex (default: 0,0) */
+        uv: Vector2;
+        /**
+         * Creates a PositionNormalTextureVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         * @param uv the uv of the vertex (default: 0,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3, 
+        /** the uv of the vertex (default: 0,0) */
+        uv?: Vector2);
+        /**
+         * Clones the PositionNormalTextureVertex
+         * @returns the cloned PositionNormalTextureVertex
+         */
+        clone(): PositionNormalTextureVertex;
+    }
+}
+declare module "babylonjs/Maths/math" {
+    export * from "babylonjs/Maths/math.axis";
+    export * from "babylonjs/Maths/math.color";
+    export * from "babylonjs/Maths/math.constants";
+    export * from "babylonjs/Maths/math.frustum";
+    export * from "babylonjs/Maths/math.path";
+    export * from "babylonjs/Maths/math.plane";
+    export * from "babylonjs/Maths/math.size";
+    export * from "babylonjs/Maths/math.vector";
+    export * from "babylonjs/Maths/math.vertexFormat";
+    export * from "babylonjs/Maths/math.viewport";
+}
 declare module "babylonjs/Helpers/videoDome" {
     import { Scene } from "babylonjs/scene";
     import { TransformNode } from "babylonjs/Meshes/transformNode";
@@ -49957,7 +50025,7 @@ declare module "babylonjs/Helpers/videoDome" {
     import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
     import "babylonjs/Meshes/Builders/sphereBuilder";
     /**
-     * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
+     * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
      * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
      * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
      * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
@@ -49975,6 +50043,7 @@ declare module "babylonjs/Helpers/videoDome" {
          * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
          */
         static readonly MODE_SIDEBYSIDE: number;
+        private _halfDome;
         private _useDirectMapping;
         /**
          * The video texture being displayed on the sphere
@@ -49993,6 +50062,10 @@ declare module "babylonjs/Helpers/videoDome" {
          */
         protected _mesh: Mesh;
         /**
+         * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
+         */
+        private _halfDomeMask;
+        /**
          * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
          * Also see the options.resolution property.
          */
@@ -50006,6 +50079,14 @@ declare module "babylonjs/Helpers/videoDome" {
          */
         videoMode: number;
         /**
+         * Is the video a 180 degrees video (half dome) or 360 video (full dome)
+         *
+         */
+        /**
+        * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
+        */
+        halfDome: boolean;
+        /**
          * Oberserver used in Stereoscopic VR Mode.
          */
         private _onBeforeCameraRenderObserver;
@@ -50024,6 +50105,7 @@ declare module "babylonjs/Helpers/videoDome" {
             poster?: string;
             faceForward?: boolean;
             useDirectMapping?: boolean;
+            halfDomeMode?: boolean;
         }, scene: Scene);
         private _changeVideoMode;
         /**
@@ -54750,74 +54832,6 @@ declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
         FogColor = 8
     }
 }
-declare module "babylonjs/Maths/math.vertexFormat" {
-    import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
-    /**
-     * Contains position and normal vectors for a vertex
-     */
-    export class PositionNormalVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /**
-         * Creates a PositionNormalVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3);
-        /**
-         * Clones the PositionNormalVertex
-         * @returns the cloned PositionNormalVertex
-         */
-        clone(): PositionNormalVertex;
-    }
-    /**
-     * Contains position, normal and uv vectors for a vertex
-     */
-    export class PositionNormalTextureVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /** the uv of the vertex (default: 0,0) */
-        uv: Vector2;
-        /**
-         * Creates a PositionNormalTextureVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         * @param uv the uv of the vertex (default: 0,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3, 
-        /** the uv of the vertex (default: 0,0) */
-        uv?: Vector2);
-        /**
-         * Clones the PositionNormalTextureVertex
-         * @returns the cloned PositionNormalTextureVertex
-         */
-        clone(): PositionNormalTextureVertex;
-    }
-}
-declare module "babylonjs/Maths/math" {
-    export * from "babylonjs/Maths/math.axis";
-    export * from "babylonjs/Maths/math.color";
-    export * from "babylonjs/Maths/math.constants";
-    export * from "babylonjs/Maths/math.frustum";
-    export * from "babylonjs/Maths/math.path";
-    export * from "babylonjs/Maths/math.plane";
-    export * from "babylonjs/Maths/math.size";
-    export * from "babylonjs/Maths/math.vector";
-    export * from "babylonjs/Maths/math.vertexFormat";
-    export * from "babylonjs/Maths/math.viewport";
-}
 declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
     import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
     import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
@@ -112121,7 +112135,62 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
+     * Contains position and normal vectors for a vertex
+     */
+    export class PositionNormalVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /**
+         * Creates a PositionNormalVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3);
+        /**
+         * Clones the PositionNormalVertex
+         * @returns the cloned PositionNormalVertex
+         */
+        clone(): PositionNormalVertex;
+    }
+    /**
+     * Contains position, normal and uv vectors for a vertex
+     */
+    export class PositionNormalTextureVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /** the uv of the vertex (default: 0,0) */
+        uv: Vector2;
+        /**
+         * Creates a PositionNormalTextureVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         * @param uv the uv of the vertex (default: 0,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3, 
+        /** the uv of the vertex (default: 0,0) */
+        uv?: Vector2);
+        /**
+         * Clones the PositionNormalTextureVertex
+         * @returns the cloned PositionNormalTextureVertex
+         */
+        clone(): PositionNormalTextureVertex;
+    }
+}
+declare module BABYLON {
+    /**
+     * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
      * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
      * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
      * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
@@ -112139,6 +112208,7 @@ declare module BABYLON {
          * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
          */
         static readonly MODE_SIDEBYSIDE: number;
+        private _halfDome;
         private _useDirectMapping;
         /**
          * The video texture being displayed on the sphere
@@ -112157,6 +112227,10 @@ declare module BABYLON {
          */
         protected _mesh: Mesh;
         /**
+         * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
+         */
+        private _halfDomeMask;
+        /**
          * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
          * Also see the options.resolution property.
          */
@@ -112170,6 +112244,14 @@ declare module BABYLON {
          */
         videoMode: number;
         /**
+         * Is the video a 180 degrees video (half dome) or 360 video (full dome)
+         *
+         */
+        /**
+        * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
+        */
+        halfDome: boolean;
+        /**
          * Oberserver used in Stereoscopic VR Mode.
          */
         private _onBeforeCameraRenderObserver;
@@ -112188,6 +112270,7 @@ declare module BABYLON {
             poster?: string;
             faceForward?: boolean;
             useDirectMapping?: boolean;
+            halfDomeMode?: boolean;
         }, scene: Scene);
         private _changeVideoMode;
         /**
@@ -116564,61 +116647,6 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Contains position and normal vectors for a vertex
-     */
-    export class PositionNormalVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /**
-         * Creates a PositionNormalVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3);
-        /**
-         * Clones the PositionNormalVertex
-         * @returns the cloned PositionNormalVertex
-         */
-        clone(): PositionNormalVertex;
-    }
-    /**
-     * Contains position, normal and uv vectors for a vertex
-     */
-    export class PositionNormalTextureVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /** the uv of the vertex (default: 0,0) */
-        uv: Vector2;
-        /**
-         * Creates a PositionNormalTextureVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         * @param uv the uv of the vertex (default: 0,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3, 
-        /** the uv of the vertex (default: 0,0) */
-        uv?: Vector2);
-        /**
-         * Clones the PositionNormalTextureVertex
-         * @returns the cloned PositionNormalTextureVertex
-         */
-        clone(): PositionNormalTextureVertex;
-    }
-}
-declare module BABYLON {
-    /**
      * Block used to expose an input value
      */
     export class InputBlock extends NodeMaterialBlock {

+ 70 - 56
dist/preview release/documentation.d.ts

@@ -47888,7 +47888,62 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
+     * Contains position and normal vectors for a vertex
+     */
+    export class PositionNormalVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /**
+         * Creates a PositionNormalVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3);
+        /**
+         * Clones the PositionNormalVertex
+         * @returns the cloned PositionNormalVertex
+         */
+        clone(): PositionNormalVertex;
+    }
+    /**
+     * Contains position, normal and uv vectors for a vertex
+     */
+    export class PositionNormalTextureVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /** the uv of the vertex (default: 0,0) */
+        uv: Vector2;
+        /**
+         * Creates a PositionNormalTextureVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         * @param uv the uv of the vertex (default: 0,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3, 
+        /** the uv of the vertex (default: 0,0) */
+        uv?: Vector2);
+        /**
+         * Clones the PositionNormalTextureVertex
+         * @returns the cloned PositionNormalTextureVertex
+         */
+        clone(): PositionNormalTextureVertex;
+    }
+}
+declare module BABYLON {
+    /**
+     * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
      * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
      * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
      * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
@@ -47906,6 +47961,7 @@ declare module BABYLON {
          * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
          */
         static readonly MODE_SIDEBYSIDE: number;
+        private _halfDome;
         private _useDirectMapping;
         /**
          * The video texture being displayed on the sphere
@@ -47924,6 +47980,10 @@ declare module BABYLON {
          */
         protected _mesh: Mesh;
         /**
+         * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
+         */
+        private _halfDomeMask;
+        /**
          * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
          * Also see the options.resolution property.
          */
@@ -47937,6 +47997,14 @@ declare module BABYLON {
          */
         videoMode: number;
         /**
+         * Is the video a 180 degrees video (half dome) or 360 video (full dome)
+         *
+         */
+        /**
+        * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
+        */
+        halfDome: boolean;
+        /**
          * Oberserver used in Stereoscopic VR Mode.
          */
         private _onBeforeCameraRenderObserver;
@@ -47955,6 +48023,7 @@ declare module BABYLON {
             poster?: string;
             faceForward?: boolean;
             useDirectMapping?: boolean;
+            halfDomeMode?: boolean;
         }, scene: Scene);
         private _changeVideoMode;
         /**
@@ -52331,61 +52400,6 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Contains position and normal vectors for a vertex
-     */
-    export class PositionNormalVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /**
-         * Creates a PositionNormalVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3);
-        /**
-         * Clones the PositionNormalVertex
-         * @returns the cloned PositionNormalVertex
-         */
-        clone(): PositionNormalVertex;
-    }
-    /**
-     * Contains position, normal and uv vectors for a vertex
-     */
-    export class PositionNormalTextureVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /** the uv of the vertex (default: 0,0) */
-        uv: Vector2;
-        /**
-         * Creates a PositionNormalTextureVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         * @param uv the uv of the vertex (default: 0,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3, 
-        /** the uv of the vertex (default: 0,0) */
-        uv?: Vector2);
-        /**
-         * Clones the PositionNormalTextureVertex
-         * @returns the cloned PositionNormalTextureVertex
-         */
-        clone(): PositionNormalTextureVertex;
-    }
-}
-declare module BABYLON {
-    /**
      * Block used to expose an input value
      */
     export class InputBlock extends NodeMaterialBlock {

+ 153 - 125
dist/preview release/viewer/babylon.module.d.ts

@@ -49949,6 +49949,74 @@ declare module "babylonjs/Helpers/sceneHelpers" {
         }
     }
 }
+declare module "babylonjs/Maths/math.vertexFormat" {
+    import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
+    /**
+     * Contains position and normal vectors for a vertex
+     */
+    export class PositionNormalVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /**
+         * Creates a PositionNormalVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3);
+        /**
+         * Clones the PositionNormalVertex
+         * @returns the cloned PositionNormalVertex
+         */
+        clone(): PositionNormalVertex;
+    }
+    /**
+     * Contains position, normal and uv vectors for a vertex
+     */
+    export class PositionNormalTextureVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /** the uv of the vertex (default: 0,0) */
+        uv: Vector2;
+        /**
+         * Creates a PositionNormalTextureVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         * @param uv the uv of the vertex (default: 0,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3, 
+        /** the uv of the vertex (default: 0,0) */
+        uv?: Vector2);
+        /**
+         * Clones the PositionNormalTextureVertex
+         * @returns the cloned PositionNormalTextureVertex
+         */
+        clone(): PositionNormalTextureVertex;
+    }
+}
+declare module "babylonjs/Maths/math" {
+    export * from "babylonjs/Maths/math.axis";
+    export * from "babylonjs/Maths/math.color";
+    export * from "babylonjs/Maths/math.constants";
+    export * from "babylonjs/Maths/math.frustum";
+    export * from "babylonjs/Maths/math.path";
+    export * from "babylonjs/Maths/math.plane";
+    export * from "babylonjs/Maths/math.size";
+    export * from "babylonjs/Maths/math.vector";
+    export * from "babylonjs/Maths/math.vertexFormat";
+    export * from "babylonjs/Maths/math.viewport";
+}
 declare module "babylonjs/Helpers/videoDome" {
     import { Scene } from "babylonjs/scene";
     import { TransformNode } from "babylonjs/Meshes/transformNode";
@@ -49957,7 +50025,7 @@ declare module "babylonjs/Helpers/videoDome" {
     import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
     import "babylonjs/Meshes/Builders/sphereBuilder";
     /**
-     * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
+     * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
      * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
      * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
      * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
@@ -49975,6 +50043,7 @@ declare module "babylonjs/Helpers/videoDome" {
          * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
          */
         static readonly MODE_SIDEBYSIDE: number;
+        private _halfDome;
         private _useDirectMapping;
         /**
          * The video texture being displayed on the sphere
@@ -49993,6 +50062,10 @@ declare module "babylonjs/Helpers/videoDome" {
          */
         protected _mesh: Mesh;
         /**
+         * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
+         */
+        private _halfDomeMask;
+        /**
          * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
          * Also see the options.resolution property.
          */
@@ -50006,6 +50079,14 @@ declare module "babylonjs/Helpers/videoDome" {
          */
         videoMode: number;
         /**
+         * Is the video a 180 degrees video (half dome) or 360 video (full dome)
+         *
+         */
+        /**
+        * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
+        */
+        halfDome: boolean;
+        /**
          * Oberserver used in Stereoscopic VR Mode.
          */
         private _onBeforeCameraRenderObserver;
@@ -50024,6 +50105,7 @@ declare module "babylonjs/Helpers/videoDome" {
             poster?: string;
             faceForward?: boolean;
             useDirectMapping?: boolean;
+            halfDomeMode?: boolean;
         }, scene: Scene);
         private _changeVideoMode;
         /**
@@ -54750,74 +54832,6 @@ declare module "babylonjs/Materials/Node/nodeMaterialWellKnownValues" {
         FogColor = 8
     }
 }
-declare module "babylonjs/Maths/math.vertexFormat" {
-    import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
-    /**
-     * Contains position and normal vectors for a vertex
-     */
-    export class PositionNormalVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /**
-         * Creates a PositionNormalVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3);
-        /**
-         * Clones the PositionNormalVertex
-         * @returns the cloned PositionNormalVertex
-         */
-        clone(): PositionNormalVertex;
-    }
-    /**
-     * Contains position, normal and uv vectors for a vertex
-     */
-    export class PositionNormalTextureVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /** the uv of the vertex (default: 0,0) */
-        uv: Vector2;
-        /**
-         * Creates a PositionNormalTextureVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         * @param uv the uv of the vertex (default: 0,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3, 
-        /** the uv of the vertex (default: 0,0) */
-        uv?: Vector2);
-        /**
-         * Clones the PositionNormalTextureVertex
-         * @returns the cloned PositionNormalTextureVertex
-         */
-        clone(): PositionNormalTextureVertex;
-    }
-}
-declare module "babylonjs/Maths/math" {
-    export * from "babylonjs/Maths/math.axis";
-    export * from "babylonjs/Maths/math.color";
-    export * from "babylonjs/Maths/math.constants";
-    export * from "babylonjs/Maths/math.frustum";
-    export * from "babylonjs/Maths/math.path";
-    export * from "babylonjs/Maths/math.plane";
-    export * from "babylonjs/Maths/math.size";
-    export * from "babylonjs/Maths/math.vector";
-    export * from "babylonjs/Maths/math.vertexFormat";
-    export * from "babylonjs/Maths/math.viewport";
-}
 declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
     import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
     import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPointTypes";
@@ -112121,7 +112135,62 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
+     * Contains position and normal vectors for a vertex
+     */
+    export class PositionNormalVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /**
+         * Creates a PositionNormalVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3);
+        /**
+         * Clones the PositionNormalVertex
+         * @returns the cloned PositionNormalVertex
+         */
+        clone(): PositionNormalVertex;
+    }
+    /**
+     * Contains position, normal and uv vectors for a vertex
+     */
+    export class PositionNormalTextureVertex {
+        /** the position of the vertex (defaut: 0,0,0) */
+        position: Vector3;
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal: Vector3;
+        /** the uv of the vertex (default: 0,0) */
+        uv: Vector2;
+        /**
+         * Creates a PositionNormalTextureVertex
+         * @param position the position of the vertex (defaut: 0,0,0)
+         * @param normal the normal of the vertex (defaut: 0,1,0)
+         * @param uv the uv of the vertex (default: 0,0)
+         */
+        constructor(
+        /** the position of the vertex (defaut: 0,0,0) */
+        position?: Vector3, 
+        /** the normal of the vertex (defaut: 0,1,0) */
+        normal?: Vector3, 
+        /** the uv of the vertex (default: 0,0) */
+        uv?: Vector2);
+        /**
+         * Clones the PositionNormalTextureVertex
+         * @returns the cloned PositionNormalTextureVertex
+         */
+        clone(): PositionNormalTextureVertex;
+    }
+}
+declare module BABYLON {
+    /**
+     * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
      * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
      * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
      * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
@@ -112139,6 +112208,7 @@ declare module BABYLON {
          * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
          */
         static readonly MODE_SIDEBYSIDE: number;
+        private _halfDome;
         private _useDirectMapping;
         /**
          * The video texture being displayed on the sphere
@@ -112157,6 +112227,10 @@ declare module BABYLON {
          */
         protected _mesh: Mesh;
         /**
+         * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
+         */
+        private _halfDomeMask;
+        /**
          * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
          * Also see the options.resolution property.
          */
@@ -112170,6 +112244,14 @@ declare module BABYLON {
          */
         videoMode: number;
         /**
+         * Is the video a 180 degrees video (half dome) or 360 video (full dome)
+         *
+         */
+        /**
+        * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
+        */
+        halfDome: boolean;
+        /**
          * Oberserver used in Stereoscopic VR Mode.
          */
         private _onBeforeCameraRenderObserver;
@@ -112188,6 +112270,7 @@ declare module BABYLON {
             poster?: string;
             faceForward?: boolean;
             useDirectMapping?: boolean;
+            halfDomeMode?: boolean;
         }, scene: Scene);
         private _changeVideoMode;
         /**
@@ -116564,61 +116647,6 @@ declare module BABYLON {
 }
 declare module BABYLON {
     /**
-     * Contains position and normal vectors for a vertex
-     */
-    export class PositionNormalVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /**
-         * Creates a PositionNormalVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3);
-        /**
-         * Clones the PositionNormalVertex
-         * @returns the cloned PositionNormalVertex
-         */
-        clone(): PositionNormalVertex;
-    }
-    /**
-     * Contains position, normal and uv vectors for a vertex
-     */
-    export class PositionNormalTextureVertex {
-        /** the position of the vertex (defaut: 0,0,0) */
-        position: Vector3;
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal: Vector3;
-        /** the uv of the vertex (default: 0,0) */
-        uv: Vector2;
-        /**
-         * Creates a PositionNormalTextureVertex
-         * @param position the position of the vertex (defaut: 0,0,0)
-         * @param normal the normal of the vertex (defaut: 0,1,0)
-         * @param uv the uv of the vertex (default: 0,0)
-         */
-        constructor(
-        /** the position of the vertex (defaut: 0,0,0) */
-        position?: Vector3, 
-        /** the normal of the vertex (defaut: 0,1,0) */
-        normal?: Vector3, 
-        /** the uv of the vertex (default: 0,0) */
-        uv?: Vector2);
-        /**
-         * Clones the PositionNormalTextureVertex
-         * @returns the cloned PositionNormalTextureVertex
-         */
-        clone(): PositionNormalTextureVertex;
-    }
-}
-declare module BABYLON {
-    /**
      * Block used to expose an input value
      */
     export class InputBlock extends NodeMaterialBlock {

File diff suppressed because it is too large
+ 5 - 5
dist/preview release/viewer/babylon.viewer.js


File diff suppressed because it is too large
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 1 - 1
nodeEditor/src/components/preview/previewManager.ts

@@ -43,7 +43,7 @@ export class PreviewManager {
 
         this._camera.lowerRadiusLimit = 3;
         this._camera.upperRadiusLimit = 10;
-        this._camera.wheelPrecision = 10;
+        this._camera.wheelPrecision = 20;
         this._camera.attachControl(targetCanvas, false);
 
         this._refreshPreviewMesh();

+ 6 - 5
src/Materials/Node/Blocks/Dual/lightBlock.ts

@@ -167,10 +167,14 @@ export class LightBlock extends NodeMaterialBlock {
 
         // Inject code in vertex
         let worldPosVaryingName = "v_" + worldPos.associatedVariableName;
-        state._emitVaryingFromString(worldPosVaryingName, "vec3");
+        if (state._emitVaryingFromString(worldPosVaryingName, "vec3")) {
+            state.compilationString += `${worldPosVaryingName} = ${worldPos.associatedVariableName}.xyz;\r\n`;
+        }
 
         let worldNormalVaryingName = "v_" + worldNormal.associatedVariableName;
-        state._emitVaryingFromString(worldNormalVaryingName, "vec3");
+        if (state._emitVaryingFromString(worldNormalVaryingName, "vec3")) {
+            state.compilationString += `${worldNormalVaryingName} = ${worldNormal.associatedVariableName}.xyz;\r\n`;
+        }
 
         if (this.light) {
             state.compilationString += state._emitCodeFromInclude("shadowsVertex", comments, {
@@ -185,9 +189,6 @@ export class LightBlock extends NodeMaterialBlock {
                 repeatKey: "maxSimultaneousLights"
             });
         }
-
-        state.compilationString += `${worldPosVaryingName} = ${worldPos.associatedVariableName}.xyz;\r\n`;
-        state.compilationString += `${worldNormalVaryingName} = ${worldNormal.associatedVariableName}.xyz;\r\n`;
     }
 
     protected _buildBlock(state: NodeMaterialBuildState) {

+ 37 - 2
src/Materials/Node/Blocks/Dual/textureBlock.ts

@@ -69,12 +69,47 @@ export class TextureBlock extends NodeMaterialBlock {
     }
 
     /**
-     * Gets the output component
+     * Gets the rgba output component
      */
-    public get output(): NodeMaterialConnectionPoint {
+    public get rgba(): NodeMaterialConnectionPoint {
         return this._outputs[0];
     }
 
+    /**
+     * Gets the rgb output component
+     */
+    public get rgb(): NodeMaterialConnectionPoint {
+        return this._outputs[1];
+    }
+    
+    /**
+     * Gets the r output component
+     */
+    public get r(): NodeMaterialConnectionPoint {
+        return this._outputs[2];
+    }
+    
+    /**
+     * Gets the g output component
+     */
+    public get g(): NodeMaterialConnectionPoint {
+        return this._outputs[3];
+    }
+    
+    /**
+     * Gets the b output component
+     */
+    public get b(): NodeMaterialConnectionPoint {
+        return this._outputs[4];
+    }
+    
+    /**
+     * Gets the a output component
+     */
+    public get a(): NodeMaterialConnectionPoint {
+        return this._outputs[5];
+    }    
+
     public autoConfigure() {
         if (!this.uv.isConnected) {
             let uvInput = new InputBlock("uv");

+ 2 - 1
src/Materials/Node/Blocks/Fragment/index.ts

@@ -5,4 +5,5 @@ export * from "../colorMergerBlock";
 export * from "../vectorMergerBlock";
 export * from "../colorSplitterBlock";
 export * from "../vectorSplitterBlock";
-export * from "./imageProcessingBlock";
+export * from "./imageProcessingBlock";
+export * from "./reflectionTextureBlock";

+ 375 - 0
src/Materials/Node/Blocks/Fragment/reflectionTextureBlock.ts

@@ -0,0 +1,375 @@
+import { NodeMaterialBlock } from '../../nodeMaterialBlock';
+import { NodeMaterialBlockConnectionPointTypes } from '../../nodeMaterialBlockConnectionPointTypes';
+import { NodeMaterialBuildState } from '../../nodeMaterialBuildState';
+import { NodeMaterialBlockTargets } from '../../nodeMaterialBlockTargets';
+import { NodeMaterialConnectionPoint } from '../../nodeMaterialBlockConnectionPoint';
+import { BaseTexture } from '../../../Textures/baseTexture';
+import { AbstractMesh } from '../../../../Meshes/abstractMesh';
+import { NodeMaterial, NodeMaterialDefines } from '../../nodeMaterial';
+import { Effect } from '../../../effect';
+import { Mesh } from '../../../../Meshes/mesh';
+import { Nullable } from '../../../../types';
+import { _TypeStore } from '../../../../Misc/typeStore';
+import { Texture } from '../../../Textures/texture';
+import { Scene } from '../../../../scene';
+import { InputBlock } from '../Input/inputBlock';
+import { NodeMaterialWellKnownValues } from '../../nodeMaterialWellKnownValues';
+import { Constants } from '../../../../Engines/constants';
+
+/**
+ * Block used to read a reflection texture from a sampler
+ */
+export class ReflectionTextureBlock extends NodeMaterialBlock {
+    private _define3DName: string;
+    private _defineMirroredEquirectangularFixedName: string;
+    private _defineEquirectangularFixedName: string;
+    private _defineSkyboxName: string;
+    private _cubeSamplerName: string;
+    private _2DSamplerName: string;
+    private _positionUVWName: string;
+    private _directionWName: string;    
+    private _reflectionCoordsName: string;
+    private _reflection2DCoordsName: string;
+    private _reflectionColorName: string;
+    private _reflectionMatrixName: string;
+
+    /**
+     * Gets or sets the texture associated with the node
+     */
+    public texture: Nullable<BaseTexture>;
+
+    /**
+     * Create a new TextureBlock
+     * @param name defines the block name
+     */
+    public constructor(name: string) {
+        super(name, NodeMaterialBlockTargets.VertexAndFragment);
+
+        this.registerInput("position", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Vertex);
+        this.registerInput("worldPosition", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Vertex);
+        this.registerInput("worldNormal", NodeMaterialBlockConnectionPointTypes.Vector4, false, NodeMaterialBlockTargets.Vertex);        
+        this.registerInput("world", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Vertex);
+        
+        this.registerInput("cameraPosition", NodeMaterialBlockConnectionPointTypes.Vector3, false, NodeMaterialBlockTargets.Fragment);
+        this.registerInput("view", NodeMaterialBlockConnectionPointTypes.Matrix, false, NodeMaterialBlockTargets.Fragment);
+
+        this.registerOutput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, NodeMaterialBlockTargets.Fragment);
+        this.registerOutput("r", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);
+        this.registerOutput("g", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);
+        this.registerOutput("b", NodeMaterialBlockConnectionPointTypes.Float, NodeMaterialBlockTargets.Fragment);
+    }
+
+    /**
+     * Gets the current class name
+     * @returns the class name
+     */
+    public getClassName() {
+        return "ReflectionTextureBlock";
+    }
+
+    /**
+     * Gets the world position input component
+     */
+    public get position(): NodeMaterialConnectionPoint {
+        return this._inputs[0];
+    }
+
+    /**
+     * Gets the world position input component
+     */
+    public get worldPosition(): NodeMaterialConnectionPoint {
+        return this._inputs[1];
+    }
+
+    /**
+     * Gets the world normal input component
+     */
+    public get worldNormal(): NodeMaterialConnectionPoint {
+        return this._inputs[2];
+    }    
+
+    /**
+     * Gets the world input component
+     */
+    public get world(): NodeMaterialConnectionPoint {
+        return this._inputs[3];
+    }  
+
+    /**
+    * Gets the camera (or eye) position component
+    */
+    public get cameraPosition(): NodeMaterialConnectionPoint {
+        return this._inputs[4];
+    }  
+    
+    /**
+     * Gets the view input component
+     */
+    public get view(): NodeMaterialConnectionPoint {
+        return this._inputs[5];
+    }      
+
+    /**
+     * Gets the rgb output component
+     */
+    public get rgb(): NodeMaterialConnectionPoint {
+        return this._outputs[0];
+    }
+    
+    /**
+     * Gets the r output component
+     */
+    public get r(): NodeMaterialConnectionPoint {
+        return this._outputs[1];
+    }
+    
+    /**
+     * Gets the g output component
+     */
+    public get g(): NodeMaterialConnectionPoint {
+        return this._outputs[2];
+    }
+    
+    /**
+     * Gets the b output component
+     */
+    public get b(): NodeMaterialConnectionPoint {
+        return this._outputs[3];
+    }     
+    
+    public autoConfigure() {
+        if (!this.position.isConnected) {
+            let positionInput = new InputBlock("position");
+            positionInput.setAsAttribute();
+            positionInput.output.connectTo(this.position);
+        }
+
+        if (!this.world.isConnected) {
+            let worldInput = new InputBlock("world");
+            worldInput.setAsWellKnownValue(NodeMaterialWellKnownValues.World);
+            worldInput.output.connectTo(this.world);
+        }
+
+        if (!this.cameraPosition.isConnected) {
+            let cameraPositionInput = new InputBlock("cameraPosition");
+            cameraPositionInput.setAsWellKnownValue(NodeMaterialWellKnownValues.CameraPosition);
+            cameraPositionInput.output.connectTo(this.cameraPosition);
+        }
+
+        if (!this.view.isConnected) {
+            let viewInput = new InputBlock("view");
+            viewInput.setAsWellKnownValue(NodeMaterialWellKnownValues.View);
+            viewInput.output.connectTo(this.view);
+        }
+    }    
+
+    public prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines) {
+        if (!defines._areTexturesDirty) {
+            return;
+        }
+
+        if (!this.texture || !this.texture.getTextureMatrix) {
+            return;
+        }
+
+        if (this.texture.isCube) {
+            defines.setValue(this._define3DName, true);
+        } else {
+            defines.setValue(this._define3DName, false);
+        }
+
+        defines.setValue(this._defineSkyboxName, this.texture.coordinatesMode === Constants.TEXTURE_SKYBOX_MODE);
+        defines.setValue(this._defineEquirectangularFixedName, this.texture.coordinatesMode === Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE);
+        defines.setValue(this._defineMirroredEquirectangularFixedName, this.texture.coordinatesMode === Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE);
+    }
+
+    public isReady() {
+        if (this.texture && !this.texture.isReadyOrNotBlocking()) {
+            return false;
+        }
+
+        return true;
+    }
+
+    public bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh) {
+        if (!mesh || !this.texture) {
+            return;
+        }
+
+        effect.setMatrix(this._reflectionMatrixName, this.texture.getReflectionTextureMatrix());
+
+        if (this.texture.isCube) {
+            effect.setTexture(this._cubeSamplerName, this.texture);
+        } else {
+            effect.setTexture(this._2DSamplerName, this.texture);
+        }        
+    }
+
+    private _injectVertexCode(state: NodeMaterialBuildState) {
+        let worldPosVaryingName = "v_" + this.worldPosition.associatedVariableName;
+        if (state._emitVaryingFromString(worldPosVaryingName, "vec3")) {
+            state.compilationString += `${worldPosVaryingName} = ${this.worldPosition.associatedVariableName}.xyz;\r\n`;
+        }
+
+        let worldNormalVaryingName = "v_" + this.worldNormal.associatedVariableName;
+        if (state._emitVaryingFromString(worldNormalVaryingName, "vec3")) {
+            state.compilationString += `${worldNormalVaryingName} = ${this.worldNormal.associatedVariableName}.xyz;\r\n`;
+        }
+
+        this._positionUVWName = state._getFreeVariableName("positionUVW");
+        this._directionWName = state._getFreeVariableName("directionW");
+
+        if (state._emitVaryingFromString(this._positionUVWName, "vec3", this._defineSkyboxName)) {
+            state.compilationString += `#ifdef ${this._defineSkyboxName}\r\n`;
+            state.compilationString += `${this._positionUVWName} = ${this.position.associatedVariableName};\r\n`;
+            state.compilationString += `#endif\r\n`;
+        }
+
+        if (state._emitVaryingFromString(this._directionWName, "vec3", `defined(${this._defineEquirectangularFixedName}) || defined(${this._defineMirroredEquirectangularFixedName})`)) {
+            state.compilationString += `#if defined(${this._defineEquirectangularFixedName}) || defined(${this._defineMirroredEquirectangularFixedName})\r\n`;
+            state.compilationString += `${this._directionWName} = normalize(vec3(${this.world.associatedVariableName} * vec4(${this.position.associatedVariableName}, 0.0)));\r\n`;
+            state.compilationString += `#endif\r\n`;
+        }
+    }
+
+    private _writeOutput(state: NodeMaterialBuildState, output: NodeMaterialConnectionPoint, swizzle: string) {
+        state.compilationString += `${this._declareOutput(output, state)} = ${this._reflectionColorName}.${swizzle};\r\n`;
+    }
+
+    protected _buildBlock(state: NodeMaterialBuildState) {
+        super._buildBlock(state);
+        
+        this._define3DName = state._getFreeDefineName("REFLECTIONMAP_3D");
+        this._defineMirroredEquirectangularFixedName = state._getFreeDefineName("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
+        this._defineEquirectangularFixedName = state._getFreeDefineName("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
+        this._defineSkyboxName = state._getFreeDefineName("REFLECTIONMAP_SKYBOX");
+
+        if (state.target !== NodeMaterialBlockTargets.Fragment) {
+            // Vertex
+            this._injectVertexCode(state);
+            return;
+        }
+
+        state.sharedData.blockingBlocks.push(this);
+        state.sharedData.textureBlocks.push(this);
+
+        // Samplers
+        this._cubeSamplerName = state._getFreeVariableName(this.name + "CubeSampler");
+        state.samplers.push(this._cubeSamplerName);
+
+        this._2DSamplerName = state._getFreeVariableName(this.name + "2DSampler");
+        state.samplers.push(this._2DSamplerName);
+
+        state._samplerDeclaration += `#ifdef ${this._define3DName}\r\n`;
+        state._samplerDeclaration += `uniform samplerCube ${this._cubeSamplerName};\r\n`;
+        state._samplerDeclaration += `#else\r\n`;
+        state._samplerDeclaration += `uniform sampler2D ${this._2DSamplerName};\r\n`;
+        state._samplerDeclaration += `#endif\r\n`;
+
+        // Fragment
+        state.sharedData.blocksWithDefines.push(this);
+        state.sharedData.bindableBlocks.push(this);
+
+        let comments = `//${this.name}`;
+        state._emitFunction("ReciprocalPI", "#define RECIPROCAL_PI2 0.15915494", "");
+        state._emitFunctionFromInclude("reflectionFunction", comments);
+
+        this._reflectionColorName = state._getFreeVariableName("reflectionColor");
+        this._reflectionCoordsName = state._getFreeVariableName("reflectionUVW");
+        this._reflection2DCoordsName = state._getFreeVariableName("reflectionUV");
+        this._reflectionMatrixName = state._getFreeVariableName("reflectionMatrix");
+
+        state._emitUniformFromString(this._reflectionMatrixName, "mat4");
+
+        // Code
+        let worldPos = "v_" + this.worldPosition.associatedVariableName;
+        let worldNormal = "v_" + this.worldNormal.associatedVariableName + "xyz";
+        let reflectionMatrix = this._reflectionMatrixName;
+        let direction = `normalize(${this._directionWName})`;
+        let positionUVW = `${this._positionUVWName}`;
+        let vEyePosition = `${this.cameraPosition.associatedVariableName}`;
+        let view = `${this.view.associatedVariableName}`;
+
+        state.compilationString += `vec3 ${this._reflectionColorName};\r\n`;
+        state.compilationString += `#ifdef ${this._define3DName}\r\n`;
+        state.compilationString += `#ifdef ${this._defineMirroredEquirectangularFixedName}\r\n`;
+        state.compilationString += `    vec3 ${this._reflectionCoordsName} =  computeMirroredFixedEquirectangularCoords(${worldPos}, ${worldNormal}, ${direction});\r\n`;
+        state.compilationString += `#endif\r\n`;
+    
+        state.compilationString += `#ifdef ${this._defineEquirectangularFixedName}\r\n`;
+        state.compilationString += `    vec3 ${this._reflectionCoordsName} =  computeFixedEquirectangularCoords(${worldPos}, ${worldNormal}, ${direction});\r\n`;
+        state.compilationString += `#endif\r\n`;
+    
+        state.compilationString += `#ifdef REFLECTIONMAP_EQUIRECTANGULAR\r\n`;
+        state.compilationString += `    vec3 ${this._reflectionCoordsName} =  computeEquirectangularCoords(${worldPos}, ${worldNormal}, ${vEyePosition}.xyz, ${reflectionMatrix});\r\n`;
+        state.compilationString += ` #endif\r\n`;
+    
+        state.compilationString += `#ifdef REFLECTIONMAP_SPHERICAL\r\n`;
+        state.compilationString += `    vec3 ${this._reflectionCoordsName} =  computeSpericalCoords(${worldPos}, ${worldNormal}, ${view}, ${reflectionMatrix});\r\n`;
+        state.compilationString += `#endif\r\n`;
+
+        state.compilationString += `#ifdef REFLECTIONMAP_PLANAR\r\n`;
+        state.compilationString += `    vec3 ${this._reflectionCoordsName} =  computePlanarCoords(${worldPos}, ${worldNormal}, ${vEyePosition}.xyz, ${reflectionMatrix});\r\n`;
+        state.compilationString += `#endif\r\n`;
+
+        state.compilationString += `#ifdef REFLECTIONMAP_CUBIC\r\n`;
+        state.compilationString += `    #ifdef USE_LOCAL_REFLECTIONMAP_CUBIC\r\n`;
+        state.compilationString += `        vec3 ${this._reflectionCoordsName} =  computeCubicLocalCoords(${worldPos}, ${worldNormal}, ${vEyePosition}.xyz, ${reflectionMatrix}, vReflectionSize, vReflectionPosition);\r\n`;
+        state.compilationString += `    #else\r\n`;
+        state.compilationString += `       vec3 ${this._reflectionCoordsName} =  computeCubicCoords(${worldPos}, ${worldNormal}, ${vEyePosition}.xyz, ${reflectionMatrix});\r\n`;
+        state.compilationString += `    #endif\r\n`;
+        state.compilationString += `#endif\r\n`;
+
+        state.compilationString += `#ifdef REFLECTIONMAP_PROJECTION\r\n`;
+        state.compilationString += `    vec3 ${this._reflectionCoordsName} =  computeProjectionCoords(${worldPos}, ${view}, ${reflectionMatrix});\r\n`;
+        state.compilationString += `#endif\r\n`;
+    
+        state.compilationString += `#ifdef ${this._defineSkyboxName}\r\n`;
+        state.compilationString += `    vec3 ${this._reflectionCoordsName} =  computeSkyBoxCoords(${positionUVW}, ${reflectionMatrix});\r\n`;
+        state.compilationString += `#endif\r\n`;
+    
+        state.compilationString += `#ifdef REFLECTIONMAP_EXPLICIT\r\n`;
+        state.compilationString += `    vec3 ${this._reflectionCoordsName} =  vec3(0, 0, 0);\r\n`;
+        state.compilationString += `#endif\r\n`;
+        
+        state.compilationString += `${this._reflectionColorName} = textureCube(${this._cubeSamplerName}, ${this._reflectionCoordsName}).rgb;\r\n`;
+        state.compilationString += `#else\r\n`;
+        state.compilationString += `vec2 ${this._reflection2DCoordsName} = ${this._reflectionCoordsName}.xy;\r\n`;
+    
+        state.compilationString += `#ifdef REFLECTIONMAP_PROJECTION\r\n`;
+        state.compilationString += `${this._reflection2DCoordsName} /= ${this._reflectionCoordsName}.z;\r\n`;
+        state.compilationString += `#endif\r\n`;
+    
+        state.compilationString += `${this._reflection2DCoordsName}.y = 1.0 - ${this._reflection2DCoordsName}.y;\r\n`;
+        state.compilationString += `${this._reflectionColorName} = texture2D(${this._2DSamplerName}, ${this._reflection2DCoordsName}).rgb;\r\n`;
+        state.compilationString += `#endif\r\n`;
+
+        for (var output of this._outputs) {
+            if (output.connectedBlocks.length) {
+                this._writeOutput(state, output, output.name);
+            }
+        }
+
+        return this;
+    }
+
+    public serialize(): any {
+        let serializationObject = super.serialize();
+
+        if (this.texture) {
+            serializationObject.texture = this.texture.serialize();
+        }
+
+        return serializationObject;
+    }
+
+    public _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {
+        super._deserialize(serializationObject, scene, rootUrl);
+
+        if (serializationObject.texture) {
+            this.texture = Texture.Parse(serializationObject.texture, scene, rootUrl);
+        }
+    }
+}
+
+_TypeStore.RegisteredTypes["BABYLON.ReflectionTextureBlock"] = ReflectionTextureBlock;

+ 27 - 5
src/Materials/Node/nodeMaterialBlock.ts

@@ -256,6 +256,21 @@ export class NodeMaterialBlock {
     }
 
     /**
+     * Gets the sibling of the given output
+     * @param current defines the current output
+     * @returns the next output in the list or null
+     */
+    public getSiblingOutput(current: NodeMaterialConnectionPoint) {
+        let index = this._outputs.indexOf(current);
+
+        if (index === -1 || index >= this._outputs.length) {
+            return null;
+        }
+
+        return this._outputs[index + 1];
+    }
+
+    /**
      * Connect current block with another block
      * @param other defines the block to connect with
      * @param options define the various options to help pick the right connections
@@ -271,12 +286,19 @@ export class NodeMaterialBlock {
         }
 
         let output = options && options.output ? this.getOutputByName(options.output) : this.getFirstAvailableOutput(other);
-        let input = options && options.input ? other.getInputByName(options.input) : other.getFirstAvailableInput(output);
 
-        if (output && input) {
-            output.connectTo(input);
-        } else {
-            throw "Unable to find a compatible match";
+        let notFound = true;
+        while (notFound) {
+            let input = options && options.input ? other.getInputByName(options.input) : other.getFirstAvailableInput(output);
+
+            if (output && input && output.canConnectTo(input)) {
+                output.connectTo(input);
+                notFound = false;
+            } else if (!output) {
+                throw "Unable to find a compatible match";
+            } else {
+                output = this.getSiblingOutput(output);
+            }
         }
 
         return this;

+ 1 - 1
src/Materials/Node/nodeMaterialBlockConnectionPoint.ts

@@ -175,7 +175,7 @@ export class NodeMaterialConnectionPoint {
      */
     public canConnectTo(connectionPoint: NodeMaterialConnectionPoint) {
         if (this.type !== connectionPoint.type && connectionPoint.type !== NodeMaterialBlockConnectionPointTypes.AutoDetect) {
-            return (connectionPoint.acceptedConnectionPointTypes.indexOf(this.type) !== -1);
+            return (connectionPoint.acceptedConnectionPointTypes && connectionPoint.acceptedConnectionPointTypes.indexOf(this.type) !== -1);
         }
 
         return true;

+ 9 - 2
src/Materials/Node/nodeMaterialBuildState.ts

@@ -2,6 +2,7 @@ import { NodeMaterialBlockConnectionPointTypes } from './nodeMaterialBlockConnec
 import { NodeMaterialBlockTargets } from './nodeMaterialBlockTargets';
 import { NodeMaterialBuildStateSharedData } from './nodeMaterialBuildStateSharedData';
 import { Effect } from '../effect';
+import { StringTools } from '../../Misc/stringTools';
 
 /**
  * Class used to store node based material build state
@@ -273,18 +274,24 @@ export class NodeMaterialBuildState {
     /** @hidden */
     public _emitVaryingFromString(name: string, type: string, define: string = "", notDefine = false) {
         if (this.sharedData.varyings.indexOf(name) !== -1) {
-            return;
+            return false;
         }
 
         this.sharedData.varyings.push(name);
 
         if (define) {
-            this.sharedData.varyingDeclaration += `${notDefine ? "#ifndef" : "#ifdef"} ${define}\r\n`;
+            if (StringTools.StartsWith(define, "defined(")) {
+                this.sharedData.varyingDeclaration += `#if ${define}\r\n`;
+            } else {
+                this.sharedData.varyingDeclaration += `${notDefine ? "#ifndef" : "#ifdef"} ${define}\r\n`;
+            }
         }
         this.sharedData.varyingDeclaration += `varying ${type} ${name};\r\n`;
         if (define) {
             this.sharedData.varyingDeclaration += `#endif\r\n`;
         }
+
+        return true;
     }
 
     /** @hidden */

+ 2 - 1
src/Materials/Node/nodeMaterialBuildStateSharedData.ts

@@ -2,6 +2,7 @@ import { NodeMaterialConnectionPoint } from './nodeMaterialBlockConnectionPoint'
 import { NodeMaterialBlock } from './nodeMaterialBlock';
 import { InputBlock } from './Blocks/Input/inputBlock';
 import { TextureBlock } from './Blocks/Dual/textureBlock';
+import { ReflectionTextureBlock } from './Blocks/Fragment/reflectionTextureBlock';
 
 /**
  * Class used to store shared data between 2 NodeMaterialBuildState
@@ -25,7 +26,7 @@ export class NodeMaterialBuildStateSharedData {
     /**
      * Input blocks
      */
-    public textureBlocks = new Array<TextureBlock>();
+    public textureBlocks = new Array<TextureBlock | ReflectionTextureBlock>();
 
     /**
      * Bindable blocks (Blocks that need to set data to the effect)

+ 90 - 27
src/Shaders/ShadersInclude/reflectionFunction.fx

@@ -1,5 +1,4 @@
-#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
-vec3 parallaxCorrectNormal( vec3 vertexPos, vec3 origVec, vec3 cubeSize, vec3 cubePos ) {
+vec3 parallaxCorrectNormal( vec3 vertexPos, vec3 origVec, vec3 cubeSize, vec3 cubePos ) {
 	// Find the ray intersection with box plane
 	vec3 invOrigVec = vec3(1.0,1.0,1.0) / origVec;
 	vec3 halfSize = cubeSize * 0.5;
@@ -14,28 +13,32 @@ vec3 parallaxCorrectNormal( vec3 vertexPos, vec3 origVec, vec3 cubeSize, vec3 cu
 	// Get corrected vector
 	return intersectPositionWS - cubePos;
 }
-#endif
 
-vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)
+vec3 computeFixedEquirectangularCoords(vec4 worldPos, vec3 worldNormal, vec3 direction)
 {
-#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)
-	vec3 direction = normalize(vDirectionW);
 	float lon = atan(direction.z, direction.x);
 	float lat = acos(direction.y);
 	vec2 sphereCoords = vec2(lon, lat) * RECIPROCAL_PI2 * 2.0;
 	float s = sphereCoords.x * 0.5 + 0.5;
 	float t = sphereCoords.y;
 
- 	#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
-		return vec3(1.0 - s, t, 0);
-	#else
-		return vec3(s, t, 0);
-	#endif
-#endif
+	return vec3(s, t, 0);	
+}
 
-#ifdef REFLECTIONMAP_EQUIRECTANGULAR
+vec3 computeMirroredFixedEquirectangularCoords(vec4 worldPos, vec3 worldNormal, vec3 direction)
+{
+	float lon = atan(direction.z, direction.x);
+	float lat = acos(direction.y);
+	vec2 sphereCoords = vec2(lon, lat) * RECIPROCAL_PI2 * 2.0;
+	float s = sphereCoords.x * 0.5 + 0.5;
+	float t = sphereCoords.y;
 
-	vec3 cameraToVertex = normalize(worldPos.xyz - vEyePosition.xyz);
+	return vec3(1.0 - s, t, 0);	
+}
+
+vec3 computeEquirectangularCoords(vec4 worldPos, vec3 worldNormal, vec3 eyePosition, mat4 reflectionMatrix)
+{
+	vec3 cameraToVertex = normalize(worldPos.xyz - eyePosition);
 	vec3 r = normalize(reflect(cameraToVertex, worldNormal));
 	r = vec3(reflectionMatrix * vec4(r, 0));
 	float lon = atan(r.z, r.x);
@@ -45,9 +48,10 @@ vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)
 	float t = sphereCoords.y;
 
 	return vec3(s, t, 0);
-#endif
+}
 
-#ifdef REFLECTIONMAP_SPHERICAL
+vec3 computeSpericalCoords(vec4 worldPos, vec3 worldNormal, mat4 view, mat4 reflectionMatrix)
+{
 	vec3 viewDir = normalize(vec3(view * worldPos));
 	vec3 viewNormal = normalize(vec3(view * vec4(worldNormal, 0.0)));
 
@@ -58,25 +62,41 @@ vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)
 	float m = 2.0 * length(r);
 
 	return vec3(r.x / m + 0.5, 1.0 - r.y / m - 0.5, 0);
-#endif
+}
 
-#ifdef REFLECTIONMAP_PLANAR
-	vec3 viewDir = worldPos.xyz - vEyePosition.xyz;
+vec3 computePlanarCoords(vec4 worldPos, vec3 worldNormal, vec3 eyePosition, mat4 reflectionMatrix)
+{
+	vec3 viewDir = worldPos.xyz - eyePosition;
 	vec3 coords = normalize(reflect(viewDir, worldNormal));
 
 	return vec3(reflectionMatrix * vec4(coords, 1));
-#endif
+}
 
-#ifdef REFLECTIONMAP_CUBIC
-    vec3 viewDir = normalize(worldPos.xyz - vEyePosition.xyz);
+vec3 computeCubicCoords(vec4 worldPos, vec3 worldNormal, vec3 eyePosition, mat4 reflectionMatrix)
+{
+    vec3 viewDir = normalize(worldPos.xyz - eyePosition);
 
     // worldNormal has already been normalized.
     vec3 coords = reflect(viewDir, worldNormal);
 
-    #ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
-        coords = parallaxCorrectNormal(worldPos.xyz, coords, vReflectionSize, vReflectionPosition);
+    coords = vec3(reflectionMatrix * vec4(coords, 0));
+
+    #ifdef INVERTCUBICMAP
+        coords.y *= -1.0;
     #endif
 
+    return coords;
+}
+
+vec3 computeCubicLocalCoords(vec4 worldPos, vec3 worldNormal, vec3 eyePosition, mat4 reflectionMatrix, vec3 reflectionSize, vec3 reflectionPosition)
+{
+    vec3 viewDir = normalize(worldPos.xyz - eyePosition);
+
+    // worldNormal has already been normalized.
+    vec3 coords = reflect(viewDir, worldNormal);
+
+	coords = parallaxCorrectNormal(worldPos.xyz, coords, reflectionSize, reflectionPosition);
+
     coords = vec3(reflectionMatrix * vec4(coords, 0));
 
     #ifdef INVERTCUBICMAP
@@ -84,18 +104,61 @@ vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)
     #endif
 
     return coords;
+}
+
+vec3 computeProjectionCoords(vec4 worldPos, mat4 view, mat4 reflectionMatrix)
+{
+	return vec3(reflectionMatrix * (view * worldPos));
+}
+
+vec3 computeSkyBoxCoords(vec3 positionW, mat4 reflectionMatrix)
+{
+	return vec3(reflectionMatrix * vec4(positionW, 0));
+}
+
+#ifdef REFLECTION
+vec3 computeReflectionCoords(vec4 worldPos, vec3 worldNormal)
+{
+#ifdef REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED
+	vec3 direction = normalize(vDirectionW);
+	return computeMirroredFixedEquirectangularCoords(worldPos, worldNormal, direction);
 #endif
 
+#ifdef REFLECTIONMAP_EQUIRECTANGULAR_FIXED
+	vec3 direction = normalize(vDirectionW);
+	return computeFixedEquirectangularCoords(worldPos, worldNormal, direction);
+#endif
+
+#ifdef REFLECTIONMAP_EQUIRECTANGULAR
+	return computeEquirectangularCoords(worldPos, worldNormal, vEyePosition.xyz, reflectionMatrix);
+#endif
+
+#ifdef REFLECTIONMAP_SPHERICAL
+	return computeSpericalCoords(worldPos, worldNormal, view, reflectionMatrix);
+#endif
+
+#ifdef REFLECTIONMAP_PLANAR
+	return computePlanarCoords(worldPos, worldNormal, vEyePosition.xyz, reflectionMatrix);
+#endif
+
+#ifdef REFLECTIONMAP_CUBIC
+	#ifdef USE_LOCAL_REFLECTIONMAP_CUBIC
+    	return computeCubicLocalCoords(worldPos, worldNormal, vEyePosition.xyz, reflectionMatrix, vReflectionSize, vReflectionPosition);
+	#else
+    	return computeCubicCoords(worldPos, worldNormal, vEyePosition.xyz, reflectionMatrix);
+	#endif
+#endif
 
 #ifdef REFLECTIONMAP_PROJECTION
-	return vec3(reflectionMatrix * (view * worldPos));
+	return computeProjectionCoords(worldPos, view, reflectionMatrix);
 #endif
 
 #ifdef REFLECTIONMAP_SKYBOX
-	return vec3(reflectionMatrix * vec4(vPositionUVW, 0));
+	return computeSkyBoxCoords(vPositionUVW, reflectionMatrix);
 #endif
 
 #ifdef REFLECTIONMAP_EXPLICIT
 	return vec3(0, 0, 0);
 #endif
-}
+}
+#endif

+ 2 - 2
src/Shaders/default.vertex.fx

@@ -113,9 +113,9 @@ void main(void) {
 
 #ifdef REFLECTIONMAP_SKYBOX
 	#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED
-		vPositionUVW = (reflectionMatrix * vec4(position, 1.0)).xyz;
+		vPositionUVW = (reflectionMatrix * vec4(positionUpdated, 1.0)).xyz;
 	#else
-		vPositionUVW = position;
+		vPositionUVW = positionUpdated;
 	#endif
 #endif