Skip to content

Commit

Permalink
Merge pull request #12925 from sebavan/master
Browse files Browse the repository at this point in the history
Add support of clipplanes in GlowLayer
  • Loading branch information
sebavan authored Aug 31, 2022
2 parents 3ce4157 + 37ea88e commit 18ad3ef
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
30 changes: 30 additions & 0 deletions packages/dev/core/src/Layers/effectLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -648,6 +648,27 @@ export abstract class EffectLayer {
}
}

// ClipPlanes
const scene = this._scene;
if (scene.clipPlane) {
defines.push("#define CLIPPLANE");
}
if (scene.clipPlane2) {
defines.push("#define CLIPPLANE2");
}
if (scene.clipPlane3) {
defines.push("#define CLIPPLANE3");
}
if (scene.clipPlane4) {
defines.push("#define CLIPPLANE4");
}
if (scene.clipPlane5) {
defines.push("#define CLIPPLANE5");
}
if (scene.clipPlane6) {
defines.push("#define CLIPPLANE6");
}

this._addCustomEffectDefines(defines);

// Get correct effect
Expand All @@ -672,6 +693,12 @@ export abstract class EffectLayer {
"opacityIntensity",
"morphTargetTextureInfo",
"morphTargetTextureIndices",
"vClipPlane",
"vClipPlane2",
"vClipPlane3",
"vClipPlane4",
"vClipPlane5",
"vClipPlane6",
],
["diffuseSampler", "emissiveSampler", "opacitySampler", "boneSampler", "morphTargets"],
join,
Expand Down Expand Up @@ -956,6 +983,9 @@ export abstract class EffectLayer {
if (enableAlphaMode) {
engine.setAlphaMode(material.alphaMode);
}

// Clip planes
MaterialHelper.BindClipPlane(effect, scene);
}

// Draw
Expand Down
3 changes: 3 additions & 0 deletions packages/dev/core/src/Shaders/glowMapGeneration.fragment.fx
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,15 @@ uniform sampler2D emissiveSampler;

uniform vec4 glowColor;

#include<clipPlaneFragmentDeclaration>

#define CUSTOM_FRAGMENT_DEFINITIONS

void main(void)
{

#include<clipPlaneFragment>

vec4 finalColor = glowColor;

// _____________________________ Alpha Information _______________________________
Expand Down
11 changes: 9 additions & 2 deletions packages/dev/core/src/Shaders/glowMapGeneration.vertex.fx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ attribute vec3 position;
#include<morphTargetsVertexGlobalDeclaration>
#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]

#include<clipPlaneVertexDeclaration>

// Uniforms
#include<instancesDeclaration>

Expand Down Expand Up @@ -59,11 +61,13 @@ void main(void)
#include<bonesVertex>
#include<bakedVertexAnimation>

vec4 worldPos = finalWorld * vec4(positionUpdated, 1.0);

#ifdef CUBEMAP
vPosition = finalWorld * vec4(positionUpdated, 1.0);
vPosition = worldPos;
gl_Position = viewProjection * finalWorld * vec4(position, 1.0);
#else
vPosition = viewProjection * finalWorld * vec4(positionUpdated, 1.0);
vPosition = viewProjection * worldPos;
gl_Position = vPosition;
#endif

Expand Down Expand Up @@ -97,4 +101,7 @@ void main(void)
#ifdef VERTEXALPHA
vColor = color;
#endif

#include<clipPlaneVertex>

}

0 comments on commit 18ad3ef

Please sign in to comment.