David Catuhe %!s(int64=6) %!d(string=hai) anos
pai
achega
f5a3fd74f4

+ 10 - 0
Playground/babylon.d.txt

@@ -51445,6 +51445,8 @@ declare module BABYLON {
         SAMPLER3DGREENDEPTH: boolean;
         SAMPLER3DBGRMAP: boolean;
         IMAGEPROCESSINGPOSTPROCESS: boolean;
+        /** MISC. */
+        BUMPDIRECTUV: number;
         constructor();
         setValue(name: string, value: boolean): void;
     }
@@ -52677,6 +52679,11 @@ declare module BABYLON {
      * Block used to pertub normals based on a normal map
      */
     export class PerturbNormalBlock extends NodeMaterialBlock {
+        private _tangentSpaceParameterName;
+        /** Gets or sets a boolean indicating that normal should be inverted on X axis */
+        invertX: boolean;
+        /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
+        invertY: boolean;
         /**
          * Create a new PerturbNormalBlock
          * @param name defines the block name
@@ -52712,8 +52719,11 @@ declare module BABYLON {
          */
         readonly output: NodeMaterialConnectionPoint;
         prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
+        bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
         autoConfigure(material: NodeMaterial): void;
         protected _buildBlock(state: NodeMaterialBuildState): this;
+        protected _dumpPropertiesCode(): string;
+        serialize(): any;
private _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
     }
 }
 declare module BABYLON {

+ 11 - 0
dist/preview release/babylon.d.ts

@@ -52237,6 +52237,8 @@ declare module BABYLON {
         SAMPLER3DGREENDEPTH: boolean;
         SAMPLER3DBGRMAP: boolean;
         IMAGEPROCESSINGPOSTPROCESS: boolean;
+        /** MISC. */
+        BUMPDIRECTUV: number;
         constructor();
         setValue(name: string, value: boolean): void;
     }
@@ -53507,6 +53509,11 @@ declare module BABYLON {
      * Block used to pertub normals based on a normal map
      */
     export class PerturbNormalBlock extends NodeMaterialBlock {
+        private _tangentSpaceParameterName;
+        /** Gets or sets a boolean indicating that normal should be inverted on X axis */
+        invertX: boolean;
+        /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
+        invertY: boolean;
         /**
          * Create a new PerturbNormalBlock
          * @param name defines the block name
@@ -53542,8 +53549,12 @@ declare module BABYLON {
          */
         readonly output: NodeMaterialConnectionPoint;
         prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
+        bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
         autoConfigure(material: NodeMaterial): void;
         protected _buildBlock(state: NodeMaterialBuildState): this;
+        protected _dumpPropertiesCode(): string;
+        serialize(): any;
+        _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
     }
 }
 declare module BABYLON {

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/babylon.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 118 - 89
dist/preview release/babylon.max.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/babylon.max.js.map


+ 25 - 0
dist/preview release/babylon.module.d.ts

@@ -54679,6 +54679,8 @@ declare module "babylonjs/Materials/Node/nodeMaterial" {
         SAMPLER3DGREENDEPTH: boolean;
         SAMPLER3DBGRMAP: boolean;
         IMAGEPROCESSINGPOSTPROCESS: boolean;
+        /** MISC. */
+        BUMPDIRECTUV: number;
         constructor();
         setValue(name: string, value: boolean): void;
     }
@@ -56041,10 +56043,18 @@ declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
     import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
     import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
     import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
+    import { Effect } from "babylonjs/Materials/effect";
+    import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Scene } from "babylonjs/scene";
     /**
      * Block used to pertub normals based on a normal map
      */
     export class PerturbNormalBlock extends NodeMaterialBlock {
+        private _tangentSpaceParameterName;
+        /** Gets or sets a boolean indicating that normal should be inverted on X axis */
+        invertX: boolean;
+        /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
+        invertY: boolean;
         /**
          * Create a new PerturbNormalBlock
          * @param name defines the block name
@@ -56080,8 +56090,12 @@ declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
          */
         readonly output: NodeMaterialConnectionPoint;
         prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
+        bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
         autoConfigure(material: NodeMaterial): void;
         protected _buildBlock(state: NodeMaterialBuildState): this;
+        protected _dumpPropertiesCode(): string;
+        serialize(): any;
+        _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
     }
 }
 declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
