private unsafe byte ComputeMapBlend(Vector2 coords, int face, ref MapBlendCache cache, MyCubemapData<byte> map) { coords = coords * map.Resolution - .5f; Vector2I isample = new Vector2I(coords); if (cache.HashCode != m_hashCode || cache.Face != face || cache.Cell != isample) { byte tl, tr, bl, br; cache.HashCode = m_hashCode; cache.Cell = isample; cache.Face = (byte)face; // Biome if (m_materialMap != null) { map.GetValue(isample.X, isample.Y, out tl); map.GetValue(isample.X + 1, isample.Y, out tr); map.GetValue(isample.X, isample.Y + 1, out bl); map.GetValue(isample.X + 1, isample.Y + 1, out br); byte* ss = stackalloc byte[4]; ss[0] = tl; ss[1] = tr; ss[2] = bl; ss[3] = br; if (tl == tr && bl == br && bl == tl) { fixed (ushort* smpls = cache.Data) { smpls[0] = (ushort)((tl << 8) | 0xF); smpls[1] = 0; smpls[2] = 0; smpls[3] = 0; } } else { fixed (ushort* smpls = cache.Data) { Sort4(ss); ComputeTilePattern(tl, tr, bl, br, ss, smpls); } } } } byte value; fixed (ushort* smpls = cache.Data) { coords -= Vector2.Floor(coords); if (coords.X == 1) coords.X = .99999f; if (coords.Y == 1) coords.Y = .99999f; SampleTile(smpls, ref coords, out value); } return value; }