Pārlūkot izejas kodu

add two new clipplanes (5 and 6) to get a clipcube

mickPASTOR 5 gadi atpakaļ
vecāks
revīzija
86d156aea8
29 mainītis faili ar 196 papildinājumiem un 58 dzēšanām
  1. 3 1
      materialsLibrary/src/cell/cellMaterial.ts
  2. 3 1
      materialsLibrary/src/fire/fireMaterial.ts
  3. 3 1
      materialsLibrary/src/fur/furMaterial.ts
  4. 3 1
      materialsLibrary/src/gradient/gradientMaterial.ts
  5. 3 1
      materialsLibrary/src/lava/lavaMaterial.ts
  6. 3 1
      materialsLibrary/src/mix/mixMaterial.ts
  7. 3 1
      materialsLibrary/src/normal/normalMaterial.ts
  8. 3 1
      materialsLibrary/src/shadowOnly/shadowOnlyMaterial.ts
  9. 3 1
      materialsLibrary/src/simple/simpleMaterial.ts
  10. 3 1
      materialsLibrary/src/sky/skyMaterial.ts
  11. 3 1
      materialsLibrary/src/terrain/terrainMaterial.ts
  12. 3 1
      materialsLibrary/src/triPlanar/triPlanarMaterial.ts
  13. 3 1
      materialsLibrary/src/water/waterMaterial.ts
  14. 3 1
      src/Materials/Background/backgroundMaterial.ts
  15. 3 1
      src/Materials/PBR/pbrBaseMaterial.ts
  16. 22 0
      src/Materials/materialHelper.ts
  17. 3 1
      src/Materials/standardMaterial.ts
  18. 3 1
      src/Meshes/linesMesh.ts
  19. 8 2
      src/Particles/gpuParticleSystem.ts
  20. 10 2
      src/Particles/particleSystem.ts
  21. 14 0
      src/Shaders/ShadersInclude/clipPlaneFragment.fx
  22. 8 0
      src/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.fx
  23. 8 0
      src/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.fx
  24. 8 0
      src/Shaders/ShadersInclude/clipPlaneVertex.fx
  25. 10 0
      src/Shaders/ShadersInclude/clipPlaneVertexDeclaration.fx
  26. 10 0
      src/Shaders/ShadersInclude/clipPlaneVertexDeclaration2.fx
  27. 14 14
      src/Shaders/gpuRenderParticles.vertex.fx
  28. 23 23
      src/Shaders/particles.vertex.fx
  29. 10 0
      src/scene.ts

+ 3 - 1
materialsLibrary/src/cell/cellMaterial.ts

@@ -26,6 +26,8 @@ class CellMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public POINTSIZE = false;
     public FOG = false;
@@ -188,7 +190,7 @@ export class CellMaterial extends PushMaterial {
                 "vFogInfos", "vFogColor", "pointSize",
                 "vDiffuseInfos",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix"
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix"
             ];
             var samplers = ["diffuseSampler"];
             var uniformBuffers = new Array<string>();

+ 3 - 1
materialsLibrary/src/fire/fireMaterial.ts

@@ -27,6 +27,8 @@ class FireMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public DEPTHPREPASS = false;
     public POINTSIZE = false;
@@ -177,7 +179,7 @@ export class FireMaterial extends PushMaterial {
                         "vFogInfos", "vFogColor", "pointSize",
                         "vDiffuseInfos",
                         "mBones",
-                        "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix",
+                        "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix",
                         // Fire
                         "time", "speed"
                     ],

+ 3 - 1
materialsLibrary/src/fur/furMaterial.ts

@@ -30,6 +30,8 @@ class FurMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public DEPTHPREPASS = false;
     public POINTSIZE = false;
