|
@@ -20,7 +20,9 @@ export class FragmentOutputBlock extends NodeMaterialBlock {
|
|
|
public constructor(name: string) {
|
|
|
super(name, NodeMaterialBlockTargets.Fragment, true);
|
|
|
|
|
|
- this.registerInput("color", NodeMaterialBlockConnectionPointTypes.Vector2OrVector3OrColor3OrVector4OrColor4);
|
|
|
+ this.registerInput("rgba", NodeMaterialBlockConnectionPointTypes.Color4, true);
|
|
|
+ this.registerInput("rgb", NodeMaterialBlockConnectionPointTypes.Color3, true);
|
|
|
+ this.registerInput("a", NodeMaterialBlockConnectionPointTypes.Float, true);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -32,24 +34,44 @@ export class FragmentOutputBlock extends NodeMaterialBlock {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Gets the color input component
|
|
|
+ * Gets the rgba input component
|
|
|
*/
|
|
|
- public get color(): NodeMaterialConnectionPoint {
|
|
|
+ public get rgba(): NodeMaterialConnectionPoint {
|
|
|
return this._inputs[0];
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Gets the rgb input component
|
|
|
+ */
|
|
|
+ public get rgb(): NodeMaterialConnectionPoint {
|
|
|
+ return this._inputs[1];
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Gets the a input component
|
|
|
+ */
|
|
|
+ public get a(): NodeMaterialConnectionPoint {
|
|
|
+ return this._inputs[2];
|
|
|
+ }
|
|
|
+
|
|
|
protected _buildBlock(state: NodeMaterialBuildState) {
|
|
|
super._buildBlock(state);
|
|
|
|
|
|
- let input = this.color;
|
|
|
+ let rgba = this.rgba;
|
|
|
+ let rgb = this.rgb;
|
|
|
+ let a = this.a;
|
|
|
state.sharedData.hints.needAlphaBlending = this.alphaBlendingEnabled;
|
|
|
|
|
|
- if (input.connectedPoint && input.connectedPoint!.type === NodeMaterialBlockConnectionPointTypes.Vector2) {
|
|
|
- state.compilationString += `gl_FragColor = vec4(${input.associatedVariableName}.r, ${input.associatedVariableName}.g, 0., 1.0);\r\n`;
|
|
|
- } else if (input.connectedPoint && (input.connectedPoint!.type === NodeMaterialBlockConnectionPointTypes.Color3 || input.connectedPoint!.type === NodeMaterialBlockConnectionPointTypes.Vector3)) {
|
|
|
- state.compilationString += `gl_FragColor = vec4(${input.associatedVariableName}, 1.0);\r\n`;
|
|
|
+ if (rgba.connectedPoint) {
|
|
|
+ state.compilationString += `gl_FragColor = ${rgba.associatedVariableName};\r\n`;
|
|
|
+ } else if (rgb.connectedPoint) {
|
|
|
+ if (a.connectedPoint) {
|
|
|
+ state.compilationString += `gl_FragColor = vec4(${rgb.associatedVariableName}, ${a.associatedVariableName});\r\n`;
|
|
|
+ } else {
|
|
|
+ state.compilationString += `gl_FragColor = vec4(${rgb.associatedVariableName}, 1.0);\r\n`;
|
|
|
+ }
|
|
|
} else {
|
|
|
- state.compilationString += `gl_FragColor = ${input.associatedVariableName};\r\n`;
|
|
|
+ state.sharedData.checks.notConnectedNonOptionalInputs.push(rgba);
|
|
|
}
|
|
|
|
|
|
return this;
|