public static void HideCrossings0(Material material, Material segMaterial, NetInfo info, bool lod = false) { if (material == null) { throw new ArgumentNullException("material"); } //if (segMaterial == null) throw new ArgumentNullException("segMaterial"); if (info == null) { throw new ArgumentNullException("info"); } Texture2D tex, tex2; bool dump = false; #if DEBUG dump = false; #endif if (dump) { DumpUtils.Dump(info); } tex = material.TryGetTexture2D(ID_Defuse); Log.Debug($"material={material} tex={tex} h={tex?.height} w={tex?.width}"); if (tex != null) { if (dump) { DumpUtils.Dump(tex, info); } if (TextureCache.Contains(tex)) { tex = TextureCache[tex] as Texture2D; Log.Info("Texture cache hit: " + tex.name); } else { Log.Info("processing Defuse texture for " + tex.name); tex = tex.GetReadableCopy(); tex.CropAndStrech(); if (dump) { DumpUtils.Dump(tex, info); } tex.Finalize(lod); TextureCache[material.GetTexture(ID_Defuse)] = tex; } if (dump) { DumpUtils.Dump(tex, info); } material.SetTexture(ID_Defuse, tex); //Log.Info($"material={material} tex={tex} h={tex.height} w={tex.width}"); if (dump) { DumpUtils.Dump(tex, DumpUtils.GetFilePath(ID_Defuse, "node-processed", info)); } } tex = material.TryGetTexture2D(ID_APRMap); if (tex != null && tex.name != "RoadSmallNode-default-apr" && tex.name != "BasicRoad2_Junction-apr") { segMaterial = segMaterial ?? GetSegmentMaterial(info, ID_APRMap); tex2 = segMaterial?.TryGetTexture2D(ID_APRMap); if (tex != null && tex2 != null) { if (dump) { DumpUtils.Dump(tex, info); } if (dump) { DumpUtils.Dump(tex2, info); } if (TextureCache.Contains(tex)) { tex = TextureCache[tex] as Texture2D; Log.Info("Texture cache hit: " + tex.name); } else { Log.Info("processing APR texture for " + tex.name); bool linear = lod && !info.IsNExt(); tex = tex.GetReadableCopy(linear: linear); tex2 = tex2.GetReadableCopy(linear: linear); if (tex2.width == tex.width * 2) { tex2 = TextureUtils.CutToSize(tex2, tex.width, tex.height); if (dump) { DumpUtils.Dump(tex2, info); } } tex.CropAndStrech(); if (dump) { DumpUtils.Dump(tex, info); } if (info.m_netAI is RoadAI) { if (info.isAsym() && !info.isOneWay()) { tex2.Mirror(); if (dump) { DumpUtils.Dump(tex2, info); } } tex2.Scale(info.ScaleRatio()); if (info.ScaleRatio() != 1f && dump) { DumpUtils.Dump(tex2, info); } } tex.MeldDiff(tex2); if (dump) { DumpUtils.Dump(tex, info); } tex.Finalize(lod); TextureCache[material.GetTexture(ID_APRMap)] = tex; } material.SetTexture(ID_APRMap, tex); if (dump) { DumpUtils.Dump(tex, DumpUtils.GetFilePath(ID_APRMap, "node-processed", info)); } } // end if cache } // end if tex } // end if category