Browse Source

Add the particle textureMask property

Popov72 5 năm trước cách đây
mục cha
commit
2a2bd257ac

+ 5 - 0
nodeEditor/src/blockTools.ts

@@ -480,6 +480,11 @@ export class BlockTools {
                 color.setAsAttribute("particle_color");
                 return color;
             }
+            case "ParticleTextureMaskBlock": {
+                let u = new InputBlock("TextureMask");
+                u.setAsAttribute("particle_texturemask");
+                return u;
+            }
         }
 
         return null;

+ 2 - 1
nodeEditor/src/components/nodeList/nodeListComponent.tsx

@@ -136,6 +136,7 @@ export class NodeListComponent extends React.Component<INodeListComponentProps,
         "ParticleUVBlock": "The particle uv texture coordinate",
         "ParticleTextureBlock": "The particle texture",
         "ParticleColorBlock": "The particle color",
+        "ParticleTextureMaskBlock": "The particle texture mask",
     };
 
     constructor(props: INodeListComponentProps) {
@@ -172,7 +173,7 @@ export class NodeListComponent extends React.Component<INodeListComponentProps,
             Mesh: ["InstancesBlock", "PositionBlock", "UVBlock", "ColorBlock", "NormalBlock", "PerturbNormalBlock", "NormalBlendBlock" , "TangentBlock", "MatrixIndicesBlock", "MatrixWeightsBlock", "WorldPositionBlock", "WorldNormalBlock", "WorldTangentBlock", "FrontFacingBlock"],
             Noises: ["RandomNumberBlock", "SimplexPerlin3DBlock", "WorleyNoise3DBlock"],
             Output_Nodes: ["VertexOutputBlock", "FragmentOutputBlock", "DiscardBlock"],
-            Particle: ["ParticleColorBlock", "ParticleTextureBlock", "ParticleUVBlock"],
+            Particle: ["ParticleColorBlock", "ParticleTextureBlock", "ParticleTextureMaskBlock", "ParticleUVBlock"],
             PBR: ["PBRMetallicRoughnessBlock", "AmbientOcclusionBlock", "AnisotropyBlock", "ClearCoatBlock", "ReflectionBlock", "ReflectivityBlock", "RefractionBlock", "SheenBlock", "SubSurfaceBlock"],
             PostProcess: ["Position2DBlock", "CurrentScreenBlock"],
             Range: ["ClampBlock", "RemapBlock", "NormalizeBlock"],

+ 2 - 0
nodeEditor/src/diagram/display/inputDisplayManager.ts

@@ -13,12 +13,14 @@ const inputNameToAttributeValue: { [name: string] : string } = {
     "position2d" : "position",
     "particle_uv" : "uv",
     "particle_color" : "color",
+    "particle_texturemask": "textureMask",
 };
 
 const inputNameToAttributeName: { [name: string] : string } = {
     "position2d" : "postprocess",
     "particle_uv" : "particle",
     "particle_color" : "particle",
+    "particle_texturemask": "particle",
 };
 
 export class InputDisplayManager implements IDisplayManager {

+ 18 - 3
src/Materials/Node/Blocks/Input/inputBlock.ts

@@ -19,11 +19,17 @@ const remapAttributeName: { [name: string]: string }  = {
     "position2d": "position",
     "particle_uv": "vUV",
     "particle_color": "vColor",
+    "particle_texturemask": "textureMask",
 };
 
-export const attributeInFragmentOnly: { [name: string]: boolean }  = {
+const attributeInFragmentOnly: { [name: string]: boolean }  = {
     "particle_uv": true,
     "particle_color": true,
+    "particle_texturemask": true,
+};
+
+const attributeAsUniform: { [name: string]: boolean }  = {
+    "particle_texturemask": true,
 };
 
 /**
@@ -120,6 +126,7 @@ export class InputBlock extends NodeMaterialBlock {
                         return this._type;
                     case "color":
                     case "particle_color":
+                    case "particle_texturemask":
                         this._type = NodeMaterialBlockConnectionPointTypes.Color4;
                         return this._type;
                 }
@@ -466,7 +473,11 @@ export class InputBlock extends NodeMaterialBlock {
 
             if (this.target === NodeMaterialBlockTargets.Vertex && state._vertexState) { // Attribute for fragment need to be carried over by varyings
                 if (attributeInFragmentOnly[this.name]) {
-                    state._emitVaryingFromString(this.associatedVariableName, state._getGLType(this.type), define);
+                    if (attributeAsUniform[this.name]) {
+                        state._emitUniformFromString(this.associatedVariableName, state._getGLType(this.type), define);
+                    } else {
+                        state._emitVaryingFromString(this.associatedVariableName, state._getGLType(this.type), define);
+                    }
                 } else {
                     this._emit(state._vertexState, define);
                 }
@@ -480,7 +491,11 @@ export class InputBlock extends NodeMaterialBlock {
             state.attributes.push(this.associatedVariableName);
 
             if (attributeInFragmentOnly[this.name]) {
-                state._emitVaryingFromString(this.associatedVariableName, state._getGLType(this.type), define);
+                if (attributeAsUniform[this.name]) {
+                    state._emitUniformFromString(this.associatedVariableName, state._getGLType(this.type), define);
+                } else {
+                    state._emitVaryingFromString(this.associatedVariableName, state._getGLType(this.type), define);
+                }
             } else {
                 if (define) {
                     state._attributeDeclaration += this._emitDefine(define);