Skip to content

Commit

Permalink
Associated with #6012
Browse files Browse the repository at this point in the history
  • Loading branch information
deltakosh committed Jun 10, 2019
1 parent 31bec11 commit 169bb32
Show file tree
Hide file tree
Showing 9 changed files with 43 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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>
Expand Down
6 changes: 0 additions & 6 deletions nodeEditor/src/graphEditor.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions src/Materials/Node/Blocks/Dual/fogBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
7 changes: 6 additions & 1 deletion src/Materials/Node/Blocks/Fragment/textureBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ export class TextureBlock extends NodeMaterialBlock {

// Setup
this._inputs[0]._needToEmitVarying = false;
this._inputs[0]._forceUniformInVertexShaderOnly = true;
}

/**
Expand Down Expand Up @@ -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) {
Expand Down
10 changes: 5 additions & 5 deletions src/Materials/Node/Blocks/Vertex/bonesBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/Materials/Node/Blocks/Vertex/morphTargetsBlock.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
}
Expand Down
14 changes: 14 additions & 0 deletions src/Materials/Node/nodeMaterialBlockConnectionPoint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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.
Expand All @@ -127,6 +137,7 @@ export class NodeMaterialConnectionPoint {

public set isUniform(value: boolean) {
this._mode = value ? NodeMaterialBlockConnectionPointMode.Uniform : NodeMaterialBlockConnectionPointMode.Undefined;
this.associatedVariableName = "";
}

/**
Expand All @@ -140,6 +151,7 @@ export class NodeMaterialConnectionPoint {

public set isAttribute(value: boolean) {
this._mode = value ? NodeMaterialBlockConnectionPointMode.Attribute : NodeMaterialBlockConnectionPointMode.Undefined;
this.associatedVariableName = "";
}

/**
Expand All @@ -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) */
Expand Down Expand Up @@ -239,6 +252,7 @@ export class NodeMaterialConnectionPoint {

public set wellKnownValue(value: Nullable<NodeMaterialWellKnownValues>) {
this._mode = NodeMaterialBlockConnectionPointMode.Uniform;
this.associatedVariableName = "";
this._wellKnownValue = value;
}

Expand Down
12 changes: 9 additions & 3 deletions src/Materials/Node/nodeMaterialBuildState.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 169bb32

Please sign in to comment.