Browse Source

disableColorWrite

David Catuhe 5 years ago
parent
commit
61c0d1efcb

+ 1 - 2
dist/preview release/what's new.md

@@ -10,12 +10,11 @@
 ### General
 
 - Refactored React refs from old string API to React.createRef() API ([belfortk](https://github.com/belfortk)
-
 - Scale on one axis for `BoundingBoxGizmo` ([cedricguillemet](https://github.com/cedricguillemet))
-
 - Simplified code contributions by fully automating the dev setup with gitpod ([nisarhassan12](https://github.com/nisarhassan12))
 - Add a `CascadedShadowMap.IsSupported` method and log an error instead of throwing an exception when CSM is not supported ([Popov72](https://github.com/Popov72))
 - Added initial code for DeviceInputSystem ([PolygonalSun](https://github.com/PolygonalSun))
+- Added support for `material.disableColorWrite` ([Deltakosh](https://github.com/deltakosh)
 
 ### Engine
 

+ 1 - 0
inspector/src/components/actionTabs/tabs/propertyGrids/materials/commonMaterialPropertyGridComponent.tsx

@@ -84,6 +84,7 @@ export class CommonMaterialPropertyGridComponent extends React.Component<ICommon
                     <CheckBoxLineComponent label="Backface culling" target={material} propertyName="backFaceCulling" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
                     <OptionsLineComponent label="Orientation" options={orientationOptions} target={material} propertyName="sideOrientation" onPropertyChangedObservable={this.props.onPropertyChangedObservable} onSelect={(value) => this.setState({ mode: value })} />
                     <CheckBoxLineComponent label="Disable lighting" target={material} propertyName="disableLighting" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
+                    <CheckBoxLineComponent label="Disable color write" target={material} propertyName="disableColorWrite" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
                     <CheckBoxLineComponent label="Disable depth write" target={material} propertyName="disableDepthWrite" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />
                     <OptionsLineComponent label="Depth function" options={depthfunctionOptions} target={material} propertyName="depthFunction" onPropertyChangedObservable={this.props.onPropertyChangedObservable} onSelect={(value) => this.setState({ depthFunction: value })} />
                     <CheckBoxLineComponent label="Need depth pre-pass" target={material} propertyName="needDepthPrePass" onPropertyChangedObservable={this.props.onPropertyChangedObservable} />

+ 22 - 0
src/Materials/material.ts

@@ -442,6 +442,12 @@ export class Material implements IAnimatable {
     public disableDepthWrite = false;
 
     /**
+     * Specifies if color writing should be disabled
+     */
+    @serialize()
+    public disableColorWrite = false;
+
+    /**
      * Specifies if depth writing should be forced
      */
     @serialize()
@@ -584,6 +590,11 @@ export class Material implements IAnimatable {
      * Specifies if the depth write state should be cached
      */
     private _cachedDepthWriteState: boolean = false;
+    
+    /**
+     * Specifies if the color write state should be cached
+     */
+    private _cachedColorWriteState: boolean = false;
 
     /**
      * Specifies if the depth function state should be cached
@@ -929,6 +940,12 @@ export class Material implements IAnimatable {
             engine.setDepthWrite(false);
         }
 
+        if (this.disableColorWrite) {
+            var engine = this._scene.getEngine();
+            this._cachedColorWriteState = engine.getColorWrite();
+            engine.setColorWrite(false);
+        }
+
         if (this.depthFunction !== 0) {
             var engine = this._scene.getEngine();
             this._cachedDepthFunctionState = engine.getDepthFunction() || 0;
@@ -953,6 +970,11 @@ export class Material implements IAnimatable {
             var engine = this._scene.getEngine();
             engine.setDepthWrite(this._cachedDepthWriteState);
         }
+
+        if (this.disableColorWrite) {
+            var engine = this._scene.getEngine();
+            engine.setColorWrite(this._cachedColorWriteState);
+        }
     }
 
     /**