diff --git a/nodeEditor/src/components/diagram/input/inputNodePropertyComponent.tsx b/nodeEditor/src/components/diagram/input/inputNodePropertyComponent.tsx index 299c80d9fdc..dca21013318 100644 --- a/nodeEditor/src/components/diagram/input/inputNodePropertyComponent.tsx +++ b/nodeEditor/src/components/diagram/input/inputNodePropertyComponent.tsx @@ -124,6 +124,7 @@ export class InputPropertyTabComponentProps extends React.Component { if (!value) { connection.isUniform = true; + this.setDefaultValue(); } else { connection.isAttribute = true; } diff --git a/nodeEditor/src/components/diagram/texture/texturePropertyTabComponent.tsx b/nodeEditor/src/components/diagram/texture/texturePropertyTabComponent.tsx index a05bbbede52..5da59f16891 100644 --- a/nodeEditor/src/components/diagram/texture/texturePropertyTabComponent.tsx +++ b/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 + this.replaceTexture(file)} accept=".jpg, .png, .tga, .dds, .env" /> diff --git a/nodeEditor/src/graphEditor.tsx b/nodeEditor/src/graphEditor.tsx index 7138a48680c..2d9cd515b19 100644 --- a/nodeEditor/src/graphEditor.tsx +++ b/nodeEditor/src/graphEditor.tsx @@ -200,12 +200,6 @@ export class GraphEditor extends React.Component { 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) diff --git a/src/Materials/Node/Blocks/Dual/fogBlock.ts b/src/Materials/Node/Blocks/Dual/fogBlock.ts index 51de986bcf2..a6c940000b6 100644 --- a/src/Materials/Node/Blocks/Dual/fogBlock.ts +++ b/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; diff --git a/src/Materials/Node/Blocks/Fragment/textureBlock.ts b/src/Materials/Node/Blocks/Fragment/textureBlock.ts index 09ad48c1bc9..49dae8748c2 100644 --- a/src/Materials/Node/Blocks/Fragment/textureBlock.ts +++ b/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) { diff --git a/src/Materials/Node/Blocks/Vertex/bonesBlock.ts b/src/Materials/Node/Blocks/Vertex/bonesBlock.ts index ab08ff9000c..c3683123c2e 100644 --- a/src/Materials/Node/Blocks/Vertex/bonesBlock.ts +++ b/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); } } diff --git a/src/Materials/Node/Blocks/Vertex/morphTargetsBlock.ts b/src/Materials/Node/Blocks/Vertex/morphTargetsBlock.ts index 5aeadb5e668..9229744b3af 100644 --- a/src/Materials/Node/Blocks/Vertex/morphTargetsBlock.ts +++ b/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"; } diff --git a/src/Materials/Node/nodeMaterialBlockConnectionPoint.ts b/src/Materials/Node/nodeMaterialBlockConnectionPoint.ts index 726ea9c6382..11f85181ce1 100644 --- a/src/Materials/Node/nodeMaterialBlockConnectionPoint.ts +++ b/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) @@ -116,6 +119,13 @@ export class NodeMaterialConnectionPoint { this._associatedVariableName = value; } + /** + * 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. @@ -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) { this._mode = NodeMaterialBlockConnectionPointMode.Uniform; + this.associatedVariableName = ""; this._wellKnownValue = value; } diff --git a/src/Materials/Node/nodeMaterialBuildState.ts b/src/Materials/Node/nodeMaterialBuildState.ts index 884a3d67fc0..6fbc19ee0ac 100644 --- a/src/Materials/Node/nodeMaterialBuildState.ts +++ b/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; }