@@ -266,7 +268,7 @@ export class FurMaterial extends PushMaterial {
                 "vFogInfos", "vFogColor", "pointSize",
                 "vDiffuseInfos",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix",
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix",
                 "furLength", "furAngle", "furColor", "furOffset", "furGravity", "furTime", "furSpacing", "furDensity", "furOcclusion"
             ];
             var samplers = ["diffuseSampler",

+ 3 - 1
materialsLibrary/src/gradient/gradientMaterial.ts

@@ -25,6 +25,8 @@ class GradientMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public DEPTHPREPASS = false;
     public POINTSIZE = false;
@@ -179,7 +181,7 @@ export class GradientMaterial extends PushMaterial {
             var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
                 "vFogInfos", "vFogColor", "pointSize",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4",
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6",
                 "topColor", "bottomColor", "offset", "smoothness", "scale"
             ];
             var samplers: string[] = [];

+ 3 - 1
materialsLibrary/src/lava/lavaMaterial.ts

@@ -26,6 +26,8 @@ class LavaMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public DEPTHPREPASS = false;
     public POINTSIZE = false;
@@ -249,7 +251,7 @@ export class LavaMaterial extends PushMaterial {
                 "vFogInfos", "vFogColor", "pointSize",
                 "vDiffuseInfos",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix",
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix",
                 "time", "speed", "movingSpeed",
                 "fogColor", "fogDensity", "lowFrequencySpeed"
             ];

+ 3 - 1
materialsLibrary/src/mix/mixMaterial.ts

@@ -27,6 +27,8 @@ class MixMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public DEPTHPREPASS = false;
     public POINTSIZE = false;
@@ -278,7 +280,7 @@ export class MixMaterial extends PushMaterial {
                 "vFogInfos", "vFogColor", "pointSize",
                 "vTextureInfos",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMatrix",
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMatrix",
                 "diffuse1Infos", "diffuse2Infos", "diffuse3Infos", "diffuse4Infos",
                 "diffuse5Infos", "diffuse6Infos", "diffuse7Infos", "diffuse8Infos"
             ];

+ 3 - 1
materialsLibrary/src/normal/normalMaterial.ts

@@ -26,6 +26,8 @@ class NormalMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public DEPTHPREPASS = false;
     public POINTSIZE = false;
@@ -222,7 +224,7 @@ export class NormalMaterial extends PushMaterial {
                 "vFogInfos", "vFogColor", "pointSize",
                 "vDiffuseInfos",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix"
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix"
             ];
             var samplers = ["diffuseSampler"];
             var uniformBuffers = new Array<string>();

+ 3 - 1
materialsLibrary/src/shadowOnly/shadowOnlyMaterial.ts

@@ -24,6 +24,8 @@ class ShadowOnlyMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public POINTSIZE = false;
     public FOG = false;
     public NORMAL = false;
@@ -151,7 +153,7 @@ export class ShadowOnlyMaterial extends PushMaterial {
             var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
                 "vFogInfos", "vFogColor", "pointSize", "alpha", "shadowColor",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4"
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6"
             ];
             var samplers = new Array<string>();
 

+ 3 - 1
materialsLibrary/src/simple/simpleMaterial.ts

@@ -26,6 +26,8 @@ class SimpleMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public DEPTHPREPASS = false;
     public POINTSIZE = false;
@@ -177,7 +179,7 @@ export class SimpleMaterial extends PushMaterial {
                 "vFogInfos", "vFogColor", "pointSize",
                 "vDiffuseInfos",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix"
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix"
             ];
             var samplers = ["diffuseSampler"];
             var uniformBuffers = new Array<string>();

+ 3 - 1
materialsLibrary/src/sky/skyMaterial.ts

@@ -23,6 +23,8 @@ class SkyMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public POINTSIZE = false;
     public FOG = false;
     public VERTEXCOLOR = false;
@@ -209,7 +211,7 @@ export class SkyMaterial extends PushMaterial {
             subMesh.setEffect(scene.getEngine().createEffect(shaderName,
                 attribs,
                 ["world", "viewProjection", "view",
-                    "vFogInfos", "vFogColor", "pointSize", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4",
+                    "vFogInfos", "vFogColor", "pointSize", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6",
                     "luminance", "turbidity", "rayleigh", "mieCoefficient", "mieDirectionalG", "sunPosition",
                     "cameraPosition", "cameraOffset"
                 ],

+ 3 - 1
materialsLibrary/src/terrain/terrainMaterial.ts

@@ -28,6 +28,8 @@ class TerrainMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public DEPTHPREPASS = false;
     public POINTSIZE = false;
@@ -240,7 +242,7 @@ export class TerrainMaterial extends PushMaterial {
                 "vFogInfos", "vFogColor", "pointSize",
                 "vTextureInfos",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMatrix",
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMatrix",
                 "diffuse1Infos", "diffuse2Infos", "diffuse3Infos"
             ];
             var samplers = ["textureSampler", "diffuse1Sampler", "diffuse2Sampler", "diffuse3Sampler",

+ 3 - 1
materialsLibrary/src/triPlanar/triPlanarMaterial.ts

@@ -34,6 +34,8 @@ class TriPlanarMaterialDefines extends MaterialDefines {
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public DEPTHPREPASS = false;
     public POINTSIZE = false;
@@ -232,7 +234,7 @@ export class TriPlanarMaterial extends PushMaterial {
             var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vDiffuseColor", "vSpecularColor",
                 "vFogInfos", "vFogColor", "pointSize",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4",
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6",
                 "tileSize"
             ];
             var samplers = ["diffuseSamplerX", "diffuseSamplerY", "diffuseSamplerZ",

+ 3 - 1
materialsLibrary/src/water/waterMaterial.ts

@@ -34,6 +34,8 @@ class WaterMaterialDefines extends MaterialDefines implements IImageProcessingCo
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public DEPTHPREPASS = false;
     public POINTSIZE = false;
@@ -438,7 +440,7 @@ export class WaterMaterial extends PushMaterial {
                 "vFogInfos", "vFogColor", "pointSize",
                 "vNormalInfos",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "normalMatrix",
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "normalMatrix",
                 "logarithmicDepthConstant",
 
                 // Water

+ 3 - 1
src/Materials/Background/backgroundMaterial.ts

@@ -151,6 +151,8 @@ class BackgroundMaterialDefines extends MaterialDefines implements IImageProcess
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public POINTSIZE = false;
     public FOG = false;
     public NORMAL = false;
@@ -869,7 +871,7 @@ export class BackgroundMaterial extends PushMaterial {
 
             var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
                 "vFogInfos", "vFogColor", "pointSize",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "mBones",
 
                 "vPrimaryColor", "vPrimaryColorShadow",
                 "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",

+ 3 - 1
src/Materials/PBR/pbrBaseMaterial.ts

@@ -183,6 +183,8 @@ export class PBRMaterialDefines extends MaterialDefines
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public POINTSIZE = false;
     public FOG = false;
     public LOGARITHMICDEPTH = false;
@@ -1205,7 +1207,7 @@ export abstract class PBRBaseMaterial extends PushMaterial {
             "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
             "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos",
             "mBones",
-            "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix",
+            "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix",
             "vLightingIntensity",
             "logarithmicDepthConstant",
             "vSphericalX", "vSphericalY", "vSphericalZ",

+ 22 - 0
src/Materials/materialHelper.ts

@@ -123,11 +123,15 @@ export class MaterialHelper {
         let useClipPlane2 = false;
         let useClipPlane3 = false;
         let useClipPlane4 = false;
+        let useClipPlane5 = false;
+        let useClipPlane6 = false;
 
         useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
         useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
         useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
         useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
+        useClipPlane5 = useClipPlane == null ? (scene.clipPlane5 !== undefined && scene.clipPlane5 !== null) : useClipPlane;
+        useClipPlane6 = useClipPlane == null ? (scene.clipPlane6 !== undefined && scene.clipPlane6 !== null) : useClipPlane;
 
         if (defines["CLIPPLANE"] !== useClipPlane1) {
             defines["CLIPPLANE"] = useClipPlane1;
@@ -149,6 +153,16 @@ export class MaterialHelper {
             changed = true;
         }
 
+        if (defines["CLIPPLANE5"] !== useClipPlane5) {
+            defines["CLIPPLANE5"] = useClipPlane5;
+            changed = true;
+        }
+
+        if (defines["CLIPPLANE6"] !== useClipPlane6) {
+            defines["CLIPPLANE6"] = useClipPlane6;
+            changed = true;
+        }
+
         if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
             defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
             changed = true;
@@ -788,5 +802,13 @@ export class MaterialHelper {
             let clipPlane = scene.clipPlane4;
             effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
         }
+        if (scene.clipPlane5) {
+            let clipPlane = scene.clipPlane5;
+            effect.setFloat4("vClipPlane5", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
+        }
+        if (scene.clipPlane6) {
+            let clipPlane = scene.clipPlane6;
+            effect.setFloat4("vClipPlane6", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
+        }
     }
 }

+ 3 - 1
src/Materials/standardMaterial.ts

@@ -57,6 +57,8 @@ export class StandardMaterialDefines extends MaterialDefines implements IImagePr
     public CLIPPLANE2 = false;
     public CLIPPLANE3 = false;
     public CLIPPLANE4 = false;
+    public CLIPPLANE5 = false;
+    public CLIPPLANE6 = false;
     public ALPHATEST = false;
     public DEPTHPREPASS = false;
     public ALPHAFROMDIFFUSE = false;
@@ -1122,7 +1124,7 @@ export class StandardMaterial extends PushMaterial {
                 "vFogInfos", "vFogColor", "pointSize",
                 "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
                 "mBones",
-                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
+                "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
                 "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
                 "vReflectionPosition", "vReflectionSize",
                 "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"

+ 3 - 1
src/Meshes/linesMesh.ts

@@ -81,7 +81,7 @@ export class LinesMesh extends Mesh {
         var defines: string[] = [];
         var options = {
             attributes: [VertexBuffer.PositionKind, "world0", "world1", "world2", "world3"],
-            uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "world", "viewProjection"],
+            uniforms: ["vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "world", "viewProjection"],
             needAlphaBlending: true,
             defines: defines
         };
@@ -132,6 +132,8 @@ export class LinesMesh extends Mesh {
         scene.clipPlane2 ? this._addClipPlaneDefine("CLIPPLANE2") : this._removeClipPlaneDefine("CLIPPLANE2");
         scene.clipPlane3 ? this._addClipPlaneDefine("CLIPPLANE3") : this._removeClipPlaneDefine("CLIPPLANE3");
         scene.clipPlane4 ? this._addClipPlaneDefine("CLIPPLANE4") : this._removeClipPlaneDefine("CLIPPLANE4");
+        scene.clipPlane5 ? this._addClipPlaneDefine("CLIPPLANE5") : this._removeClipPlaneDefine("CLIPPLANE5");
+        scene.clipPlane6 ? this._addClipPlaneDefine("CLIPPLANE6") : this._removeClipPlaneDefine("CLIPPLANE6");
 
         if (!this._colorShader.isReady()) {
             return false;

+ 8 - 2
src/Particles/gpuParticleSystem.ts

@@ -1028,6 +1028,12 @@ export class GPUParticleSystem extends BaseParticleSystem implements IDisposable
         if (this._scene.clipPlane4) {
             defines = "\n#define CLIPPLANE4";
         }
+        if (this._scene.clipPlane5) {
+            defines = "\n#define CLIPPLANE5";
+        }
+        if (this._scene.clipPlane6) {
+            defines = "\n#define CLIPPLANE6";
+        }
 
         if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
             defines = "\n#define BLENDMULTIPLYMODE";
@@ -1066,7 +1072,7 @@ export class GPUParticleSystem extends BaseParticleSystem implements IDisposable
             return;
         }
 
-        var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
+        var uniforms = ["worldOffset", "view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "sheetInfos", "translationPivot", "eyePosition"];
         var samplers = ["textureSampler", "colorGradientSampler"];
 
         if (ImageProcessingConfiguration) {
@@ -1315,7 +1321,7 @@ export class GPUParticleSystem extends BaseParticleSystem implements IDisposable
                 this._renderEffect.setVector3("eyePosition", camera.globalPosition);
             }
 
-            if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
+            if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) {
                 var invView = viewMatrix.clone();
                 invView.invert();
                 this._renderEffect.setMatrix("invView", invView);

+ 10 - 2
src/Particles/particleSystem.ts

@@ -1493,7 +1493,7 @@ export class ParticleSystem extends BaseParticleSystem implements IDisposable, I
 
     /** @hidden */
     public static _GetEffectCreationOptions(isAnimationSheetEnabled = false): string[] {
-        var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
+        var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "vClipPlane5", "vClipPlane6", "textureMask", "translationPivot", "eyePosition"];
 
         if (isAnimationSheetEnabled) {
             effectCreationOption.push("particlesInfos");
@@ -1526,6 +1526,14 @@ export class ParticleSystem extends BaseParticleSystem implements IDisposable, I
             defines.push("#define CLIPPLANE4");
         }
 
+        if (this._scene.clipPlane5) {
+            defines.push("#define CLIPPLANE5");
+        }
+
+        if (this._scene.clipPlane6) {
+            defines.push("#define CLIPPLANE6");
+        }
+
         if (this._isAnimationSheetEnabled) {
             defines.push("#define ANIMATESHEET");
         }
@@ -1763,7 +1771,7 @@ export class ParticleSystem extends BaseParticleSystem implements IDisposable, I
             effect.setTexture("rampSampler", this._rampGradientsTexture);
         }
 
-        if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
+        if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4 || this._scene.clipPlane5 || this._scene.clipPlane6) {
             var invView = viewMatrix.clone();
             invView.invert();
             effect.setMatrix("invView", invView);

+ 14 - 0
src/Shaders/ShadersInclude/clipPlaneFragment.fx

@@ -24,4 +24,18 @@
 	{
 		discard;
 	}
+#endif
+
+#ifdef CLIPPLANE5
+	if (fClipDistance5 > 0.0)
+	{
+		discard;
+	}
+#endif
+
+#ifdef CLIPPLANE6
+	if (fClipDistance6 > 0.0)
+	{
+		discard;
+	}
 #endif

+ 8 - 0
src/Shaders/ShadersInclude/clipPlaneFragmentDeclaration.fx

@@ -12,4 +12,12 @@
 
 #ifdef CLIPPLANE4
 	varying float fClipDistance4;
+#endif
+
+#ifdef CLIPPLANE5
+	varying float fClipDistance5;
+#endif
+
+#ifdef CLIPPLANE6
+	varying float fClipDistance6;
 #endif

+ 8 - 0
src/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.fx

@@ -12,4 +12,12 @@
 
 #ifdef CLIPPLANE4
 	in float fClipDistance4;
+#endif
+
+#ifdef CLIPPLANE5
+	in float fClipDistance5;
+#endif
+
+#ifdef CLIPPLANE6
+	in float fClipDistance6;
 #endif

+ 8 - 0
src/Shaders/ShadersInclude/clipPlaneVertex.fx

@@ -12,4 +12,12 @@
 
 #ifdef CLIPPLANE4
 	fClipDistance4 = dot(worldPos, vClipPlane4);
+#endif
+
+#ifdef CLIPPLANE5
+	fClipDistance5 = dot(worldPos, vClipPlane5);
+#endif
+
+#ifdef CLIPPLANE6
+	fClipDistance6 = dot(worldPos, vClipPlane6);
 #endif

+ 10 - 0
src/Shaders/ShadersInclude/clipPlaneVertexDeclaration.fx

@@ -16,4 +16,14 @@
 #ifdef CLIPPLANE4
 	uniform vec4 vClipPlane4;
 	varying float fClipDistance4;
+#endif
+
+#ifdef CLIPPLANE5
+	uniform vec4 vClipPlane5;
+	varying float fClipDistance5;
+#endif
+
+#ifdef CLIPPLANE6
+	uniform vec4 vClipPlane6;
+	varying float fClipDistance6;
 #endif

+ 10 - 0
src/Shaders/ShadersInclude/clipPlaneVertexDeclaration2.fx

@@ -16,4 +16,14 @@
 #ifdef CLIPPLANE4
 	uniform vec4 vClipPlane4;
 	out float fClipDistance4;
+#endif
+
+#ifdef CLIPPLANE5
+	uniform vec4 vClipPlane5;
+	out float fClipDistance5;
+#endif
+
+#ifdef CLIPPLANE6
+	uniform vec4 vClipPlane6;
+	out float fClipDistance6;
 #endif

+ 14 - 14
src/Shaders/gpuRenderParticles.vertex.fx

@@ -27,7 +27,7 @@ in vec2 uv;
 out vec2 vUV;
 out vec4 vColor;
 
-#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)
+#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
 uniform mat4 invView;
 #endif
 
@@ -45,9 +45,9 @@ uniform vec3 sheetInfos;
 #endif
 
 #ifdef BILLBOARD
-	uniform vec3 eyePosition;	
+	uniform vec3 eyePosition;
 #endif
-	
+
 vec3 rotate(vec3 yaxis, vec3 rotatedCorner) {
 	vec3 xaxis = normalize(cross(vec3(0., 1.0, 0.), yaxis));
 	vec3 zaxis = normalize(cross(yaxis, xaxis));
@@ -76,7 +76,7 @@ vec3 rotateAlign(vec3 toCamera, vec3 rotatedCorner) {
 	mat3 rotMatrix =  mat3(row0, row1, row2);
 
 	vec3 alignedCorner = rotMatrix * rotatedCorner;
-	return (position + worldOffset) + alignedCorner; 
+	return (position + worldOffset) + alignedCorner;
 }
 #endif
 
@@ -89,7 +89,7 @@ void main() {
 		vec2 uvScale = sheetInfos.xy;
 		vec2 uvOffset = vec2(uv.x , 1.0 - uv.y);
 		vUV = (uvOffset + vec2(columnOffset, rowOffset)) * uvScale;
-	#else	
+	#else
    	vUV = uv;
 	#endif
   float ratio = age / life;
@@ -98,14 +98,14 @@ void main() {
 #else
 	vColor = color * vec4(1.0 - ratio) + colorDead * vec4(ratio);
 #endif
-  
+
   vec2 cornerPos = (offset - translationPivot) * size.yz * size.x + translationPivot;
 
 #ifdef BILLBOARD
 	vec4 rotatedCorner;
 	rotatedCorner.w = 0.;
 
-	#ifdef BILLBOARDY	
+	#ifdef BILLBOARDY
 		rotatedCorner.x = cornerPos.x * cos(angle) - cornerPos.y * sin(angle);
 		rotatedCorner.z = cornerPos.x * sin(angle) + cornerPos.y * cos(angle);
 		rotatedCorner.y = 0.;
@@ -114,16 +114,16 @@ void main() {
 		yaxis.y = 0.;
 		vec3 worldPos = rotate(normalize(yaxis), rotatedCorner.xyz);
 
-		vec4 viewPosition = (view * vec4(worldPos, 1.0)); 
+		vec4 viewPosition = (view * vec4(worldPos, 1.0));
 	#elif defined(BILLBOARDSTRETCHED)
 		rotatedCorner.x = cornerPos.x * cos(angle) - cornerPos.y * sin(angle);
 		rotatedCorner.y = cornerPos.x * sin(angle) + cornerPos.y * cos(angle);
 		rotatedCorner.z = 0.;
 
-		vec3 toCamera = (position + worldOffset) - eyePosition;	
+		vec3 toCamera = (position + worldOffset) - eyePosition;
 		vec3 worldPos = rotateAlign(toCamera, rotatedCorner.xyz);
-		
-		vec4 viewPosition = (view * vec4(worldPos, 1.0)); 	
+
+		vec4 viewPosition = (view * vec4(worldPos, 1.0));
 	#else
 		// Rotate
 		rotatedCorner.x = cornerPos.x * cos(angle) - cornerPos.y * sin(angle);
@@ -145,13 +145,13 @@ void main() {
 	vec3 worldPos = rotate(yaxis, rotatedCorner);
 
   // Expand position
-  vec4 viewPosition = view * vec4(worldPos, 1.0);  
+  vec4 viewPosition = view * vec4(worldPos, 1.0);
 #endif
 	gl_Position = projection * viewPosition;
 
 	// Clip plane
-#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)
+#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
 	vec4 worldPos = invView * viewPosition;
-#endif  
+#endif
 	#include<clipPlaneVertex>
 }

+ 23 - 23
src/Shaders/particles.vertex.fx

@@ -3,14 +3,14 @@ attribute vec3 position;
 attribute vec4 color;
 attribute float angle;
 attribute vec2 size;
-#ifdef ANIMATESHEET	
+#ifdef ANIMATESHEET
 attribute float cellIndex;
 #endif
-#ifndef BILLBOARD	
+#ifndef BILLBOARD
 attribute vec3 direction;
 #endif
 #ifdef BILLBOARDSTRETCHED
-attribute vec3 direction; 
+attribute vec3 direction;
 #endif
 #ifdef RAMPGRADIENT
 attribute vec4 remapData;
@@ -22,7 +22,7 @@ uniform mat4 view;
 uniform mat4 projection;
 uniform vec2 translationPivot;
 
-#ifdef ANIMATESHEET	
+#ifdef ANIMATESHEET
 uniform vec3 particlesInfos; // x (number of rows) y(number of columns) z(rowSize)
 #endif
 
@@ -34,13 +34,13 @@ varying vec4 vColor;
 varying vec4 remapRanges;
 #endif
 
-#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)
+#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
 uniform mat4 invView;
 #endif
 #include<clipPlaneVertexDeclaration>
 
 #ifdef BILLBOARD
-	uniform vec3 eyePosition;	
+	uniform vec3 eyePosition;
 #endif
 
 vec3 rotate(vec3 yaxis, vec3 rotatedCorner) {
@@ -54,7 +54,7 @@ vec3 rotate(vec3 yaxis, vec3 rotatedCorner) {
 	mat3 rotMatrix =  mat3(row0, row1, row2);
 
 	vec3 alignedCorner = rotMatrix * rotatedCorner;
-	return position + alignedCorner; 
+	return position + alignedCorner;
 }
 
 #ifdef BILLBOARDSTRETCHED
@@ -70,45 +70,45 @@ vec3 rotateAlign(vec3 toCamera, vec3 rotatedCorner) {
 	mat3 rotMatrix =  mat3(row0, row1, row2);
 
 	vec3 alignedCorner = rotMatrix * rotatedCorner;
-	return position + alignedCorner; 
+	return position + alignedCorner;
 }
 #endif
 
-void main(void) {	
+void main(void) {
 	vec2 cornerPos;
-	
+
 	cornerPos = (vec2(offset.x - 0.5, offset.y  - 0.5) - translationPivot) * size + translationPivot;
 
-#ifdef BILLBOARD	
+#ifdef BILLBOARD
 	// Rotate
 	vec3 rotatedCorner;
 
-#ifdef BILLBOARDY	
+#ifdef BILLBOARDY
 	rotatedCorner.x = cornerPos.x * cos(angle) - cornerPos.y * sin(angle);
 	rotatedCorner.z = cornerPos.x * sin(angle) + cornerPos.y * cos(angle);
 	rotatedCorner.y = 0.;
 
 	vec3 yaxis = position - eyePosition;
 	yaxis.y = 0.;
-	
+
 	vec3 worldPos = rotate(normalize(yaxis), rotatedCorner);
-	
-	vec3 viewPos = (view * vec4(worldPos, 1.0)).xyz; 
+
+	vec3 viewPos = (view * vec4(worldPos, 1.0)).xyz;
 #elif defined(BILLBOARDSTRETCHED)
 	rotatedCorner.x = cornerPos.x * cos(angle) - cornerPos.y * sin(angle);
 	rotatedCorner.y = cornerPos.x * sin(angle) + cornerPos.y * cos(angle);
 	rotatedCorner.z = 0.;
 
-	vec3 toCamera = position - eyePosition;	
+	vec3 toCamera = position - eyePosition;
 	vec3 worldPos = rotateAlign(toCamera, rotatedCorner);
-	
-	vec3 viewPos = (view * vec4(worldPos, 1.0)).xyz; 
+
+	vec3 viewPos = (view * vec4(worldPos, 1.0)).xyz;
 #else
 	rotatedCorner.x = cornerPos.x * cos(angle) - cornerPos.y * sin(angle);
 	rotatedCorner.y = cornerPos.x * sin(angle) + cornerPos.y * cos(angle);
 	rotatedCorner.z = 0.;
 
-	vec3 viewPos = (view * vec4(position, 1.0)).xyz + rotatedCorner; 
+	vec3 viewPos = (view * vec4(position, 1.0)).xyz + rotatedCorner;
 #endif
 
 #ifdef RAMPGRADIENT
@@ -116,7 +116,7 @@ void main(void) {
 #endif
 
 	// Position
-	gl_Position = projection * vec4(viewPos, 1.0);   
+	gl_Position = projection * vec4(viewPos, 1.0);
 #else
 	// Rotate
 	vec3 rotatedCorner;
@@ -127,8 +127,8 @@ void main(void) {
 	vec3 yaxis = normalize(direction);
 	vec3 worldPos = rotate(yaxis, rotatedCorner);
 
-	gl_Position = projection * view * vec4(worldPos, 1.0);  
-#endif	
+	gl_Position = projection * view * vec4(worldPos, 1.0);
+#endif
 	vColor = color;
 
 	#ifdef ANIMATESHEET
@@ -143,7 +143,7 @@ void main(void) {
 	#endif
 
 	// Clip plane
-#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)
+#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4) || defined(CLIPPLANE5) || defined(CLIPPLANE6)
 	vec4 worldPos = invView * vec4(viewPos, 1.0);
 #endif
 	#include<clipPlaneVertex>

+ 10 - 0
src/scene.ts

@@ -294,6 +294,16 @@ export class Scene extends AbstractScene implements IAnimatable {
     public clipPlane4: Nullable<Plane>;
 
     /**
+     * Gets or sets the active clipplane 5
+     */
+    public clipPlane5: Nullable<Plane>;
+
+    /**
+     * Gets or sets the active clipplane 6
+     */
+    public clipPlane6: Nullable<Plane>;
+
+    /**
      * Gets or sets a boolean indicating if animations are enabled
      */
     public animationsEnabled = true;