@@ -117796,6 +117810,8 @@ declare module BABYLON {
         SAMPLER3DGREENDEPTH: boolean;
         SAMPLER3DBGRMAP: boolean;
         IMAGEPROCESSINGPOSTPROCESS: boolean;
+        /** MISC. */
+        BUMPDIRECTUV: number;
         constructor();
         setValue(name: string, value: boolean): void;
     }
@@ -119066,6 +119082,11 @@ declare module BABYLON {
      * Block used to pertub normals based on a normal map
      */
     export class PerturbNormalBlock extends NodeMaterialBlock {
+        private _tangentSpaceParameterName;
+        /** Gets or sets a boolean indicating that normal should be inverted on X axis */
+        invertX: boolean;
+        /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
+        invertY: boolean;
         /**
          * Create a new PerturbNormalBlock
          * @param name defines the block name
@@ -119101,8 +119122,12 @@ declare module BABYLON {
          */
         readonly output: NodeMaterialConnectionPoint;
         prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
+        bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
         autoConfigure(material: NodeMaterial): void;
         protected _buildBlock(state: NodeMaterialBuildState): this;
+        protected _dumpPropertiesCode(): string;
+        serialize(): any;
+        _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
     }
 }
 declare module BABYLON {

+ 11 - 0
dist/preview release/documentation.d.ts

@@ -52237,6 +52237,8 @@ declare module BABYLON {
         SAMPLER3DGREENDEPTH: boolean;
         SAMPLER3DBGRMAP: boolean;
         IMAGEPROCESSINGPOSTPROCESS: boolean;
+        /** MISC. */
+        BUMPDIRECTUV: number;
         constructor();
         setValue(name: string, value: boolean): void;
     }
@@ -53507,6 +53509,11 @@ declare module BABYLON {
      * Block used to pertub normals based on a normal map
      */
     export class PerturbNormalBlock extends NodeMaterialBlock {
+        private _tangentSpaceParameterName;
+        /** Gets or sets a boolean indicating that normal should be inverted on X axis */
+        invertX: boolean;
+        /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
+        invertY: boolean;
         /**
          * Create a new PerturbNormalBlock
          * @param name defines the block name
@@ -53542,8 +53549,12 @@ declare module BABYLON {
          */
         readonly output: NodeMaterialConnectionPoint;
         prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
+        bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
         autoConfigure(material: NodeMaterial): void;
         protected _buildBlock(state: NodeMaterialBuildState): this;
+        protected _dumpPropertiesCode(): string;
+        serialize(): any;
+        _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
     }
 }
 declare module BABYLON {

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/nodeEditor/babylon.nodeEditor.js


+ 5 - 1
dist/preview release/nodeEditor/babylon.nodeEditor.max.js

@@ -69050,7 +69050,11 @@ var GenericNodeModel = /** @class */ (function (_super) {
                                 transformBlock.complementW = 1;
                             }
                             globalState.onRebuildRequiredObservable.notifyObservers();
-                        }, isSelected: function () { return _this.block.complementW === 0; } }))));
+                        }, isSelected: function () { return _this.block.complementW === 0; } })),
+            this.block.getClassName() === "PerturbNormalBlock" &&
+                react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_sharedComponents_lineContainerComponent__WEBPACK_IMPORTED_MODULE_4__["LineContainerComponent"], { title: "PROPERTIES" },
+                    react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_sharedComponents_checkBoxLineComponent__WEBPACK_IMPORTED_MODULE_6__["CheckBoxLineComponent"], { label: "Invert X axis", target: this.block, propertyName: "invertX", onValueChanged: function () { return globalState.onRebuildRequiredObservable.notifyObservers(); } }),
+                    react__WEBPACK_IMPORTED_MODULE_1__["createElement"](_sharedComponents_checkBoxLineComponent__WEBPACK_IMPORTED_MODULE_6__["CheckBoxLineComponent"], { label: "Invert Y axis", target: this.block, propertyName: "invertY", onValueChanged: function () { return globalState.onRebuildRequiredObservable.notifyObservers(); } }))));
     };
     return GenericNodeModel;
 }(_defaultNodeModel__WEBPACK_IMPORTED_MODULE_2__["DefaultNodeModel"]));

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/nodeEditor/babylon.nodeEditor.max.js.map


+ 1 - 1
dist/preview release/packagesSizeBaseLine.json

@@ -1 +1 @@
-{"engineOnly":167802,"sceneOnly":508293,"minGridMaterial":638479,"minStandardMaterial":767609}
+{"engineOnly":167802,"sceneOnly":508293,"minGridMaterial":638443,"minStandardMaterial":767573}

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

