Skip to content

Commit

Permalink
Merge pull request #4734 from AnalyticalGraphicsInc/alpha-fix
Browse files Browse the repository at this point in the history
Fix model alpha
  • Loading branch information
pjcozzi authored Dec 8, 2016
2 parents 512b9a6 + b172977 commit 94eb9d6
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Source/Scene/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -1770,8 +1770,17 @@ define([
' gltf_blend_main(); \n';

// Un-premultiply the alpha so that blending is correct.

// Avoid divide-by-zero. The code below is equivalent to:
// if (gl_FragColor.a > 0.0)
// {
// gl_FragColor.rgb /= gl_FragColor.a;
// }

if (premultipliedAlpha) {
shader += ' gl_FragColor.rgb /= gl_FragColor.a; \n';
shader +=
' float alpha = 1.0 - ceil(gl_FragColor.a) + gl_FragColor.a; \n' +
' gl_FragColor.rgb /= alpha; \n';
}

shader +=
Expand Down

0 comments on commit 94eb9d6

Please sign in to comment.