Skip to content
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
22 changes: 19 additions & 3 deletions src/Layers/glowLayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,16 @@ export interface IGlowLayerOptions {
* The rendering group to draw the layer in.
*/
renderingGroupId: number;

/**
* Forces the merge step to be done in ldr (clamp values > 1)
*/
ldrMerge?: boolean;

/**
* Defines the blend mode used by the merge
*/
alphaBlendingMode?: number;
}

/**
Expand Down Expand Up @@ -183,12 +193,14 @@ export class GlowLayer extends EffectLayer {
camera: null,
mainTextureSamples: 1,
renderingGroupId: -1,
ldrMerge: false,
alphaBlendingMode: Constants.ALPHA_ADD,
...options,
};

// Initialize the layer
this._init({
alphaBlendingMode: Constants.ALPHA_ADD,
alphaBlendingMode: this._options.alphaBlendingMode,
camera: this._options.camera,
mainTextureFixedSize: this._options.mainTextureFixedSize,
mainTextureRatio: this._options.mainTextureRatio,
Expand All @@ -209,13 +221,17 @@ export class GlowLayer extends EffectLayer {
* to the main canvas at the end of the scene rendering.
*/
protected _createMergeEffect(): Effect {
let defines = "#define EMISSIVE \n";
if (this._options.ldrMerge) {
defines += "#define LDR \n";
}

// Effect
return this._engine.createEffect("glowMapMerge",
[VertexBuffer.PositionKind],
["offset"],
["textureSampler", "textureSampler2"],
"#define EMISSIVE \n");

defines);
}

/**
Expand Down
4 changes: 4 additions & 0 deletions src/Shaders/glowMapMerge.fragment.fx
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,9 @@ void main(void) {
#endif
#endif

#if LDR
baseColor = clamp(baseColor, 0., 1.0);
#endif

gl_FragColor = baseColor;
}