@@ -54679,6 +54679,8 @@ declare module "babylonjs/Materials/Node/nodeMaterial" {
         SAMPLER3DGREENDEPTH: boolean;
         SAMPLER3DBGRMAP: boolean;
         IMAGEPROCESSINGPOSTPROCESS: boolean;
+        /** MISC. */
+        BUMPDIRECTUV: number;
         constructor();
         setValue(name: string, value: boolean): void;
     }
@@ -56041,10 +56043,18 @@ declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
     import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
     import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
     import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
+    import { Effect } from "babylonjs/Materials/effect";
+    import { Mesh } from "babylonjs/Meshes/mesh";
+    import { Scene } from "babylonjs/scene";
     /**
      * Block used to pertub normals based on a normal map
      */
     export class PerturbNormalBlock extends NodeMaterialBlock {
+        private _tangentSpaceParameterName;
+        /** Gets or sets a boolean indicating that normal should be inverted on X axis */
+        invertX: boolean;
+        /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
+        invertY: boolean;
         /**
          * Create a new PerturbNormalBlock
          * @param name defines the block name
@@ -56080,8 +56090,12 @@ declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
          */
         readonly output: NodeMaterialConnectionPoint;
         prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
+        bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
         autoConfigure(material: NodeMaterial): void;
         protected _buildBlock(state: NodeMaterialBuildState): this;
+        protected _dumpPropertiesCode(): string;
+        serialize(): any;
+        _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
     }
 }
 declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
@@ -117796,6 +117810,8 @@ declare module BABYLON {
         SAMPLER3DGREENDEPTH: boolean;
         SAMPLER3DBGRMAP: boolean;
         IMAGEPROCESSINGPOSTPROCESS: boolean;
+        /** MISC. */
+        BUMPDIRECTUV: number;
         constructor();
         setValue(name: string, value: boolean): void;
     }
@@ -119066,6 +119082,11 @@ declare module BABYLON {
      * Block used to pertub normals based on a normal map
      */
     export class PerturbNormalBlock extends NodeMaterialBlock {
+        private _tangentSpaceParameterName;
+        /** Gets or sets a boolean indicating that normal should be inverted on X axis */
+        invertX: boolean;
+        /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
+        invertY: boolean;
         /**
          * Create a new PerturbNormalBlock
          * @param name defines the block name
@@ -119101,8 +119122,12 @@ declare module BABYLON {
          */
         readonly output: NodeMaterialConnectionPoint;
         prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
+        bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
         autoConfigure(material: NodeMaterial): void;
         protected _buildBlock(state: NodeMaterialBuildState): this;
+        protected _dumpPropertiesCode(): string;
+        serialize(): any;
+        _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
     }
 }
 declare module BABYLON {

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 8 - 8
dist/preview release/viewer/babylon.viewer.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 1 - 1
dist/preview release/viewer/babylon.viewer.max.js


+ 1 - 1
nodeEditor/public/index.js

@@ -105,7 +105,7 @@ var showEditor = function() {
 // Let's start
 if (BABYLON.Engine.isSupported()) {
     var canvas = document.createElement("canvas");
-    var engine = new BABYLON.Engine(canvas, false);
+    var engine = new BABYLON.Engine(canvas, false, {disableWebGL2Support: true});
     var scene = new BABYLON.Scene(engine);
 
     nodeMaterial = new BABYLON.NodeMaterial("node");

+ 8 - 1
nodeEditor/src/components/diagram/generic/genericNodeModel.tsx

@@ -64,7 +64,14 @@ export class GenericNodeModel extends DefaultNodeModel {
                         globalState.onRebuildRequiredObservable.notifyObservers();
                     }} isSelected={() => (this.block as TransformBlock).complementW === 0} />
                 </LineContainerComponent>
-            }        
+            }                    
+            {
+                this.block!.getClassName() === "PerturbNormalBlock" &&
+                <LineContainerComponent title="PROPERTIES">
+                    <CheckBoxLineComponent label="Invert X axis" target={this.block} propertyName="invertX" onValueChanged={() => globalState.onRebuildRequiredObservable.notifyObservers()} />
+                    <CheckBoxLineComponent label="Invert Y axis" target={this.block} propertyName="invertY" onValueChanged={() => globalState.onRebuildRequiredObservable.notifyObservers()}/>                    
+                </LineContainerComponent>
+            }   
             </div>
         );
     }

