Explorar el Código

Merge branch 'master' into Worley_Block_Dev

David Catuhe hace 5 años
padre
commit
e8ef7eece5

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

@@ -17,6 +17,7 @@
 - Added support for multiple canvases with one engine [Doc](https://doc.babylonjs.com/how_to/multi_canvases) ([Deltakosh](https://github.com/deltakosh/)
 
 ## Updates
+
 ### General
 
 - Added support for dual shock gamepads ([Deltakosh](https://github.com/deltakosh/))
@@ -141,6 +142,7 @@
 - If canvas does not have WebXR support the scene will still render (mainly Firefox) ([RaananW](https://github.com/RaananW/))
 - Added support for foveated rendering in Oculus Quest ([Deltakosh](https://github.com/deltakosh/))
 - Added option to configure the output canvas ([RaananW](https://github.com/RaananW/))
+- Supporting multisampled multiview rendering using the oculus multiview extension ([RaananW](https://github.com/RaananW/))
 
 ### Ray
 
@@ -213,6 +215,7 @@
 - Prevent an infinite loop when calling `engine.dispose()` in a scene with multiple `SoundTracks` defined ([kirbysayshi](https://github.com/kirbysayshi))
 - Fixed missing properties in serialization / parsing of `coneParticleEmitter` ([Popov72](https://github.com/Popov72))
 - Fix a bug with exit VR and Edge ([RaananW](https://github.com/RaananW/))
+- Fixed an issue with size of texture in multiview ([RaananW](https://github.com/RaananW/))
 
 ## Breaking changes
 

+ 467 - 464
nodeEditor/src/blockTools.ts

@@ -1,465 +1,468 @@
-import { DiscardBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/discardBlock';
-import { BonesBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/bonesBlock';
-import { InstancesBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/instancesBlock';
-import { MorphTargetsBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock';
-import { ImageProcessingBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock';
-import { ColorMergerBlock } from 'babylonjs/Materials/Node/Blocks/colorMergerBlock';
-import { VectorMergerBlock } from 'babylonjs/Materials/Node/Blocks/vectorMergerBlock';
-import { ColorSplitterBlock } from 'babylonjs/Materials/Node/Blocks/colorSplitterBlock';
-import { VectorSplitterBlock } from 'babylonjs/Materials/Node/Blocks/vectorSplitterBlock';
-import { RemapBlock } from 'babylonjs/Materials/Node/Blocks/remapBlock';
-import { TextureBlock } from 'babylonjs/Materials/Node/Blocks/Dual/textureBlock';
-import { ReflectionTextureBlock } from 'babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock';
-import { LightBlock } from 'babylonjs/Materials/Node/Blocks/Dual/lightBlock';
-import { FogBlock } from 'babylonjs/Materials/Node/Blocks/Dual/fogBlock';
-import { VertexOutputBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock';
-import { FragmentOutputBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock';
-import { NormalizeBlock } from 'babylonjs/Materials/Node/Blocks/normalizeBlock';
-import { AddBlock } from 'babylonjs/Materials/Node/Blocks/addBlock';
-import { ScaleBlock } from 'babylonjs/Materials/Node/Blocks/scaleBlock';
-import { TrigonometryBlock, TrigonometryBlockOperations } from 'babylonjs/Materials/Node/Blocks/trigonometryBlock';
-import { ClampBlock } from 'babylonjs/Materials/Node/Blocks/clampBlock';
-import { CrossBlock } from 'babylonjs/Materials/Node/Blocks/crossBlock';
-import { DotBlock } from 'babylonjs/Materials/Node/Blocks/dotBlock';
-import { MultiplyBlock } from 'babylonjs/Materials/Node/Blocks/multiplyBlock';
-import { TransformBlock } from 'babylonjs/Materials/Node/Blocks/transformBlock';
-import { NodeMaterialBlockConnectionPointTypes } from 'babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes';
-import { FresnelBlock } from 'babylonjs/Materials/Node/Blocks/fresnelBlock';
-import { LerpBlock } from 'babylonjs/Materials/Node/Blocks/lerpBlock';
-import { NLerpBlock } from 'babylonjs/Materials/Node/Blocks/nLerpBlock';
-import { DivideBlock } from 'babylonjs/Materials/Node/Blocks/divideBlock';
-import { SubtractBlock } from 'babylonjs/Materials/Node/Blocks/subtractBlock';
-import { StepBlock } from 'babylonjs/Materials/Node/Blocks/stepBlock';
-import { SmoothStepBlock } from 'babylonjs/Materials/Node/Blocks/smoothStepBlock';
-import { InputBlock } from 'babylonjs/Materials/Node/Blocks/Input/inputBlock';
-import { NodeMaterialSystemValues } from 'babylonjs/Materials/Node/Enums/nodeMaterialSystemValues';
-import { AnimatedInputBlockTypes } from 'babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes';
-import { OneMinusBlock } from 'babylonjs/Materials/Node/Blocks/oneMinusBlock';
-import { ViewDirectionBlock } from 'babylonjs/Materials/Node/Blocks/viewDirectionBlock';
-import { LightInformationBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock';
-import { MaxBlock } from 'babylonjs/Materials/Node/Blocks/maxBlock';
-import { MinBlock } from 'babylonjs/Materials/Node/Blocks/minBlock';
-import { PerturbNormalBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock';
-import { LengthBlock } from 'babylonjs/Materials/Node/Blocks/lengthBlock';
-import { DistanceBlock } from 'babylonjs/Materials/Node/Blocks/distanceBlock';
-import { FrontFacingBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock';
-import { NegateBlock } from 'babylonjs/Materials/Node/Blocks/negateBlock';
-import { PowBlock } from 'babylonjs/Materials/Node/Blocks/powBlock';
-import { Scene } from 'babylonjs/scene';
-import { RandomNumberBlock } from 'babylonjs/Materials/Node/Blocks/randomNumberBlock';
-import { ReplaceColorBlock } from 'babylonjs/Materials/Node/Blocks/replaceColorBlock';
-import { PosterizeBlock } from 'babylonjs/Materials/Node/Blocks/posterizeBlock';
-import { ArcTan2Block } from 'babylonjs/Materials/Node/Blocks/arcTan2Block';
-import { ReciprocalBlock } from 'babylonjs/Materials/Node/Blocks/reciprocalBlock';
-import { GradientBlock } from 'babylonjs/Materials/Node/Blocks/gradientBlock';
-import { WaveBlock, WaveBlockKind } from 'babylonjs/Materials/Node/Blocks/waveBlock';
-import { NodeMaterial } from 'babylonjs/Materials/Node/nodeMaterial';
-import { WorleyNoise3DBlock } from 'babylonjs/Materials/Node/Blocks/worleyNoise3DBlock';
-
-export class BlockTools {
-    public static GetBlockFromString(data: string, scene: Scene, nodeMaterial: NodeMaterial) {
-        switch (data) {
-            case "WorleyNoise3DBlock":
-                return new WorleyNoise3DBlock("WorleyNoise3DBlock");
-            case "BonesBlock":
-                return new BonesBlock("Bones");
-            case "InstancesBlock":
-                return new InstancesBlock("Instances");
-            case "MorphTargetsBlock":
-                return new MorphTargetsBlock("MorphTargets");
-            case "DiscardBlock":
-                return new DiscardBlock("Discard");
-            case "ImageProcessingBlock":
-                return new ImageProcessingBlock("ImageProcessing");
-            case "ColorMergerBlock":
-                return new ColorMergerBlock("ColorMerger");
-            case "VectorMergerBlock":
-                return new VectorMergerBlock("VectorMerger");                
-            case "ColorSplitterBlock":
-                return new ColorSplitterBlock("ColorSplitter");
-            case "VectorSplitterBlock":
-                return new VectorSplitterBlock("VectorSplitter");
-            case "TextureBlock":
-                return new TextureBlock("Texture");
-            case "ReflectionTextureBlock":
-                return new ReflectionTextureBlock("Reflection texture");                
-            case "LightBlock":
-                return new LightBlock("Lights");
-            case "FogBlock":
-                return new FogBlock("Fog");
-            case "VertexOutputBlock":
-                return new VertexOutputBlock("VertexOutput");
-            case "FragmentOutputBlock":
-                return new FragmentOutputBlock("FragmentOutput");
-            case "AddBlock":
-                return new AddBlock("Add");
-            case "ClampBlock":
-                return new ClampBlock("Clamp");
-            case "ScaleBlock":
-                return new ScaleBlock("Scale");
-            case "CrossBlock":
-                return new CrossBlock("Cross");
-            case "DotBlock":
-                return new DotBlock("Dot");
-            case "PowBlock":
-                return new PowBlock("Pow");
-            case "MultiplyBlock":
-                return new MultiplyBlock("Multiply");
-            case "TransformBlock":
-                return new TransformBlock("Transform");
-            case "TrigonometryBlock":
-                return new TrigonometryBlock("Trigonometry");
-            case "RemapBlock":
-                return new RemapBlock("Remap");
-            case "NormalizeBlock":
-                return new NormalizeBlock("Normalize");
-            case "FresnelBlock":
-                return new FresnelBlock("Fresnel");
-            case "LerpBlock":
-                return new LerpBlock("Lerp");
-            case "NLerpBlock":
-                return new NLerpBlock("NLerp");
-            case "DivideBlock":
-                return new DivideBlock("Divide");
-            case "SubtractBlock":
-                return new SubtractBlock("Subtract"); 
-            case "StepBlock":
-                return new StepBlock("Step");        
-            case "SmoothStepBlock":
-                return new SmoothStepBlock("Smooth step");        
-            case "OneMinusBlock":
-                return new OneMinusBlock("One minus");          
-            case "ReciprocalBlock":
-                return new ReciprocalBlock("Reciprocal");    
-            case "ViewDirectionBlock":
-                return new ViewDirectionBlock("View direction");    
-            case "LightInformationBlock":
-                let lightInformationBlock = new LightInformationBlock("Light information");
-                lightInformationBlock.light = scene.lights.length ? scene.lights[0] : null;
-                return lightInformationBlock;
-            case "MaxBlock":
-                return new MaxBlock("Max");       
-            case "MinBlock":
-                return new MinBlock("Min");      
-            case "LengthBlock":
-                return new LengthBlock("Length");   
-            case "DistanceBlock":
-                return new DistanceBlock("Distance");     
-            case "NegateBlock":
-                return new NegateBlock("Negate");                                     
-            case "PerturbNormalBlock":                                          
-                return new PerturbNormalBlock("Perturb normal");                     
-            case "RandomNumberBlock":                                          
-                return new RandomNumberBlock("Random number");         
-            case "ReplaceColorBlock":                                          
-                return new ReplaceColorBlock("Replace color");      
-            case "PosterizeBlock":                                          
-                return new PosterizeBlock("Posterize");                              
-            case "ArcTan2Block":                                          
-                return new ArcTan2Block("ArcTan2");                            
-            case "GradientBlock":                                          
-                return new GradientBlock("Gradient");                             
-            case "FrontFacingBlock":                                          
-                return new FrontFacingBlock("Front facing");            
-            case "CosBlock": {
-                let cosBlock = new TrigonometryBlock("Cos");
-                cosBlock.operation = TrigonometryBlockOperations.Cos;
-                return cosBlock;
-            }
-            case "SinBlock": {
-                let sinBlock = new TrigonometryBlock("Sin");
-                sinBlock.operation = TrigonometryBlockOperations.Sin;
-                return sinBlock;
-            }
-            case "AbsBlock": {
-                let absBlock = new TrigonometryBlock("Abs");
-                absBlock.operation = TrigonometryBlockOperations.Abs;
-                return absBlock;
-            }            
-            case "SqrtBlock": {
-                let sqrtBlock = new TrigonometryBlock("Sqrt");
-                sqrtBlock.operation = TrigonometryBlockOperations.Sqrt;
-                return sqrtBlock;
-            }
-            case "ArcCosBlock": {
-                let acosBlock = new TrigonometryBlock("ArcCos");
-                acosBlock.operation = TrigonometryBlockOperations.ArcCos;
-                return acosBlock;
-            }
-            case "ArcSinBlock": {
-                let asinBlock = new TrigonometryBlock("ArcSin");
-                asinBlock.operation = TrigonometryBlockOperations.ArcSin;
-                return asinBlock;
-            }
-            case "TanBlock": {
-                let tanBlock = new TrigonometryBlock("Tan");
-                tanBlock.operation = TrigonometryBlockOperations.Tan;
-                return tanBlock;
-            }
-            case "ArcTanBlock": {
-                let atanBlock = new TrigonometryBlock("ArcTan");
-                atanBlock.operation = TrigonometryBlockOperations.ArcTan;
-                return atanBlock;
-            }
-            case "FractBlock": {
-                let fractBlock = new TrigonometryBlock("Fract");
-                fractBlock.operation = TrigonometryBlockOperations.Fract;
-                return fractBlock;
-            }
-            case "SignBlock": {
-                let signBlock = new TrigonometryBlock("Sign");
-                signBlock.operation = TrigonometryBlockOperations.Sign;
-                return signBlock;
-            }            
-            case "LogBlock": {
-                let logBlock = new TrigonometryBlock("Log");
-                logBlock.operation = TrigonometryBlockOperations.Log;
-                return logBlock;
-            }                                                            
-            case "ExpBlock": {
-                let expBlock = new TrigonometryBlock("Exp");
-                expBlock.operation = TrigonometryBlockOperations.Exp;
-                return expBlock;
-            }
-            case "Exp2Block": {
-                let exp2Block = new TrigonometryBlock("Exp2");
-                exp2Block.operation = TrigonometryBlockOperations.Exp2;
-                return exp2Block;
-            }
-            case "DegreesToRadiansBlock": {
-                let degreesToRadiansBlock = new TrigonometryBlock("Degrees to radians");
-                degreesToRadiansBlock.operation = TrigonometryBlockOperations.Radians;
-                return degreesToRadiansBlock;
-            }
-            case "RadiansToDegreesBlock": {
-                let radiansToDegreesBlock = new TrigonometryBlock("Radians to degrees");
-                radiansToDegreesBlock.operation = TrigonometryBlockOperations.Degrees;
-                return radiansToDegreesBlock;
-            }                        
-            case "RoundBlock": {
-                let roundBlock = new TrigonometryBlock("Round");
-                roundBlock.operation = TrigonometryBlockOperations.Round;
-                return roundBlock;
-            }
-            case "CeilingBlock": {
-                let ceilingBlock = new TrigonometryBlock("Ceiling");
-                ceilingBlock.operation = TrigonometryBlockOperations.Ceiling;
-                return ceilingBlock;
-            }     
-            case "FloorBlock": {
-                let floorBlock = new TrigonometryBlock("Floor");
-                floorBlock.operation = TrigonometryBlockOperations.Floor;
-                return floorBlock;
-            }       
-            case "SawToothWaveBlock": {
-                let sawToothWaveBlock = new WaveBlock("SawTooth wave");
-                sawToothWaveBlock.kind = WaveBlockKind.SawTooth;
-                return sawToothWaveBlock;
-            }     
-            case "SquareWaveBlock": {
-                let squareWaveBlock = new WaveBlock("Square wave");
-                squareWaveBlock.kind = WaveBlockKind.Square;
-                return squareWaveBlock;
-            }     
-            case "TriangleWaveBlock": {
-                let triangleWaveBlock = new WaveBlock("Triangle wave");
-                triangleWaveBlock.kind = WaveBlockKind.Triangle;
-                return triangleWaveBlock;
-            }
-            case "WorldMatrixBlock": {
-                let worldMatrixBlock = new InputBlock("World");
-                worldMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.World);
-                return worldMatrixBlock;
-            }             
-            case "WorldViewMatrixBlock": {
-                let worldViewMatrixBlock = new InputBlock("World x View");
-                worldViewMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.WorldView);
-                return worldViewMatrixBlock;
-            }             
-            case "WorldViewProjectionMatrixBlock": {
-                let worldViewProjectionMatrixBlock = new InputBlock("World x View x Projection");
-                worldViewProjectionMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.WorldViewProjection);
-                return worldViewProjectionMatrixBlock;
-            }                    
-            case "ViewMatrixBlock": {
-                let viewMatrixBlock = new InputBlock("View");
-                viewMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.View);
-                return viewMatrixBlock;
-            }                          
-            case "ViewProjectionMatrixBlock": {
-                let viewProjectionMatrixBlock = new InputBlock("View x Projection");
-                viewProjectionMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.ViewProjection);
-                return viewProjectionMatrixBlock;
-            }                              
-            case "ProjectionMatrixBlock": {
-                let projectionMatrixBlock = new InputBlock("Projection");
-                projectionMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.Projection);
-                return projectionMatrixBlock;
-            }                                 
-            case "CameraPositionBlock": {
-                let cameraPosition = new InputBlock("Camera position");
-                cameraPosition.setAsSystemValue(NodeMaterialSystemValues.CameraPosition);
-                return cameraPosition;
-            }                              
-            case "FogColorBlock": {
-                let FogColor = new InputBlock("Fog color");
-                FogColor.setAsSystemValue(NodeMaterialSystemValues.FogColor);
-                return FogColor;
-            }                                   
-            case "PositionBlock": {
-                let meshPosition = new InputBlock("position");
-                meshPosition.setAsAttribute("position");
-                return meshPosition;
-            }                                        
-            case "UVBlock": {
-                let meshUV = new InputBlock("uv");
-                meshUV.setAsAttribute("uv");
-                return meshUV;
-            }                                         
-            case "ColorBlock": {
-                let meshColor = new InputBlock("color");
-                meshColor.setAsAttribute("color");
-                return meshColor;
-            }                                              
-            case "NormalBlock": {
-                let meshNormal = new InputBlock("normal");
-                meshNormal.setAsAttribute("normal");
-                return meshNormal;
-            }                                                 
-            case "TangentBlock": {
-                let meshTangent = new InputBlock("tangent");
-                meshTangent.setAsAttribute("tangent");
-                return meshTangent;
-            }                                                  
-            case "MatrixIndicesBlock": {
-                let meshMatrixIndices = new InputBlock("matricesIndices");
-                meshMatrixIndices.setAsAttribute("matricesIndices");
-                return meshMatrixIndices;
-            }                                                    
-            case "MatrixWeightsBlock": {
-                let meshMatrixWeights = new InputBlock("matricesWeights");
-                meshMatrixWeights.setAsAttribute("matricesWeights");
-                return meshMatrixWeights;
-            }                                                     
-            case "TimeBlock": {
-                let timeBlock = new InputBlock("Time", undefined, NodeMaterialBlockConnectionPointTypes.Float);
-                timeBlock.animationType = AnimatedInputBlockTypes.Time;
-                return timeBlock;
-            }   
-            case "DeltaTimeBlock": {
-                let deltaTimeBlock = new InputBlock("Delta time");                
-                deltaTimeBlock.setAsSystemValue(NodeMaterialSystemValues.DeltaTime);
-                return deltaTimeBlock;
-            }      
-            case "WorldPositionBlock": {
-                let worldPositionBlock = nodeMaterial.getInputBlockByPredicate(b => b.isAttribute && b.name === "position");                
-                if (!worldPositionBlock) {
-                    worldPositionBlock = new InputBlock("position");
-                    worldPositionBlock.setAsAttribute("position");
-                }
-
-                let worldMatrixBlock = nodeMaterial.getInputBlockByPredicate(b => b.isSystemValue && b.systemValue === NodeMaterialSystemValues.World);  
-
-                if (!worldMatrixBlock) {
-                    worldMatrixBlock = new InputBlock("World");
-                    worldMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.World);
-                }
-
-                let transformBlock = new TransformBlock("World position");
-                worldPositionBlock.connectTo(transformBlock);
-                worldMatrixBlock.connectTo(transformBlock);
-
-                return transformBlock;
-            }        
-            case "WorldNormalBlock": {
-                let worldNormalBlock = nodeMaterial.getInputBlockByPredicate(b => b.isAttribute && b.name === "normal");                
-                if (!worldNormalBlock) {
-                    worldNormalBlock = new InputBlock("normal");
-                    worldNormalBlock.setAsAttribute("normal");
-                }
-
-                let worldMatrixBlock = nodeMaterial.getInputBlockByPredicate(b => b.isSystemValue && b.systemValue === NodeMaterialSystemValues.World);  
-
-                if (!worldMatrixBlock) {
-                    worldMatrixBlock = new InputBlock("World");
-                    worldMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.World);
-                }
-
-                let transformBlock = new TransformBlock("World normal");
-                worldNormalBlock.connectTo(transformBlock);
-                worldMatrixBlock.connectTo(transformBlock);
-
-                return transformBlock;
-            }                  
-        }
-
-        return null;
-    }
-
-    public static GetColorFromConnectionNodeType(type: NodeMaterialBlockConnectionPointTypes) {
-        let color = "Red";
-        switch (type) {
-            case NodeMaterialBlockConnectionPointTypes.Float:
-				color = "#cb9e27";
-                break;
-            case NodeMaterialBlockConnectionPointTypes.Vector2:                
-				color = "#16bcb1";
-                break;
-            case NodeMaterialBlockConnectionPointTypes.Vector3:                
-            case NodeMaterialBlockConnectionPointTypes.Color3:                
-                color = "#b786cb";
-                break;
-            case NodeMaterialBlockConnectionPointTypes.Vector4:                
-            case NodeMaterialBlockConnectionPointTypes.Color4:                
-				color = "#be5126";
-                break;
-            case NodeMaterialBlockConnectionPointTypes.Matrix:                
-				color = "#591990";
-                break;
-        }
-
-        return color;
-    }
-
-    public static GetConnectionNodeTypeFromString(type: string) {
-        switch (type) {
-            case "Float":
-                return NodeMaterialBlockConnectionPointTypes.Float;
-            case "Vector2":
-                return NodeMaterialBlockConnectionPointTypes.Vector2;
-            case "Vector3":
-                return NodeMaterialBlockConnectionPointTypes.Vector3;
-            case "Vector4":
-                return NodeMaterialBlockConnectionPointTypes.Vector4;
-            case "Matrix":
-                return NodeMaterialBlockConnectionPointTypes.Matrix;
-            case "Color3":
-                return NodeMaterialBlockConnectionPointTypes.Color3;
-            case "Color4":
-                return NodeMaterialBlockConnectionPointTypes.Color4;
-        }
-
-        return NodeMaterialBlockConnectionPointTypes.AutoDetect;
-    }
-
-    public static GetStringFromConnectionNodeType(type: NodeMaterialBlockConnectionPointTypes) {
-        switch (type){
-            case NodeMaterialBlockConnectionPointTypes.Float:
-                return "Float";
-            case NodeMaterialBlockConnectionPointTypes.Vector2:
-                return "Vector2";
-            case NodeMaterialBlockConnectionPointTypes.Vector3:
-                return "Vector3";
-            case NodeMaterialBlockConnectionPointTypes.Vector4:
-                return "Vector4";
-            case NodeMaterialBlockConnectionPointTypes.Color3:
-                return "Color3";
-            case NodeMaterialBlockConnectionPointTypes.Color4:
-                return "Color4";
-            case NodeMaterialBlockConnectionPointTypes.Matrix:
-                return "Matrix";
-        }
-
-        return "";
-    }
+import { DiscardBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/discardBlock';
+import { BonesBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/bonesBlock';
+import { InstancesBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/instancesBlock';
+import { MorphTargetsBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock';
+import { ImageProcessingBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock';
+import { ColorMergerBlock } from 'babylonjs/Materials/Node/Blocks/colorMergerBlock';
+import { VectorMergerBlock } from 'babylonjs/Materials/Node/Blocks/vectorMergerBlock';
+import { ColorSplitterBlock } from 'babylonjs/Materials/Node/Blocks/colorSplitterBlock';
+import { VectorSplitterBlock } from 'babylonjs/Materials/Node/Blocks/vectorSplitterBlock';
+import { RemapBlock } from 'babylonjs/Materials/Node/Blocks/remapBlock';
+import { TextureBlock } from 'babylonjs/Materials/Node/Blocks/Dual/textureBlock';
+import { ReflectionTextureBlock } from 'babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock';
+import { LightBlock } from 'babylonjs/Materials/Node/Blocks/Dual/lightBlock';
+import { FogBlock } from 'babylonjs/Materials/Node/Blocks/Dual/fogBlock';
+import { VertexOutputBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock';
+import { FragmentOutputBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock';
+import { NormalizeBlock } from 'babylonjs/Materials/Node/Blocks/normalizeBlock';
+import { AddBlock } from 'babylonjs/Materials/Node/Blocks/addBlock';
+import { ScaleBlock } from 'babylonjs/Materials/Node/Blocks/scaleBlock';
+import { TrigonometryBlock, TrigonometryBlockOperations } from 'babylonjs/Materials/Node/Blocks/trigonometryBlock';
+import { ClampBlock } from 'babylonjs/Materials/Node/Blocks/clampBlock';
+import { CrossBlock } from 'babylonjs/Materials/Node/Blocks/crossBlock';
+import { DotBlock } from 'babylonjs/Materials/Node/Blocks/dotBlock';
+import { MultiplyBlock } from 'babylonjs/Materials/Node/Blocks/multiplyBlock';
+import { TransformBlock } from 'babylonjs/Materials/Node/Blocks/transformBlock';
+import { NodeMaterialBlockConnectionPointTypes } from 'babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes';
+import { FresnelBlock } from 'babylonjs/Materials/Node/Blocks/fresnelBlock';
+import { LerpBlock } from 'babylonjs/Materials/Node/Blocks/lerpBlock';
+import { NLerpBlock } from 'babylonjs/Materials/Node/Blocks/nLerpBlock';
+import { DivideBlock } from 'babylonjs/Materials/Node/Blocks/divideBlock';
+import { SubtractBlock } from 'babylonjs/Materials/Node/Blocks/subtractBlock';
+import { StepBlock } from 'babylonjs/Materials/Node/Blocks/stepBlock';
+import { SmoothStepBlock } from 'babylonjs/Materials/Node/Blocks/smoothStepBlock';
+import { InputBlock } from 'babylonjs/Materials/Node/Blocks/Input/inputBlock';
+import { NodeMaterialSystemValues } from 'babylonjs/Materials/Node/Enums/nodeMaterialSystemValues';
+import { AnimatedInputBlockTypes } from 'babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes';
+import { OneMinusBlock } from 'babylonjs/Materials/Node/Blocks/oneMinusBlock';
+import { ViewDirectionBlock } from 'babylonjs/Materials/Node/Blocks/viewDirectionBlock';
+import { LightInformationBlock } from 'babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock';
+import { MaxBlock } from 'babylonjs/Materials/Node/Blocks/maxBlock';
+import { MinBlock } from 'babylonjs/Materials/Node/Blocks/minBlock';
+import { PerturbNormalBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock';
+import { LengthBlock } from 'babylonjs/Materials/Node/Blocks/lengthBlock';
+import { DistanceBlock } from 'babylonjs/Materials/Node/Blocks/distanceBlock';
+import { FrontFacingBlock } from 'babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock';
+import { NegateBlock } from 'babylonjs/Materials/Node/Blocks/negateBlock';
+import { PowBlock } from 'babylonjs/Materials/Node/Blocks/powBlock';
+import { Scene } from 'babylonjs/scene';
+import { RandomNumberBlock } from 'babylonjs/Materials/Node/Blocks/randomNumberBlock';
+import { ReplaceColorBlock } from 'babylonjs/Materials/Node/Blocks/replaceColorBlock';
+import { PosterizeBlock } from 'babylonjs/Materials/Node/Blocks/posterizeBlock';
+import { ArcTan2Block } from 'babylonjs/Materials/Node/Blocks/arcTan2Block';
+import { ReciprocalBlock } from 'babylonjs/Materials/Node/Blocks/reciprocalBlock';
+import { GradientBlock } from 'babylonjs/Materials/Node/Blocks/gradientBlock';
+import { WaveBlock, WaveBlockKind } from 'babylonjs/Materials/Node/Blocks/waveBlock';
+import { NodeMaterial } from 'babylonjs/Materials/Node/nodeMaterial';
+import { WorleyNoise3DBlock } from 'babylonjs/Materials/Node/Blocks/worleyNoise3DBlock';
+import { SimplexPerlin3DBlock } from 'babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock';
+
+export class BlockTools {
+    public static GetBlockFromString(data: string, scene: Scene, nodeMaterial: NodeMaterial) {
+        switch (data) {
+            case "WorleyNoise3DBlock":
+                return new WorleyNoise3DBlock("WorleyNoise3D");
+            case "SimplexPerlin3DBlock":
+                return new SimplexPerlin3DBlock("SimplexPerlin3D");
+            case "BonesBlock":
+                return new BonesBlock("Bones");
+            case "InstancesBlock":
+                return new InstancesBlock("Instances");
+            case "MorphTargetsBlock":
+                return new MorphTargetsBlock("MorphTargets");
+            case "DiscardBlock":
+                return new DiscardBlock("Discard");
+            case "ImageProcessingBlock":
+                return new ImageProcessingBlock("ImageProcessing");
+            case "ColorMergerBlock":
+                return new ColorMergerBlock("ColorMerger");
+            case "VectorMergerBlock":
+                return new VectorMergerBlock("VectorMerger");                
+            case "ColorSplitterBlock":
+                return new ColorSplitterBlock("ColorSplitter");
+            case "VectorSplitterBlock":
+                return new VectorSplitterBlock("VectorSplitter");
+            case "TextureBlock":
+                return new TextureBlock("Texture");
+            case "ReflectionTextureBlock":
+                return new ReflectionTextureBlock("Reflection texture");                
+            case "LightBlock":
+                return new LightBlock("Lights");
+            case "FogBlock":
+                return new FogBlock("Fog");
+            case "VertexOutputBlock":
+                return new VertexOutputBlock("VertexOutput");
+            case "FragmentOutputBlock":
+                return new FragmentOutputBlock("FragmentOutput");
+            case "AddBlock":
+                return new AddBlock("Add");
+            case "ClampBlock":
+                return new ClampBlock("Clamp");
+            case "ScaleBlock":
+                return new ScaleBlock("Scale");
+            case "CrossBlock":
+                return new CrossBlock("Cross");
+            case "DotBlock":
+                return new DotBlock("Dot");
+            case "PowBlock":
+                return new PowBlock("Pow");
+            case "MultiplyBlock":
+                return new MultiplyBlock("Multiply");
+            case "TransformBlock":
+                return new TransformBlock("Transform");
+            case "TrigonometryBlock":
+                return new TrigonometryBlock("Trigonometry");
+            case "RemapBlock":
+                return new RemapBlock("Remap");
+            case "NormalizeBlock":
+                return new NormalizeBlock("Normalize");
+            case "FresnelBlock":
+                return new FresnelBlock("Fresnel");
+            case "LerpBlock":
+                return new LerpBlock("Lerp");
+            case "NLerpBlock":
+                return new NLerpBlock("NLerp");
+            case "DivideBlock":
+                return new DivideBlock("Divide");
+            case "SubtractBlock":
+                return new SubtractBlock("Subtract"); 
+            case "StepBlock":
+                return new StepBlock("Step");        
+            case "SmoothStepBlock":
+                return new SmoothStepBlock("Smooth step");        
+            case "OneMinusBlock":
+                return new OneMinusBlock("One minus");          
+            case "ReciprocalBlock":
+                return new ReciprocalBlock("Reciprocal");    
+            case "ViewDirectionBlock":
+                return new ViewDirectionBlock("View direction");    
+            case "LightInformationBlock":
+                let lightInformationBlock = new LightInformationBlock("Light information");
+                lightInformationBlock.light = scene.lights.length ? scene.lights[0] : null;
+                return lightInformationBlock;
+            case "MaxBlock":
+                return new MaxBlock("Max");       
+            case "MinBlock":
+                return new MinBlock("Min");      
+            case "LengthBlock":
+                return new LengthBlock("Length");   
+            case "DistanceBlock":
+                return new DistanceBlock("Distance");     
+            case "NegateBlock":
+                return new NegateBlock("Negate");                                     
+            case "PerturbNormalBlock":                                          
+                return new PerturbNormalBlock("Perturb normal");                     
+            case "RandomNumberBlock":                                          
+                return new RandomNumberBlock("Random number");         
+            case "ReplaceColorBlock":                                          
+                return new ReplaceColorBlock("Replace color");      
+            case "PosterizeBlock":                                          
+                return new PosterizeBlock("Posterize");                              
+            case "ArcTan2Block":                                          
+                return new ArcTan2Block("ArcTan2");                            
+            case "GradientBlock":                                          
+                return new GradientBlock("Gradient");                             
+            case "FrontFacingBlock":                                          
+                return new FrontFacingBlock("Front facing");            
+            case "CosBlock": {
+                let cosBlock = new TrigonometryBlock("Cos");
+                cosBlock.operation = TrigonometryBlockOperations.Cos;
+                return cosBlock;
+            }
+            case "SinBlock": {
+                let sinBlock = new TrigonometryBlock("Sin");
+                sinBlock.operation = TrigonometryBlockOperations.Sin;
+                return sinBlock;
+            }
+            case "AbsBlock": {
+                let absBlock = new TrigonometryBlock("Abs");
+                absBlock.operation = TrigonometryBlockOperations.Abs;
+                return absBlock;
+            }            
+            case "SqrtBlock": {
+                let sqrtBlock = new TrigonometryBlock("Sqrt");
+                sqrtBlock.operation = TrigonometryBlockOperations.Sqrt;
+                return sqrtBlock;
+            }
+            case "ArcCosBlock": {
+                let acosBlock = new TrigonometryBlock("ArcCos");
+                acosBlock.operation = TrigonometryBlockOperations.ArcCos;
+                return acosBlock;
+            }
+            case "ArcSinBlock": {
+                let asinBlock = new TrigonometryBlock("ArcSin");
+                asinBlock.operation = TrigonometryBlockOperations.ArcSin;
+                return asinBlock;
+            }
+            case "TanBlock": {
+                let tanBlock = new TrigonometryBlock("Tan");
+                tanBlock.operation = TrigonometryBlockOperations.Tan;
+                return tanBlock;
+            }
+            case "ArcTanBlock": {
+                let atanBlock = new TrigonometryBlock("ArcTan");
+                atanBlock.operation = TrigonometryBlockOperations.ArcTan;
+                return atanBlock;
+            }
+            case "FractBlock": {
+                let fractBlock = new TrigonometryBlock("Fract");
+                fractBlock.operation = TrigonometryBlockOperations.Fract;
+                return fractBlock;
+            }
+            case "SignBlock": {
+                let signBlock = new TrigonometryBlock("Sign");
+                signBlock.operation = TrigonometryBlockOperations.Sign;
+                return signBlock;
+            }            
+            case "LogBlock": {
+                let logBlock = new TrigonometryBlock("Log");
+                logBlock.operation = TrigonometryBlockOperations.Log;
+                return logBlock;
+            }                                                            
+            case "ExpBlock": {
+                let expBlock = new TrigonometryBlock("Exp");
+                expBlock.operation = TrigonometryBlockOperations.Exp;
+                return expBlock;
+            }
+            case "Exp2Block": {
+                let exp2Block = new TrigonometryBlock("Exp2");
+                exp2Block.operation = TrigonometryBlockOperations.Exp2;
+                return exp2Block;
+            }
+            case "DegreesToRadiansBlock": {
+                let degreesToRadiansBlock = new TrigonometryBlock("Degrees to radians");
+                degreesToRadiansBlock.operation = TrigonometryBlockOperations.Radians;
+                return degreesToRadiansBlock;
+            }
+            case "RadiansToDegreesBlock": {
+                let radiansToDegreesBlock = new TrigonometryBlock("Radians to degrees");
+                radiansToDegreesBlock.operation = TrigonometryBlockOperations.Degrees;
+                return radiansToDegreesBlock;
+            }                        
+            case "RoundBlock": {
+                let roundBlock = new TrigonometryBlock("Round");
+                roundBlock.operation = TrigonometryBlockOperations.Round;
+                return roundBlock;
+            }
+            case "CeilingBlock": {
+                let ceilingBlock = new TrigonometryBlock("Ceiling");
+                ceilingBlock.operation = TrigonometryBlockOperations.Ceiling;
+                return ceilingBlock;
+            }     
+            case "FloorBlock": {
+                let floorBlock = new TrigonometryBlock("Floor");
+                floorBlock.operation = TrigonometryBlockOperations.Floor;
+                return floorBlock;
+            }       
+            case "SawToothWaveBlock": {
+                let sawToothWaveBlock = new WaveBlock("SawTooth wave");
+                sawToothWaveBlock.kind = WaveBlockKind.SawTooth;
+                return sawToothWaveBlock;
+            }     
+            case "SquareWaveBlock": {
+                let squareWaveBlock = new WaveBlock("Square wave");
+                squareWaveBlock.kind = WaveBlockKind.Square;
+                return squareWaveBlock;
+            }     
+            case "TriangleWaveBlock": {
+                let triangleWaveBlock = new WaveBlock("Triangle wave");
+                triangleWaveBlock.kind = WaveBlockKind.Triangle;
+                return triangleWaveBlock;
+            }
+            case "WorldMatrixBlock": {
+                let worldMatrixBlock = new InputBlock("World");
+                worldMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.World);
+                return worldMatrixBlock;
+            }             
+            case "WorldViewMatrixBlock": {
+                let worldViewMatrixBlock = new InputBlock("World x View");
+                worldViewMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.WorldView);
+                return worldViewMatrixBlock;
+            }             
+            case "WorldViewProjectionMatrixBlock": {
+                let worldViewProjectionMatrixBlock = new InputBlock("World x View x Projection");
+                worldViewProjectionMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.WorldViewProjection);
+                return worldViewProjectionMatrixBlock;
+            }                    
+            case "ViewMatrixBlock": {
+                let viewMatrixBlock = new InputBlock("View");
+                viewMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.View);
+                return viewMatrixBlock;
+            }                          
+            case "ViewProjectionMatrixBlock": {
+                let viewProjectionMatrixBlock = new InputBlock("View x Projection");
+                viewProjectionMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.ViewProjection);
+                return viewProjectionMatrixBlock;
+            }                              
+            case "ProjectionMatrixBlock": {
+                let projectionMatrixBlock = new InputBlock("Projection");
+                projectionMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.Projection);
+                return projectionMatrixBlock;
+            }                                 
+            case "CameraPositionBlock": {
+                let cameraPosition = new InputBlock("Camera position");
+                cameraPosition.setAsSystemValue(NodeMaterialSystemValues.CameraPosition);
+                return cameraPosition;
+            }                              
+            case "FogColorBlock": {
+                let FogColor = new InputBlock("Fog color");
+                FogColor.setAsSystemValue(NodeMaterialSystemValues.FogColor);
+                return FogColor;
+            }                                   
+            case "PositionBlock": {
+                let meshPosition = new InputBlock("position");
+                meshPosition.setAsAttribute("position");
+                return meshPosition;
+            }                                        
+            case "UVBlock": {
+                let meshUV = new InputBlock("uv");
+                meshUV.setAsAttribute("uv");
+                return meshUV;
+            }                                         
+            case "ColorBlock": {
+                let meshColor = new InputBlock("color");
+                meshColor.setAsAttribute("color");
+                return meshColor;
+            }                                              
+            case "NormalBlock": {
+                let meshNormal = new InputBlock("normal");
+                meshNormal.setAsAttribute("normal");
+                return meshNormal;
+            }                                                 
+            case "TangentBlock": {
+                let meshTangent = new InputBlock("tangent");
+                meshTangent.setAsAttribute("tangent");
+                return meshTangent;
+            }                                                  
+            case "MatrixIndicesBlock": {
+                let meshMatrixIndices = new InputBlock("matricesIndices");
+                meshMatrixIndices.setAsAttribute("matricesIndices");
+                return meshMatrixIndices;
+            }                                                    
+            case "MatrixWeightsBlock": {
+                let meshMatrixWeights = new InputBlock("matricesWeights");
+                meshMatrixWeights.setAsAttribute("matricesWeights");
+                return meshMatrixWeights;
+            }                                                     
+            case "TimeBlock": {
+                let timeBlock = new InputBlock("Time", undefined, NodeMaterialBlockConnectionPointTypes.Float);
+                timeBlock.animationType = AnimatedInputBlockTypes.Time;
+                return timeBlock;
+            }   
+            case "DeltaTimeBlock": {
+                let deltaTimeBlock = new InputBlock("Delta time");                
+                deltaTimeBlock.setAsSystemValue(NodeMaterialSystemValues.DeltaTime);
+                return deltaTimeBlock;
+            }      
+            case "WorldPositionBlock": {
+                let worldPositionBlock = nodeMaterial.getInputBlockByPredicate(b => b.isAttribute && b.name === "position");                
+                if (!worldPositionBlock) {
+                    worldPositionBlock = new InputBlock("position");
+                    worldPositionBlock.setAsAttribute("position");
+                }
+
+                let worldMatrixBlock = nodeMaterial.getInputBlockByPredicate(b => b.isSystemValue && b.systemValue === NodeMaterialSystemValues.World);  
+
+                if (!worldMatrixBlock) {
+                    worldMatrixBlock = new InputBlock("World");
+                    worldMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.World);
+                }
+
+                let transformBlock = new TransformBlock("World position");
+                worldPositionBlock.connectTo(transformBlock);
+                worldMatrixBlock.connectTo(transformBlock);
+
+                return transformBlock;
+            }        
+            case "WorldNormalBlock": {
+                let worldNormalBlock = nodeMaterial.getInputBlockByPredicate(b => b.isAttribute && b.name === "normal");                
+                if (!worldNormalBlock) {
+                    worldNormalBlock = new InputBlock("normal");
+                    worldNormalBlock.setAsAttribute("normal");
+                }
+
+                let worldMatrixBlock = nodeMaterial.getInputBlockByPredicate(b => b.isSystemValue && b.systemValue === NodeMaterialSystemValues.World);  
+
+                if (!worldMatrixBlock) {
+                    worldMatrixBlock = new InputBlock("World");
+                    worldMatrixBlock.setAsSystemValue(NodeMaterialSystemValues.World);
+                }
+
+                let transformBlock = new TransformBlock("World normal");
+                worldNormalBlock.connectTo(transformBlock);
+                worldMatrixBlock.connectTo(transformBlock);
+
+                return transformBlock;
+            }                  
+        }
+
+        return null;
+    }
+
+    public static GetColorFromConnectionNodeType(type: NodeMaterialBlockConnectionPointTypes) {
+        let color = "Red";
+        switch (type) {
+            case NodeMaterialBlockConnectionPointTypes.Float:
+				color = "#cb9e27";
+                break;
+            case NodeMaterialBlockConnectionPointTypes.Vector2:                
+				color = "#16bcb1";
+                break;
+            case NodeMaterialBlockConnectionPointTypes.Vector3:                
+            case NodeMaterialBlockConnectionPointTypes.Color3:                
+                color = "#b786cb";
+                break;
+            case NodeMaterialBlockConnectionPointTypes.Vector4:                
+            case NodeMaterialBlockConnectionPointTypes.Color4:                
+				color = "#be5126";
+                break;
+            case NodeMaterialBlockConnectionPointTypes.Matrix:                
+				color = "#591990";
+                break;
+        }
+
+        return color;
+    }
+
+    public static GetConnectionNodeTypeFromString(type: string) {
+        switch (type) {
+            case "Float":
+                return NodeMaterialBlockConnectionPointTypes.Float;
+            case "Vector2":
+                return NodeMaterialBlockConnectionPointTypes.Vector2;
+            case "Vector3":
+                return NodeMaterialBlockConnectionPointTypes.Vector3;
+            case "Vector4":
+                return NodeMaterialBlockConnectionPointTypes.Vector4;
+            case "Matrix":
+                return NodeMaterialBlockConnectionPointTypes.Matrix;
+            case "Color3":
+                return NodeMaterialBlockConnectionPointTypes.Color3;
+            case "Color4":
+                return NodeMaterialBlockConnectionPointTypes.Color4;
+        }
+
+        return NodeMaterialBlockConnectionPointTypes.AutoDetect;
+    }
+
+    public static GetStringFromConnectionNodeType(type: NodeMaterialBlockConnectionPointTypes) {
+        switch (type){
+            case NodeMaterialBlockConnectionPointTypes.Float:
+                return "Float";
+            case NodeMaterialBlockConnectionPointTypes.Vector2:
+                return "Vector2";
+            case NodeMaterialBlockConnectionPointTypes.Vector3:
+                return "Vector3";
+            case NodeMaterialBlockConnectionPointTypes.Vector4:
+                return "Vector4";
+            case NodeMaterialBlockConnectionPointTypes.Color3:
+                return "Color3";
+            case NodeMaterialBlockConnectionPointTypes.Color4:
+                return "Color4";
+            case NodeMaterialBlockConnectionPointTypes.Matrix:
+                return "Matrix";
+        }
+
+        return "";
+    }
 }

+ 1 - 1
nodeEditor/src/components/nodeList/nodeListComponent.tsx

@@ -33,7 +33,7 @@ export class NodeListComponent extends React.Component<INodeListComponentProps,
             Interpolation: ["LerpBlock", "SmoothStepBlock", "NLerpBlock"],
             Matrices: ["Matrix", "WorldMatrixBlock", "WorldViewMatrixBlock", "WorldViewProjectionMatrixBlock", "ViewMatrixBlock", "ViewProjectionMatrixBlock", "ProjectionMatrixBlock"],
             Mesh: ["InstancesBlock", "PositionBlock", "UVBlock", "ColorBlock", "NormalBlock", "TangentBlock", "MatrixIndicesBlock", "MatrixWeightsBlock", "WorldPositionBlock", "WorldNormalBlock", "FrontFacingBlock"], 
-            Noises: ["WorleyNoise3DBlock"],
+            Noises: ["SimplexPerlin3DBlock", "WorleyNoise3DBlock"],
             Output_Blocks: ["VertexOutputBlock", "FragmentOutputBlock", "DiscardBlock"],
             Range: ["ClampBlock", "RemapBlock", "NormalizeBlock"],
             Round: ["StepBlock", "RoundBlock", "CeilingBlock", "FloorBlock"],

+ 2 - 2
src/Cameras/VR/webVRCamera.ts

@@ -278,7 +278,7 @@ export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
             this.setCameraRigMode(Camera.RIG_MODE_WEBVR, { parentCamera: this, vrDisplay: this._vrDevice, frameData: this._frameData, specs: this._specsVersion });
 
             if (this._attached) {
-                this.getEngine().enableVR();
+                this.getEngine().enableVR(this.webVROptions);
             }
         });
 
@@ -506,7 +506,7 @@ export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
         noPreventDefault = Camera.ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
 
         if (this._vrDevice) {
-            this.getEngine().enableVR();
+            this.getEngine().enableVR(this.webVROptions);
         }
 
         let hostWindow = this._scene.getEngine().getHostWindow();

+ 9 - 4
src/Engines/Extensions/engine.multiview.ts

@@ -52,13 +52,18 @@ Engine.prototype.createMultiviewRenderTargetTexture = function(width: number, he
 
 Engine.prototype.bindMultiviewFramebuffer = function(multiviewTexture: InternalTexture) {
     var gl: any = this._gl;
-    var ext = this.getCaps().multiview;
+    var ext = this.getCaps().oculusMultiview || this.getCaps().multiview;
 
     this.bindFramebuffer(multiviewTexture, undefined, undefined, undefined, true);
     gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, multiviewTexture._framebuffer);
     if (multiviewTexture._colorTextureArray && multiviewTexture._depthStencilTextureArray) {
-        ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, multiviewTexture._colorTextureArray, 0, 0, 2);
-        ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, multiviewTexture._depthStencilTextureArray, 0, 0, 2);
+        if (this.getCaps().oculusMultiview) {
+            ext.framebufferTextureMultisampleMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, multiviewTexture._colorTextureArray, 0, multiviewTexture.samples, 0, 2);
+            ext.framebufferTextureMultisampleMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, multiviewTexture._depthStencilTextureArray, 0, multiviewTexture.samples, 0, 2);
+        } else {
+            ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.COLOR_ATTACHMENT0, multiviewTexture._colorTextureArray, 0, 0, 2);
+            ext.framebufferTextureMultiviewOVR(gl.DRAW_FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, multiviewTexture._depthStencilTextureArray, 0, 0, 2);
+        }
     } else {
         throw "Invalid multiview frame buffer";
     }
@@ -147,7 +152,7 @@ Scene.prototype._renderMultiviewToSingleView = function(camera: Camera) {
 
     // Render to a multiview texture
     camera._resizeOrCreateMultiviewTexture(
-        (camera._rigPostProcess && camera._rigPostProcess && camera._rigPostProcess.width > 0) ? camera._rigPostProcess.width / 2 : this.getEngine().getRenderWidth(true) / 2,
+        (camera._rigPostProcess && camera._rigPostProcess && camera._rigPostProcess.width > 0) ? camera._rigPostProcess.width : this.getEngine().getRenderWidth(true),
         (camera._rigPostProcess && camera._rigPostProcess && camera._rigPostProcess.height > 0) ? camera._rigPostProcess.height : this.getEngine().getRenderHeight(true)
     );
     if (!this._multiviewSceneUbo) {

+ 5 - 2
src/Engines/Extensions/engine.webVR.ts

@@ -5,6 +5,7 @@ import { Size } from '../../Maths/math.size';
 import { Observable } from '../../Misc/observable';
 import { Tools } from '../../Misc/tools';
 import { DomManagement } from '../../Misc/domManagement';
+import { WebVROptions } from '../../Cameras/VR/webVRCamera';
 
 /**
  * Interface used to define additional presentation attributes
@@ -96,9 +97,10 @@ declare module "../../Engines/engine" {
         /**
          * Call this function to switch to webVR mode
          * Will do nothing if webVR is not supported or if there is no webVR device
+         * @param options the webvr options provided to the camera. mainly used for multiview
          * @see http://doc.babylonjs.com/how_to/webvr_camera
          */
-        enableVR(): void;
+        enableVR(options: WebVROptions): void;
 
         /** @hidden */
         _onVRFullScreenTriggered(): void;
@@ -194,7 +196,7 @@ Engine.prototype._getVRDisplaysAsync = function(): Promise<IDisplayChangedEventA
     });
 };
 
-Engine.prototype.enableVR = function() {
+Engine.prototype.enableVR = function(options: WebVROptions) {
     if (this._vrDisplay && !this._vrDisplay.isPresenting) {
         var onResolved = () => {
             this.onVRRequestPresentComplete.notifyObservers(true);
@@ -209,6 +211,7 @@ Engine.prototype.enableVR = function() {
         var presentationAttributes = {
             highRefreshRate: this.vrPresentationAttributes ? this.vrPresentationAttributes.highRefreshRate : false,
             foveationLevel: this.vrPresentationAttributes ? this.vrPresentationAttributes.foveationLevel : 1,
+            multiview: (this.getCaps().multiview || this.getCaps().oculusMultiview) && options.useMultiview
         };
 
         this._vrDisplay.requestPresent([{

+ 4 - 0
src/Engines/engineCapabilities.ts

@@ -10,6 +10,8 @@ export interface EngineCapabilities {
     maxCombinedTexturesImageUnits: number;
     /** Maximum texture size */
     maxTextureSize: number;
+    /** Maximum texture samples */
+    maxSamples?: number;
     /** Maximum cube texture size */
     maxCubemapTextureSize: number;
     /** Maximum render texture size */
@@ -74,6 +76,8 @@ export interface EngineCapabilities {
     canUseTimestampForTimerQuery: boolean;
     /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
     multiview?: any;
+    /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
+    oculusMultiview?: any;
     /** Function used to let the system compiles shaders in background */
     parallelShaderCompile?: {
         COMPLETION_STATUS_KHR: number;

+ 2 - 0
src/Engines/thinEngine.ts

@@ -705,6 +705,7 @@ export class ThinEngine {
             maxCombinedTexturesImageUnits: this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS),
             maxVertexTextureImageUnits: this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS),
             maxTextureSize: this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE),
+            maxSamples: this._gl.getParameter(this._gl.MAX_SAMPLES),
             maxCubemapTextureSize: this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE),
             maxRenderTextureSize: this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE),
             maxVertexAttribs: this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS),
@@ -740,6 +741,7 @@ export class ThinEngine {
             textureLOD: (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false,
             blendMinMax: false,
             multiview: this._gl.getExtension('OVR_multiview2'),
+            oculusMultiview: this._gl.getExtension('OCULUS_multiview'),
             depthTextureExtension: false
         };
 

+ 42 - 41
src/Materials/Node/Blocks/index.ts

@@ -1,41 +1,42 @@
-export * from "./Vertex/index";
-export * from "./Fragment/index";
-export * from "./Dual/index";
-export * from "./Input/index";
-export * from "./multiplyBlock";
-export * from "./addBlock";
-export * from "./scaleBlock";
-export * from "./clampBlock";
-export * from "./crossBlock";
-export * from "./dotBlock";
-export * from "./transformBlock";
-export * from "./remapBlock";
-export * from "./normalizeBlock";
-export * from "./trigonometryBlock";
-export * from "./colorMergerBlock";
-export * from "./vectorMergerBlock";
-export * from "./colorSplitterBlock";
-export * from "./vectorSplitterBlock";
-export * from "./lerpBlock";
-export * from "./divideBlock";
-export * from "./subtractBlock";
-export * from "./stepBlock";
-export * from "./oneMinusBlock";
-export * from "./viewDirectionBlock";
-export * from "./fresnelBlock";
-export * from "./maxBlock";
-export * from "./minBlock";
-export * from "./distanceBlock";
-export * from "./lengthBlock";
-export * from "./negateBlock";
-export * from "./powBlock";
-export * from "./randomNumberBlock";
-export * from "./arcTan2Block";
-export * from "./smoothStepBlock";
-export * from "./reciprocalBlock";
-export * from "./replaceColorBlock";
-export * from "./posterizeBlock";
-export * from "./waveBlock";
-export * from "./gradientBlock";
-export * from "./nLerpBlock";
-export * from "./worleyNoise3DBlock";
+export * from "./Vertex/index";
+export * from "./Fragment/index";
+export * from "./Dual/index";
+export * from "./Input/index";
+export * from "./multiplyBlock";
+export * from "./addBlock";
+export * from "./scaleBlock";
+export * from "./clampBlock";
+export * from "./crossBlock";
+export * from "./dotBlock";
+export * from "./transformBlock";
+export * from "./remapBlock";
+export * from "./normalizeBlock";
+export * from "./trigonometryBlock";
+export * from "./colorMergerBlock";
+export * from "./vectorMergerBlock";
+export * from "./colorSplitterBlock";
+export * from "./vectorSplitterBlock";
+export * from "./lerpBlock";
+export * from "./divideBlock";
+export * from "./subtractBlock";
+export * from "./stepBlock";
+export * from "./oneMinusBlock";
+export * from "./viewDirectionBlock";
+export * from "./fresnelBlock";
+export * from "./maxBlock";
+export * from "./minBlock";
+export * from "./distanceBlock";
+export * from "./lengthBlock";
+export * from "./negateBlock";
+export * from "./powBlock";
+export * from "./randomNumberBlock";
+export * from "./arcTan2Block";
+export * from "./smoothStepBlock";
+export * from "./reciprocalBlock";
+export * from "./replaceColorBlock";
+export * from "./posterizeBlock";
+export * from "./waveBlock";
+export * from "./gradientBlock";
+export * from "./nLerpBlock";
+export * from "./worleyNoise3DBlock";
+export * from "./simplexPerlin3DBlock";

+ 131 - 0
src/Materials/Node/Blocks/simplexPerlin3DBlock.ts

@@ -0,0 +1,131 @@
+import { NodeMaterialBlock } from '../nodeMaterialBlock';
+import { NodeMaterialBlockConnectionPointTypes } from '../Enums/nodeMaterialBlockConnectionPointTypes';
+import { NodeMaterialBuildState } from '../nodeMaterialBuildState';
+import { NodeMaterialConnectionPoint } from '../nodeMaterialBlockConnectionPoint';
+import { NodeMaterialBlockTargets } from '../Enums/nodeMaterialBlockTargets';
+import { _TypeStore } from '../../../Misc/typeStore';
+/**
+ * block used to Generate a Simplex Perlin 3d Noise Pattern
+ */
+//
+//  Wombat
+//  An efficient texture-free GLSL procedural noise library
+//  Source: https://github.com/BrianSharpe/Wombat
+//  Derived from: https://github.com/BrianSharpe/GPU-Noise-Lib
+//
+//  I'm not one for copyrights.  Use the code however you wish.
+//  All I ask is that credit be given back to the blog or myself when appropriate.
+//  And also to let me know if you come up with any changes, improvements, thoughts or interesting uses for this stuff. :)
+//  Thanks!
+//
+//  Brian Sharpe
+//  brisharpe CIRCLE_A yahoo DOT com
+//  http://briansharpe.wordpress.com
+//  https://github.com/BrianSharpe
+//
+//
+//  This is a modified version of Stefan Gustavson's and Ian McEwan's work at http://github.com/ashima/webgl-noise
+//  Modifications are...
+//  - faster random number generation
+//  - analytical final normalization
+//  - space scaled can have an approx feature size of 1.0
+//  - filter kernel changed to fix discontinuities at tetrahedron boundaries
+//
+//  Converted to BJS by Pryme8
+//
+//  Simplex Perlin Noise 3D
+//  Return value range of -1.0->1.0
+//
+export class SimplexPerlin3DBlock extends NodeMaterialBlock {
+    /**
+     * Creates a new SimplexPerlin3DBlock
+     * @param name defines the block name
+     */
+    public constructor(name: string) {
+        super(name, NodeMaterialBlockTargets.Neutral);
+        this.registerInput("position", NodeMaterialBlockConnectionPointTypes.Vector3);
+        this.registerOutput("output", NodeMaterialBlockConnectionPointTypes.Float);
+    }
+
+    /**
+     * Gets the current class name
+     * @returns the class name
+     */
+    public getClassName() {
+        return "SimplexPerlin3DBlock";
+    }
+
+    /**
+     * Gets the position operand input component
+     */
+    public get position(): NodeMaterialConnectionPoint {
+        return this._inputs[0];
+    }
+
+    /**
+     * Gets the output component
+     */
+    public get output(): NodeMaterialConnectionPoint {
+        return this._outputs[0];
+    }
+
+    protected _buildBlock(state: NodeMaterialBuildState) {
+        super._buildBlock(state);
+
+        if (!this.position.isConnected) {
+            return;
+        }
+
+        if (!this._outputs[0].hasEndpoints) {
+            return;
+        }
+
+        let functionString = `const float SKEWFACTOR = 1.0/3.0;\r\n`;
+        functionString += `const float UNSKEWFACTOR = 1.0/6.0;\r\n`;
+        functionString += `const float SIMPLEX_CORNER_POS = 0.5;\r\n`;
+        functionString += `const float SIMPLEX_TETRAHADRON_HEIGHT = 0.70710678118654752440084436210485;\r\n`;
+        functionString += `float SimplexPerlin3D( vec3 P ){\r\n`;
+        functionString += `    P *= SIMPLEX_TETRAHADRON_HEIGHT;\r\n`;
+        functionString += `    vec3 Pi = floor( P + dot( P, vec3( SKEWFACTOR) ) );`;
+        functionString += `    vec3 x0 = P - Pi + dot(Pi, vec3( UNSKEWFACTOR ) );\r\n`;
+        functionString += `    vec3 g = step(x0.yzx, x0.xyz);\r\n`;
+        functionString += `    vec3 l = 1.0 - g;\r\n`;
+        functionString += `    vec3 Pi_1 = min( g.xyz, l.zxy );\r\n`;
+        functionString += `    vec3 Pi_2 = max( g.xyz, l.zxy );\r\n`;
+        functionString += `    vec3 x1 = x0 - Pi_1 + UNSKEWFACTOR;\r\n`;
+        functionString += `    vec3 x2 = x0 - Pi_2 + SKEWFACTOR;\r\n`;
+        functionString += `    vec3 x3 = x0 - SIMPLEX_CORNER_POS;\r\n`;
+        functionString += `    vec4 v1234_x = vec4( x0.x, x1.x, x2.x, x3.x );\r\n`;
+        functionString += `    vec4 v1234_y = vec4( x0.y, x1.y, x2.y, x3.y );\r\n`;
+        functionString += `    vec4 v1234_z = vec4( x0.z, x1.z, x2.z, x3.z );\r\n`;
+        functionString += `    Pi.xyz = Pi.xyz - floor(Pi.xyz * ( 1.0 / 69.0 )) * 69.0;\r\n`;
+        functionString += `    vec3 Pi_inc1 = step( Pi, vec3( 69.0 - 1.5 ) ) * ( Pi + 1.0 );\r\n`;
+        functionString += `    vec4 Pt = vec4( Pi.xy, Pi_inc1.xy ) + vec2( 50.0, 161.0 ).xyxy;\r\n`;
+        functionString += `    Pt *= Pt;\r\n`;
+        functionString += `    vec4 V1xy_V2xy = mix( Pt.xyxy, Pt.zwzw, vec4( Pi_1.xy, Pi_2.xy ) );\r\n`;
+        functionString += `    Pt = vec4( Pt.x, V1xy_V2xy.xz, Pt.z ) * vec4( Pt.y, V1xy_V2xy.yw, Pt.w );\r\n`;
+        functionString += `    const vec3 SOMELARGEFLOATS = vec3( 635.298681, 682.357502, 668.926525 );\r\n`;
+        functionString += `    const vec3 ZINC = vec3( 48.500388, 65.294118, 63.934599 );\r\n`;
+        functionString += `    vec3 lowz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi.zzz * ZINC.xyz ) );\r\n`;
+        functionString += `    vec3 highz_mods = vec3( 1.0 / ( SOMELARGEFLOATS.xyz + Pi_inc1.zzz * ZINC.xyz ) );\r\n`;
+        functionString += `    Pi_1 = ( Pi_1.z < 0.5 ) ? lowz_mods : highz_mods;\r\n`;
+        functionString += `    Pi_2 = ( Pi_2.z < 0.5 ) ? lowz_mods : highz_mods;\r\n`;
+        functionString += `    vec4 hash_0 = fract( Pt * vec4( lowz_mods.x, Pi_1.x, Pi_2.x, highz_mods.x ) ) - 0.49999;\r\n`;
+        functionString += `    vec4 hash_1 = fract( Pt * vec4( lowz_mods.y, Pi_1.y, Pi_2.y, highz_mods.y ) ) - 0.49999;\r\n`;
+        functionString += `    vec4 hash_2 = fract( Pt * vec4( lowz_mods.z, Pi_1.z, Pi_2.z, highz_mods.z ) ) - 0.49999;\r\n`;
+        functionString += `    vec4 grad_results = inversesqrt( hash_0 * hash_0 + hash_1 * hash_1 + hash_2 * hash_2 ) * ( hash_0 * v1234_x + hash_1 * v1234_y + hash_2 * v1234_z );\r\n`;
+        functionString += `    const float FINAL_NORMALIZATION = 37.837227241611314102871574478976;\r\n`;
+        functionString += `    vec4 kernel_weights = v1234_x * v1234_x + v1234_y * v1234_y + v1234_z * v1234_z;\r\n`;
+        functionString += `    kernel_weights = max(0.5 - kernel_weights, 0.0);\r\n`;
+        functionString += `    kernel_weights = kernel_weights*kernel_weights*kernel_weights;\r\n`;
+        functionString += `    return dot( kernel_weights, grad_results ) * FINAL_NORMALIZATION;\r\n`;
+        functionString += `}\r\n`;
+
+        state._emitFunction('SimplexPerlin3D', functionString, 'SimplexPerlin3D');
+        state.compilationString += this._declareOutput(this._outputs[0], state) + ` = SimplexPerlin3D(${this.position.associatedVariableName});\r\n`;
+
+        return this;
+    }
+}
+
+_TypeStore.RegisteredTypes["BABYLON.SimplexPerlin3DBlock"] = SimplexPerlin3DBlock;

+ 1 - 0
src/Materials/Textures/MultiviewRenderTarget.ts

@@ -17,6 +17,7 @@ export class MultiviewRenderTarget extends RenderTargetTexture {
         var internalTexture = scene.getEngine().createMultiviewRenderTargetTexture(this.getRenderWidth(), this.getRenderHeight());
         internalTexture.isMultiview = true;
         this._texture = internalTexture;
+        this.samples = this._engine.getCaps().maxSamples || this.samples;
     }
 
     /**