Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support of clipplanes in GlowLayer #12925

Merged
merged 1 commit into from
Aug 31, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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>

}