+ 44 - 1
src/Materials/Node/Blocks/Fragment/perturbNormalBlock.ts

@@ -7,11 +7,21 @@ import { _TypeStore } from '../../../../Misc/typeStore';
 import { NodeMaterial, NodeMaterialDefines } from '../../nodeMaterial';
 import { AbstractMesh } from '../../../../Meshes/abstractMesh';
 import { InputBlock } from '../Input/inputBlock';
+import { Effect } from '../../../effect';
+import { Mesh } from '../../../../Meshes/mesh';
+import { Scene } from '../../../../scene';
 
 /**
  * Block used to pertub normals based on a normal map
  */
 export class PerturbNormalBlock extends NodeMaterialBlock {
+    private _tangentSpaceParameterName = "";
+
+    /** Gets or sets a boolean indicating that normal should be inverted on X axis */
+    public invertX = false;
+    /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
+    public invertY = false;
+
     /**
      * Create a new PerturbNormalBlock
      * @param name defines the block name
@@ -84,6 +94,10 @@ export class PerturbNormalBlock extends NodeMaterialBlock {
         defines.setValue("BUMP", true);
     }
 
+    public bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh) {
+        effect.setFloat2(this._tangentSpaceParameterName, this.invertX ? -1 : 1, this.invertY ? -1 : 1);
+    }
+
     public autoConfigure(material: NodeMaterial) {
         if (!this.uv.isConnected) {
             let uvInput = material.getInputBlockByPredicate((b) => b.isAttribute && b.name === "uv");
@@ -111,12 +125,17 @@ export class PerturbNormalBlock extends NodeMaterialBlock {
         let worldNormal = this.worldNormal;
 
         state.sharedData.blocksWithDefines.push(this);
+        state.sharedData.bindableBlocks.push(this);
+
+        this._tangentSpaceParameterName = state._getFreeDefineName("tangentSpaceParameter");
+
+        state._emitUniformFromString(this._tangentSpaceParameterName, "vec2");
 
         state._emitExtension("bump", "#extension GL_OES_standard_derivatives : enable");
         state._emitFunctionFromInclude("bumpFragmentFunctions", comments, {
             replaceStrings: [
                 { search: /vBumpInfos.y/g, replace: `1.0 / ${this.strength.associatedVariableName}`},
-                { search: /vTangentSpaceParams/g, replace: "vec2(1.0, 1.0)"},
+                { search: /vTangentSpaceParams/g, replace: this._tangentSpaceParameterName},
                 { search: /vPositionW/g, replace: worldPosition.associatedVariableName + ".xyz"}
             ]
         });
@@ -134,6 +153,30 @@ export class PerturbNormalBlock extends NodeMaterialBlock {
 
         return this;
     }
+
+    protected _dumpPropertiesCode() {
+        var codeString = `${this._codeVariableName}.invertX = ${this.invertX};\r\n`;
+
+        codeString += `${this._codeVariableName}.invertY = ${this.invertY};\r\n`;
+
+        return codeString;
+    }
+
+    public serialize(): any {
+        let serializationObject = super.serialize();
+
+        serializationObject.invertX = this.invertX;
+        serializationObject.invertY = this.invertY;
+
+        return serializationObject;
+    }
+
+    public _deserialize(serializationObject: any, scene: Scene, rootUrl: string) {
+        super._deserialize(serializationObject, scene, rootUrl);
+
+        this.invertX = serializationObject.invertX;
+        this.invertY = serializationObject.invertY;
+    }
 }
 
 _TypeStore.RegisteredTypes["BABYLON.PerturbNormalBlock"] = PerturbNormalBlock;

+ 3 - 0
src/Materials/Node/nodeMaterial.ts

@@ -71,6 +71,9 @@ export class NodeMaterialDefines extends MaterialDefines implements IImageProces
     public SAMPLER3DBGRMAP = false;
     public IMAGEPROCESSINGPOSTPROCESS = false;
 
+    /** MISC. */
+    public BUMPDIRECTUV = 0;
+
     constructor() {
         super();
         this.rebuild();

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

@@ -110,7 +110,7 @@ export class NodeMaterialBuildState {
 
         for (var extensionName in this.extensions) {
             let extension = this.extensions[extensionName];
-            this.compilationString = `${extension}\r\n${this.compilationString}`;
+            this.compilationString = `\r\n${extension}\r\n${this.compilationString}`;
         }
 
         this._builtCompilationString = this.compilationString;