@@ -293,17 +293,21 @@ public virtual void DrawShadow(T gameObject)
293293
294294 protected virtual float GetDepthFromPosition ( T gameObject , int bottomDrawPoint )
295295 {
296- // In this generic implementation, we only use the cell to fetch its height.
297- // Otherwise, position-related depth is calculated from the bottom draw point of the object.
296+ // Calculate position-related depth from the bottom draw point of the object.
297+ // Snap the texture height to the southernmost pixel coordinate of the southernmost
298+ // cell that this object's texture overlaps.
298299 var cell = Map . GetTile ( gameObject . Position ) ;
300+ int cellY = CellMath . CellTopLeftPointFromCellCoords ( gameObject . Position , Map ) . Y ;
301+ int dy = bottomDrawPoint - cellY ;
302+ int extraHeightForSnap = dy % Constants . CellHeight ;
299303
300304 int height = 0 ;
301305 if ( cell != null )
302306 {
303307 height = cell . Level ;
304308 }
305309
306- return ( ( bottomDrawPoint + ( height * Constants . CellHeight ) + Constants . CellSizeY ) / ( float ) Map . HeightInPixelsWithCellHeight ) * Constants . DownwardsDepthRenderSpace +
310+ return ( ( bottomDrawPoint + ( height * Constants . CellHeight ) + extraHeightForSnap ) / ( float ) Map . HeightInPixelsWithCellHeight ) * Constants . DownwardsDepthRenderSpace +
307311 ( height * Constants . DepthRenderStep ) ;
308312 }
309313
@@ -485,7 +489,7 @@ private void RenderFrame(T gameObject, PositionedTexture frame, PositionedTextur
485489 depthAddition = 1.0f ;
486490
487491 // Add extra depth so objects show above terrain despite float imprecision
488- depthAddition += Constants . DepthEpsilon ;
492+ // depthAddition += Constants.DepthEpsilon;
489493
490494 // There can be a gap between the end of the texture and the bottom-most cell for objects,
491495 // with more "circular" graphics. This can reduce depth when it's calculated in the shader.
0 commit comments