Browse Source

Associated with #6012

David Catuhe 6 years ago
parent
commit
78998587f2

+ 3 - 1
inspector/src/components/actionTabs/tabs/propertyGrids/materials/nodeMaterialPropertyGridComponent.tsx

@@ -9,6 +9,7 @@ import { CommonMaterialPropertyGridComponent } from "./commonMaterialPropertyGri
 import { LockObject } from "../lockObject";
 import { GlobalState } from '../../../../globalState';
 import { ButtonLineComponent } from '../../../lines/buttonLineComponent';
+import { CheckBoxLineComponent } from '../../../lines/checkBoxLineComponent';
 
 interface INodeMaterialPropertyGridComponentProps {
     globalState: GlobalState;
@@ -33,7 +34,8 @@ export class NodeMaterialPropertyGridComponent extends React.Component<INodeMate
         return (
             <div className="pane">
                 <CommonMaterialPropertyGridComponent globalState={this.props.globalState} lockObject={this.props.lockObject} material={material} onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
-                <LineContainerComponent globalState={this.props.globalState} title="EDITOR">
+                <LineContainerComponent globalState={this.props.globalState} title="NODES">
+                    <CheckBoxLineComponent label="Ignore alpha" target={material} propertyName="ignoreAlpha" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
                     <ButtonLineComponent label="Edit" onClick={() => this.edit()} />
                 </LineContainerComponent>
             </div>

+ 1 - 1
nodeEditor/src/main.scss

@@ -51,7 +51,7 @@
     position: absolute;
     width: 100%;
     height: 100%;
-    background: rgba(0.1, 0.1, 0.1, 0.3);
+    background: rgba(0.1, 0.1, 0.1, 0.6);
     display: grid;
     font-family: "acumin-pro";
     top:0;

+ 1 - 5
src/Materials/Node/Blocks/Fragment/fragmentOutputBlock.ts

@@ -10,10 +10,6 @@ import { _TypeStore } from '../../../../Misc/typeStore';
  */
 export class FragmentOutputBlock extends NodeMaterialBlock {
     /**
-     * Gets or sets a boolean indicating if this block will output an alpha value
-     */
-    public alphaBlendingEnabled = false;
-    /**
      * Create a new FragmentOutputBlock
      * @param name defines the block name
      */
@@ -60,7 +56,7 @@ export class FragmentOutputBlock extends NodeMaterialBlock {
         let rgba = this.rgba;
         let rgb = this.rgb;
         let a = this.a;
-        state.sharedData.hints.needAlphaBlending = this.alphaBlendingEnabled;
+        state.sharedData.hints.needAlphaBlending = rgba.isConnected || a.isConnected;
 
         if (rgba.connectedPoint) {
             state.compilationString += `gl_FragColor = ${rgba.associatedVariableName};\r\n`;

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

@@ -127,6 +127,11 @@ export class NodeMaterial extends PushMaterial {
     }
 
     /**
+     * Gets or sets a boolean indicating that alpha value must be ignored (This will turn alpha blending off even if an alpha value is produced by the material)
+     */
+    public ignoreAlpha = false;
+
+    /**
     * Defines the maximum number of lights that can be used in the material
     */
     public maxSimultaneousLights = 4;
@@ -365,6 +370,9 @@ export class NodeMaterial extends PushMaterial {
      * @returns a boolean specifying if alpha blending is needed
      */
     public needAlphaBlending(): boolean {
+        if (this.ignoreAlpha) {
+            return false;
+        }
         return (this.alpha < 1.0) || this._sharedData.hints.needAlphaBlending;
     }