Skip to content

Commit 959645d

Browse files
committed
Always render drop shadow behind text
1 parent 164cdf9 commit 959645d

1 file changed

Lines changed: 30 additions & 18 deletions

File tree

src/gameobjects/bitmaptext/static/BitmapTextWebGLRenderer.js

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,42 +78,54 @@ var BitmapTextWebGLRenderer = function (renderer, src, interpolationPercentage,
7878
var tintBL = Utils.getTintAppendFloatAlpha(src._tintBL, cameraAlpha * src._alphaBL);
7979
var tintBR = Utils.getTintAppendFloatAlpha(src._tintBR, cameraAlpha * src._alphaBR);
8080

81+
var texture = src.frame.glTexture;
82+
var textureUnit = pipeline.setGameObject(src);
83+
84+
// Update the bounds - skipped internally if not dirty
85+
var bounds = src.getTextBounds(false);
86+
87+
var i;
88+
var char;
89+
var glyph;
90+
91+
var characters = bounds.characters;
92+
8193
var dropShadowX = src.dropShadowX;
8294
var dropShadowY = src.dropShadowY;
8395

8496
var dropShadow = (dropShadowX !== 0 || dropShadowY !== 0);
8597

8698
if (dropShadow)
8799
{
88-
var blackTL = Utils.getTintAppendFloatAlpha(src.dropShadowColor, cameraAlpha * src.dropShadowAlpha * src._alphaTL);
89-
var blackTR = Utils.getTintAppendFloatAlpha(src.dropShadowColor, cameraAlpha * src.dropShadowAlpha * src._alphaTR);
90-
var blackBL = Utils.getTintAppendFloatAlpha(src.dropShadowColor, cameraAlpha * src.dropShadowAlpha * src._alphaBL);
91-
var blackBR = Utils.getTintAppendFloatAlpha(src.dropShadowColor, cameraAlpha * src.dropShadowAlpha * src._alphaBR);
92-
}
100+
var blackTL = Utils.getTintAppendFloatAlpha(src._dropShadowColorGL, cameraAlpha * src.dropShadowAlpha * src._alphaTL);
101+
var blackTR = Utils.getTintAppendFloatAlpha(src._dropShadowColorGL, cameraAlpha * src.dropShadowAlpha * src._alphaTR);
102+
var blackBL = Utils.getTintAppendFloatAlpha(src._dropShadowColorGL, cameraAlpha * src.dropShadowAlpha * src._alphaBL);
103+
var blackBR = Utils.getTintAppendFloatAlpha(src._dropShadowColorGL, cameraAlpha * src.dropShadowAlpha * src._alphaBR);
93104

94-
var texture = src.frame.glTexture;
95-
var textureUnit = pipeline.setGameObject(src);
105+
for (i = 0; i < characters.length; i++)
106+
{
107+
char = characters[i];
108+
glyph = char.glyph;
96109

97-
// Update the bounds - skipped internally if not dirty
98-
var bounds = src.getTextBounds(false);
110+
if (char.code === 32 || glyph.width === 0 || glyph.height === 0)
111+
{
112+
continue;
113+
}
99114

100-
var characters = bounds.characters;
115+
BatchChar(pipeline, src, char, glyph, dropShadowX, dropShadowY, calcMatrix, roundPixels, blackTL, blackTR, blackBL, blackBR, 0, texture, textureUnit);
116+
}
117+
}
101118

102-
for (var i = 0; i < characters.length; i++)
119+
for (i = 0; i < characters.length; i++)
103120
{
104-
var char = characters[i];
105-
var glyph = char.glyph;
121+
char = characters[i];
122+
glyph = char.glyph;
106123

107124
if (char.code === 32 || glyph.width === 0 || glyph.height === 0)
108125
{
109126
continue;
110127
}
111128

112-
if (dropShadow)
113-
{
114-
BatchChar(pipeline, src, char, glyph, dropShadowX, dropShadowY, calcMatrix, roundPixels, blackTL, blackTR, blackBL, blackBR, 0, texture, textureUnit);
115-
}
116-
117129
if (charColors[char.i])
118130
{
119131
var color = charColors[char.i];

0 commit comments

Comments
 (0)