# Mysterious Sparkling Bug

I’ve been noticing for a while an occasional bit of “pixel sparkling” on some of the walls. Those stray yellow pixels, which are the color of the next room over. My theory is that it’s small gaps in my triangle mesh, maybe due to arithmetic round-off error. Ok! Let’s tweak the shader to show those triangles. Yup, that’d be it. When building the mesh, the geometry is initially only decomposed into rectangles. I notice: There are never sparkles on the rectangle halves. Great! I’ll just expand each rectangle slightly.

Rooms in Metareal are generally about 10x10x10. (I think of it as meters… but it’s just “units”.) When I expand each rectangle by 0.01 (a centimeter? sort-of?) it fixes all the sparkles, sure enough, but makes a mess of the corners. I wonder: How “big” are these sparkles? As an experiment, I shrink all the rectangles by 0.0001 (a tenth of a millimeter?) and sure enough… well… take a look. And expanding each rectangle by 0.0001 seems just right. No visible corner-mangling or overlap, and, as near as I can see, all sparkles gone. And some of the code that drives this…

```// Build the four corners of the rectangle
MeVec3 p00 = wVector + sVector * sLo + tVector * tLo;
MeVec3 p10 = wVector + sVector * sHi + tVector * tLo;
MeVec3 p01 = wVector + sVector * sLo + tVector * tHi;
MeVec3 p11 = wVector + sVector * sHi + tVector * tHi;

// we like to expand the rectangle a tiny bit, we need normalized s&t
float expandAmount = 0.0001;
MeVec3 s1Vector = sVector.normalize() * expandAmount;
MeVec3 t1Vector = tVector.normalize() * expandAmount;

// apply the expansion
p00 += -s1Vector -t1Vector;
p01 += -s1Vector +t1Vector;
p10 += +s1Vector -t1Vector;
p11 += +s1Vector +t1Vector;
```

Always nice to resolve an ongoing irritation.