浏览代码

Associated with #6012

David Catuhe 6 年之前
父节点
当前提交
169bb32706

+ 1 - 0
nodeEditor/src/components/diagram/input/inputNodePropertyComponent.tsx

@@ -124,6 +124,7 @@ export class InputPropertyTabComponentProps extends React.Component<IInputProper
                     <CheckBoxLineComponent label="Is mesh attribute" onSelect={value => {
                         if (!value) {
                             connection.isUniform = true;
+                            this.setDefaultValue();
                         } else {
                             connection.isAttribute = true;
                         }

+ 2 - 0
nodeEditor/src/components/diagram/texture/texturePropertyTabComponent.tsx

@@ -9,6 +9,7 @@ import { TextureNodeModel } from './textureNodeModel';
 import { TextLineComponent } from '../../../sharedComponents/textLineComponent';
 import { LineContainerComponent } from '../../../sharedComponents/lineContainerComponent';
 import { TextInputLineComponent } from '../../../sharedComponents/textInputLineComponent';
+import { CheckBoxLineComponent } from '../../../sharedComponents/checkBoxLineComponent';
 
 interface ITexturePropertyTabComponentProps {
     globalState: GlobalState;
@@ -63,6 +64,7 @@ export class TexturePropertyTabComponent extends React.Component<ITexturePropert
                 </LineContainerComponent>
 
                 <LineContainerComponent title="PROPERTIES">
+                    <CheckBoxLineComponent label="Auto select UV" propertyName="autoSelectUV" target={this.props.node.block!} />
                     <FileButtonLineComponent label="Replace texture" onClick={(file) => this.replaceTexture(file)} accept=".jpg, .png, .tga, .dds, .env" />
                 </LineContainerComponent>
             </div>

+ 0 - 6
nodeEditor/src/graphEditor.tsx

@@ -200,12 +200,6 @@ export class GraphEditor extends React.Component<IGraphEditorProps> {
                     var link = DefaultPortModel.SortInputOutput(e.link.sourcePort as DefaultPortModel, e.link.targetPort as DefaultPortModel);
                     if (link) {
                         if (link.input.connection) {
-                            let targetBlock = link.input.connection.ownerBlock;
-
-                            if (targetBlock.isFinalMerger) {
-                                this.props.globalState.nodeMaterial!.removeOutputNode(targetBlock);
-                            }
-
                             if (link.output.connection) {
                                 // Disconnect standard nodes
                                 link.output.connection.disconnectFrom(link.input.connection)

+ 3 - 3
src/Materials/Node/Blocks/Dual/fogBlock.ts

@@ -79,13 +79,13 @@ export class FogBlock extends NodeMaterialBlock {
     }
 
     public autoConfigure() {
-        if (!this.view.connectedPoint) {
+        if (this.view.isUndefined) {
             this.view.setAsWellKnownValue(NodeMaterialWellKnownValues.View);
         }
-        if (!this.fogColor.connectedPoint) {
+        if (this.fogColor.isUndefined) {
             this.fogColor.setAsWellKnownValue(NodeMaterialWellKnownValues.Automatic);
         }
-        if (!this.fogParameters.connectedPoint) {
+        if (this.fogParameters.isUndefined) {
             this.fogParameters.setAsWellKnownValue(NodeMaterialWellKnownValues.Automatic);
         }
         this._outputs[0].isVarying = true;

+ 6 - 1
src/Materials/Node/Blocks/Fragment/textureBlock.ts

@@ -41,6 +41,7 @@ export class TextureBlock extends NodeMaterialBlock {
 
         // Setup
         this._inputs[0]._needToEmitVarying = false;
+        this._inputs[0]._forceUniformInVertexShaderOnly = true;
     }
 
     /**
@@ -87,10 +88,14 @@ export class TextureBlock extends NodeMaterialBlock {
     }
 
     public autoConfigure() {
-        if (!this.uv.connectedPoint) {
+        if (this.uv.isUndefined) {
             this.uv.setAsAttribute();
             this.uv.connectTo(this.transformedUV);
         }
+
+        if (this.transformedUV.isUndefined) {
+            this.uv.connectTo(this.transformedUV);
+        }
     }
 
     public initialize(state: NodeMaterialBuildState) {

+ 5 - 5
src/Materials/Node/Blocks/Vertex/bonesBlock.ts

@@ -85,19 +85,19 @@ export class BonesBlock extends NodeMaterialBlock {
     }
 
     public autoConfigure() {
-        if (!this.matricesIndices.connectedPoint) {
+        if (this.matricesIndices.isUndefined) {
             this.matricesIndices.setAsAttribute();
         }
-        if (!this.matricesWeights.connectedPoint) {
+        if (this.matricesWeights.isUndefined) {
             this.matricesWeights.setAsAttribute();
         }
-        if (!this.matricesIndicesExtra.connectedPoint) {
+        if (this.matricesIndicesExtra.isUndefined) {
             this.matricesIndicesExtra.setAsAttribute();
         }
-        if (!this.matricesWeightsExtra.connectedPoint) {
+        if (this.matricesWeightsExtra.isUndefined) {
             this.matricesWeightsExtra.setAsAttribute();
         }
-        if (!this.world.connectedPoint) {
+        if (this.world.isUndefined) {
             this.world.setAsWellKnownValue(NodeMaterialWellKnownValues.World);
         }
     }

+ 3 - 3
src/Materials/Node/Blocks/Vertex/morphTargetsBlock.ts

@@ -87,14 +87,14 @@ export class MorphTargetsBlock extends NodeMaterialBlock {
     }
 
     public autoConfigure() {
-        if (!this.position.connectedPoint) {
+        if (this.position.isUndefined) {
             this.position.setAsAttribute();
         }
-        if (!this.normal.connectedPoint) {
+        if (this.normal.isUndefined) {
             this.normal.setAsAttribute();
             this.normal.define = "NORMAL";
         }
-        if (!this.tangent.connectedPoint) {
+        if (this.tangent.isUndefined) {
             this.tangent.setAsAttribute();
             this.tangent.define = "TANGENT";
         }

+ 14 - 0
src/Materials/Node/nodeMaterialBlockConnectionPoint.ts

@@ -32,6 +32,9 @@ export class NodeMaterialConnectionPoint {
     /** @hidden */
     public _needToEmitVarying = true;
 
+    /** @hidden */
+    public _forceUniformInVertexShaderOnly = false;
+
     private _type = NodeMaterialBlockConnectionPointTypes.Float;
     /**
      * Gets or sets the connection point type (default is float)
@@ -117,6 +120,13 @@ export class NodeMaterialConnectionPoint {
     }
 
     /**
+     * Gets a boolean indicating that this connection point not defined yet
+     */
+    public get isUndefined(): boolean {
+        return this._mode === NodeMaterialBlockConnectionPointMode.Undefined;
+    }
+
+    /**
      * Gets or sets a boolean indicating that this connection point is coming from an uniform.
      * In this case the connection point name must be the name of the uniform to use.
      * Can only be set on inputs
@@ -127,6 +137,7 @@ export class NodeMaterialConnectionPoint {
 
     public set isUniform(value: boolean) {
         this._mode = value ? NodeMaterialBlockConnectionPointMode.Uniform : NodeMaterialBlockConnectionPointMode.Undefined;
+        this.associatedVariableName = "";
     }
 
     /**
@@ -140,6 +151,7 @@ export class NodeMaterialConnectionPoint {
 
     public set isAttribute(value: boolean) {
         this._mode = value ? NodeMaterialBlockConnectionPointMode.Attribute : NodeMaterialBlockConnectionPointMode.Undefined;
+        this.associatedVariableName = "";
     }
 
     /**
@@ -152,6 +164,7 @@ export class NodeMaterialConnectionPoint {
 
     public set isVarying(value: boolean) {
         this._mode = value ? NodeMaterialBlockConnectionPointMode.Varying : NodeMaterialBlockConnectionPointMode.Undefined;
+        this.associatedVariableName = "";
     }
 
     /** Get the other side of the connection (if any) */
@@ -239,6 +252,7 @@ export class NodeMaterialConnectionPoint {
 
     public set wellKnownValue(value: Nullable<NodeMaterialWellKnownValues>) {
         this._mode = NodeMaterialBlockConnectionPointMode.Uniform;
+        this.associatedVariableName = "";
         this._wellKnownValue = value;
     }
 

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

@@ -330,8 +330,14 @@ export class NodeMaterialBuildState {
         // Uniforms
         if (point.isUniform) {
             if (!point.associatedVariableName) {
-                point.associatedVariableName = this._getFreeVariableName(point.name);
+                point.associatedVariableName = this._getFreeVariableName("u_" + point.name);
             }
+
+            if (point._forceUniformInVertexShaderOnly && this._vertexState) { // Uniform for fragment need to be carried over by varyings
+                this._vertexState._emitUniformOrAttributes(point);
+                return;
+            }
+
             if (this.uniforms.indexOf(point.associatedVariableName) !== -1) {
                 return;
             }
@@ -371,8 +377,8 @@ export class NodeMaterialBuildState {
                 this._vertexState._emitUniformOrAttributes(point);
 
                 if (point._needToEmitVarying) {
-                    this._vertexState._emitVaryings(point, undefined, true, true, "v" + point.associatedVariableName);
-                    point.associatedVariableName = "v" + point.associatedVariableName;
+                    this._vertexState._emitVaryings(point, undefined, true, true, "v_" + point.associatedVariableName);
+                    point.associatedVariableName = "v_" + point.associatedVariableName;
                 }
                 return;
             }