public void GenerateAsync(bool listCommand = true) { allStrings[0] = ClusterMatResources.infosPath; allStrings[1] = name; allStrings[2] = ".mpipe"; sb.Combine(allStrings); loader.fsm = new FileStream(sb.str, FileMode.Open, FileAccess.Read); loader.LoadAll(); materialIndexBuffer = resources.vmManager.SetMaterials(loader.allProperties.Length); for (int i = 0; i < loader.cluster.Length; ++i) { loader.cluster[i].index = propertyCount; } materialProperties = new NativeArray <VirtualMaterial.MaterialProperties>(loader.allProperties.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); VirtualMaterial.MaterialProperties *propertiesPtr = materialProperties.Ptr(); //Update Material for (int i = 0; i < materialProperties.Length; ++i) { ref var currProp = ref propertiesPtr[i]; currProp = loader.allProperties[i]; if (currProp._MainTex >= 0) { currProp._MainTex = resources.rgbaPool.GetTex(loader.albedoGUIDs[currProp._MainTex]); } if (currProp._SecondaryMainTex >= 0) { currProp._SecondaryMainTex = resources.rgbaPool.GetTex(loader.secondAlbedoGUIDs[currProp._SecondaryMainTex]); } if (currProp._BumpMap >= 0) { currProp._BumpMap = resources.rgbaPool.GetTex(loader.normalGUIDs[currProp._BumpMap], true); } if (currProp._SecondaryBumpMap >= 0) { currProp._SecondaryBumpMap = resources.rgbaPool.GetTex(loader.secondNormalGUIDs[currProp._SecondaryBumpMap], true); } if (currProp._SpecularMap >= 0) { currProp._SpecularMap = resources.rgbaPool.GetTex(loader.smoGUIDs[currProp._SpecularMap]); } if (currProp._SecondarySpecularMap >= 0) { currProp._SecondarySpecularMap = resources.rgbaPool.GetTex(loader.secondSpecGUIDs[currProp._SecondarySpecularMap]); } if (currProp._EmissionMap >= 0) { currProp._EmissionMap = resources.emissionPool.GetTex(loader.emissionGUIDs[currProp._EmissionMap]); } if (currProp._HeightMap >= 0) { currProp._HeightMap = resources.heightPool.GetTex(loader.heightGUIDs[currProp._HeightMap]); } }
public void GenerateAsync() { var resources = ClusterMatResources.current; allStrings[0] = ClusterMatResources.infosPath; allStrings[1] = fileName; allStrings[2] = ".mpipe"; sb.Combine(allStrings); loader.fsm = new FileStream(sb.str, FileMode.Open, FileAccess.Read); if (!loader.LoadAll(resources.maximumClusterCount - SceneController.baseBuffer.prepareClusterCount)) { if (!waiting) { loading = false; } state = State.Unloaded; int required = SceneController.baseBuffer.prepareClusterCount + loader.clusterCount; int actual = resources.maximumClusterCount; Debug.LogError("No Enough Model Space! Required: " + required + " Actual: " + actual); loader.Dispose(); return; } materialIndexBuffer = resources.vmManager.SetMaterials(loader.allProperties.Length); for (int i = 0; i < loader.cluster.Length; ++i) { loader.cluster[i].index = propertyCount; } materialProperties = new NativeArray <VirtualMaterial.MaterialProperties>(loader.allProperties.Length, Allocator.Persistent, NativeArrayOptions.UninitializedMemory); VirtualMaterial.MaterialProperties *propertiesPtr = materialProperties.Ptr(); textureLoadingFlags.Clear(); //Update Material for (int i = 0; i < materialProperties.Length; ++i) { ref var currProp = ref propertiesPtr[i]; currProp = loader.allProperties[i]; if (currProp._MainTex >= 0) { currProp._MainTex = resources.rgbaPool.GetTex(loader.albedoGUIDs[currProp._MainTex], ref textureLoadingFlags); } if (currProp._SecondaryMainTex >= 0) { currProp._SecondaryMainTex = resources.rgbaPool.GetTex(loader.secondAlbedoGUIDs[currProp._SecondaryMainTex], ref textureLoadingFlags); } if (currProp._BumpMap >= 0) { currProp._BumpMap = resources.rgbaPool.GetTex(loader.normalGUIDs[currProp._BumpMap], ref textureLoadingFlags, true); } if (currProp._SecondaryBumpMap >= 0) { currProp._SecondaryBumpMap = resources.rgbaPool.GetTex(loader.secondNormalGUIDs[currProp._SecondaryBumpMap], ref textureLoadingFlags, true); } if (currProp._SpecularMap >= 0) { currProp._SpecularMap = resources.rgbaPool.GetTex(loader.smoGUIDs[currProp._SpecularMap], ref textureLoadingFlags); } if (currProp._SecondarySpecularMap >= 0) { currProp._SecondarySpecularMap = resources.rgbaPool.GetTex(loader.secondSpecGUIDs[currProp._SecondarySpecularMap], ref textureLoadingFlags); } if (currProp._EmissionMap >= 0) { currProp._EmissionMap = resources.emissionPool.GetTex(loader.emissionGUIDs[currProp._EmissionMap], ref textureLoadingFlags); } if (currProp._HeightMap >= 0) { currProp._HeightMap = resources.heightPool.GetTex(loader.heightGUIDs[currProp._HeightMap], ref textureLoadingFlags); } }