Skip to content

Commit

Permalink
Alpha premultiplied in FS for proper compositing.
Browse files Browse the repository at this point in the history
  • Loading branch information
tsherif committed Mar 15, 2016
1 parent 586730a commit 6b267a7
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/core/display/chunks/flagsChunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ SceneJS_ChunkFactory.createChunkType({
// Entering a transparency bin

gl.enable(gl.BLEND);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
frameCtx.blendEnabled = true;

} else {
Expand Down
2 changes: 1 addition & 1 deletion src/core/display/chunks/regionMapChunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ SceneJS_ChunkFactory.createChunkType({
// Entering a transparency bin

gl.enable(gl.BLEND);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
frameCtx.blendEnabled = true;

} else {
Expand Down
2 changes: 1 addition & 1 deletion src/core/display/chunks/renderTargetChunk.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ SceneJS_ChunkFactory.createChunkType({
// Enable blending for non-depth targets
if (frameCtx.blendEnabled) {
gl.enable(gl.BLEND);
gl.blendFunc(gl.SRC_ALPHA, gl.ONE_MINUS_SRC_ALPHA);
gl.blendFunc(gl.ONE, gl.ONE_MINUS_SRC_ALPHA);
}
}

Expand Down
4 changes: 4 additions & 0 deletions src/core/display/programSourceFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -1304,6 +1304,10 @@ var SceneJS_ProgramSourceFactory = new (function () {
add("fragColor.rgb *= mix(SCENEJS_uFragmentFresnelEdgeColor.rgb, SCENEJS_uFragmentFresnelCenterColor.rgb, fragmentFresnel);");
}

if (!depthTargeting) {
add("fragColor.rgb *= fragColor.a;");
}

add("gl_FragColor = fragColor;");

add("}");
Expand Down

0 comments on commit 6b267a7

Please sign in to comment.