public void Start() { var msw = new MyStopWatch(); msw.StartSegment("Loading"); var loader = new HabitatMapOsmLoader(); var fields = loader.Load(@"C:\inz\osm\map.osm"); msw.StartSegment("Translating"); var translator = new HabitatFieldPositionTranslator(GeoCoordsToUnityTranslator.DefaultTranslator); fields = fields.Select(c => translator.Translate(c)).ToList(); msw.StartSegment("MapCreating"); var map = HabitatMap.Create( new MyRectangle(62 * 720, 67 * 720, 8 * 720, 8 * 720), new Vector2(90 * 8, 90 * 8), fields, HabitatType.NotSpecified, HabitatTypePriorityResolver.Default); GeoCoordsToUnityTranslator translator2 = GeoCoordsToUnityTranslator.DefaultTranslator; var geoPos1 = new GeoCoordinate(49.600f, 19.543f); var lifePos1 = translator2.TranslateToUnity(geoPos1); var geoPos2 = new GeoCoordinate(49.610f, 19.552f); var lifePos2 = translator2.TranslateToUnity(geoPos2); MyRectangle territoryUsedToCreateStainTexture = new MyRectangle(lifePos1.x, lifePos1.y, lifePos2.x - lifePos1.x, lifePos2.y - lifePos1.y); territoryUsedToCreateStainTexture = RectangleUtils.CalculateSubPosition(territoryUsedToCreateStainTexture, new MyRectangle(0.65f, 0.65f, 0.1f, 0.1f)); var treeX = map.QueryMap(territoryUsedToCreateStainTexture); var parentObjectX = new GameObject($"MAGA"); treeX.QueryAll() .ForEach(c => HabitatMapOsmLoaderDebugObject.CreateDebugHabitatField(c.Field, 0.01f, parentObjectX)); msw.StartSegment("MapQuerying"); for (int x = 0; x < 8; x++) { for (int y = 0; y < 8; y++) { var tree = map.QueryMap( new MyRectangle(62 * 720 + x * 720, 67 * 720 + y * 720, 720, 720)); var parentObject = new GameObject($"x:{x} y:{y}"); tree.QueryAll() .ForEach(c => HabitatMapOsmLoaderDebugObject.CreateDebugHabitatField(c.Field, 0.01f, parentObject)); } } Debug.Log("T64: " + msw.CollectResults()); }
public float [] Generate(Mesh inputMesh, int radius = 5, bool useKring = true) { var unaliasedGenerator = new UnaliasedMeshGenerator(); var unaliasedMesh = unaliasedGenerator.GenerateUnaliasedMesh(inputMesh); var verticesFlatArray = unaliasedMesh.Vertices.SelectMany(c => c.ToArray()).ToArray(); var unaliasedVerticesCount = unaliasedMesh.Vertices.Length; var unaliasedTrianglesCount = unaliasedMesh.Triangles.Length / 3; var outDirection1 = new float[3 * unaliasedVerticesCount]; var outDirection2 = new float[3 * unaliasedVerticesCount]; var outValues1 = new float[unaliasedVerticesCount]; var outValues2 = new float[unaliasedVerticesCount]; var sw = new MyStopWatch(); sw.StartSegment("pc"); PrincipalCurvatureDll.EnableLogging(); int callStatus = PrincipalCurvatureDll.compute_principal_curvature(verticesFlatArray, unaliasedVerticesCount, unaliasedMesh.Triangles, unaliasedTrianglesCount, outDirection1, outDirection2, outValues1, outValues2, radius, useKring); sw.StartSegment("pc2"); Preconditions.Assert(callStatus == 0, "Calling compute_principal_curvature failed, as returned status " + callStatus); //RemapCurvatureData(outDirection1, outDirection2, outValues1, outValues2); var inputVerticesCount = inputMesh.vertices.Length; var outArray = new float[inputVerticesCount * 8]; for (int i = 0; i < unaliasedVerticesCount; i++) { foreach (var inputVerticleIndex in unaliasedMesh.VerticlesToOriginalVerticles[unaliasedMesh.Vertices[i]]) { var outArrayIdx = inputVerticleIndex * 8; var inArrayIdx = i * 3; outArray[outArrayIdx + 0] = outDirection1[inArrayIdx + 0]; outArray[outArrayIdx + 1] = outDirection1[inArrayIdx + 1]; outArray[outArrayIdx + 2] = outDirection1[inArrayIdx + 2]; outArray[outArrayIdx + 3] = outValues1[i]; outArray[outArrayIdx + 4] = outDirection2[inArrayIdx + 0]; outArray[outArrayIdx + 5] = outDirection2[inArrayIdx + 1]; outArray[outArrayIdx + 6] = outDirection2[inArrayIdx + 2]; outArray[outArrayIdx + 7] = outValues2[i]; } } Debug.Log("A22: " + sw.CollectResults()); return(outArray); }
public void Start() { var sw = new MyStopWatch(); sw.StartSegment("TamIdGeneration"); TaskUtils.SetGlobalMultithreading(false); var tonesCount = 3; var levelsCount = 3; var layersCount = 1; var tamTones = TAMTone.CreateList(tonesCount, new Dictionary <int, TAMStrokeOrientation>() { { 0, TAMStrokeOrientation.Horizontal }, { 3, TAMStrokeOrientation.Vertical }, { 5, TAMStrokeOrientation.Both } }); var tamMipmapLevels = TAMMipmapLevel.CreateList(levelsCount); var configuration = TamIdPackGenerationConfiguration .GetDefaultTamIdConfiguration(tamTones, tamMipmapLevels, 1f, layersCount, StrokeImagePath, BlankImagePath, false); configuration.SmallestLevelSoleImageResolution = new IntVector2(256, 256); var packGenerator = new TamIdPackGenerator(); var pack = packGenerator.GenerateTamPack(configuration, false, FindObjectOfType <ComputeShaderContainerGameObject>()); TamIdGeneratorGO.DrawDebugPlates(pack); var fileManager = new TamIdPackFileManager(); Debug.Log("Sw: " + sw.CollectResults()); var tamIdPath = TemporaryImagesPath + TamName + @"\"; Directory.CreateDirectory(tamIdPath); fileManager.Save(tamIdPath, tamTones, tamMipmapLevels, layersCount, pack); }
public void Update() { var newPosition = Camera.main.transform.position; if (!_once) { var msw = new MyStopWatch(); msw.StartSegment("Starting segment."); _once = true; _vegetationRuntimeManagementProxy.Start(newPosition); _vegetationRuntimeManagementProxy.StartThreading(); //_globalInstancingContainer.StartThread(); _debugGrassGroupsGrowerUnderTest.FinalizeStart(); Debug.Log("L8: segment " + msw.CollectResults()); } else { //_globalInstancingContainer.DrawFrame(); _vegetationRuntimeManagementProxy.AddUpdate(newPosition); const int maxMsPerFrame = 4000; //_globalInstancingContainer.FinishUpdateBatch(); } _debugGrassGroupsGrowerUnderTest.Update(); }
public void Compute(ComputeShaderContainerGameObject computeShaderContainer) { TaskUtils.SetGlobalMultithreading(false); _gameInitializationFields.SetField(computeShaderContainer); var msw = new MyStopWatch(); //var queries = RecordingTerrainShapeDb.LoadQueriesFromFile(@"C:\inz\allQueries.json"); //Debug.Log("H8: " + StringUtils.ToString(queries.Select(c => c.QueryArea))); //msw.StartSegment("TerrainDbInitialization"); //InitializeTerrainDb(true); //TestHeightNormalization(); //return; msw.StartSegment("PathPrecomputation"); var pathPrecomputation = new PathPrecomputation(_gameInitializationFields, _precomputationConfiguration, _filePathsConfiguration); //pathPrecomputation.Compute(); pathPrecomputation.Load(); msw.StartSegment("HabitatMapDbPrecomputation"); var habitatMapDbPrecomputation = new HabitatMapDbPrecomputation(_gameInitializationFields, _precomputationConfiguration, _filePathsConfiguration); habitatMapDbPrecomputation.Compute(); habitatMapDbPrecomputation.Load(); //msw.StartSegment("Ring1Precomputation"); //var ring1Precomputation = new Ring1Precomputation(_gameInitializationFields, _precomputationConfiguration, // _filePathsConfiguration); //ring1Precomputation.Compute(); //ring1Precomputation.Load(); //msw.StartSegment("VegetationDatabasePrecomputation"); //var vegetationDatabasePrecomputation = // new VegetationDatabasePrecomputation(_gameInitializationFields, _precomputationConfiguration, _filePathsConfiguration); //vegetationDatabasePrecomputation.Compute(); //msw.StartSegment("Grass2billboardsPrecomputation"); //var grass2BillboardsPrecomputation = new Grass2BillboardsPrecomputer(_gameInitializationFields, _filePathsConfiguration); ////grass2BillboardsPrecomputation.Compute(); //Debug.Log("L8 Precomputation time: "+msw.CollectResults()); }
public void TakeMeasurements(int frameNo, MeasurementScreenshotsSet screenshotsSet) { Debug.Log("R827 RESOLUTION: " + screenshotsSet.HatchMainTexture.Height + " " + screenshotsSet.HatchMainTexture.Width); var msw = new MyStopWatch(); foreach (var gauge in _gauges) { msw.StartSegment(gauge.ToString()); var result = gauge.TakeMeasurement(screenshotsSet); WriteResultsToFile(frameNo, result); } Debug.Log(msw.CollectResults()); }
public float [] Generate(Mesh inputMesh, int radius = 5, bool useKring = true) { var unaliasedGenerator = new UnaliasedMeshGenerator(); var unaliasedMesh = unaliasedGenerator.GenerateUnaliasedMesh(inputMesh); var verticesFlatArray = unaliasedMesh.Vertices.SelectMany(c => VectorUtils.ToArray((Vector3)c)).ToArray(); var unaliasedVerticesCount = unaliasedMesh.Vertices.Length; var unaliasedTrianglesCount = unaliasedMesh.Triangles.Length / 3; var floatsPerVertex = (3 + 1 + 3 + 1 + 4); var unaliasedOutArray = new float[unaliasedVerticesCount * floatsPerVertex]; var sw = new MyStopWatch(); sw.StartSegment("trimesh2_compute_principal_curvature - computing"); PrincipalCurvatureDll.EnableLogging(); int callStatus = PrincipalCurvatureDll.trimesh2_compute_principal_curvature(verticesFlatArray, unaliasedVerticesCount, unaliasedMesh.Triangles, unaliasedTrianglesCount, unaliasedOutArray); sw.StartSegment("trimesh2_compute_principal_curvature - aliasing"); Preconditions.Assert(callStatus == 0, "Calling trimesh2_compute_principal_curvature failed, as returned status " + callStatus); //RemapCurvatureData(outDirection1, outDirection2, outValues1, outValues2); var inputVerticesCount = inputMesh.vertices.Length; var outArray = new float[inputVerticesCount * floatsPerVertex]; for (int i = 0; i < unaliasedVerticesCount; i++) { foreach (var inputVerticleIndex in unaliasedMesh.VerticlesToOriginalVerticles[unaliasedMesh.Vertices[i]]) { for (int j = 0; j < floatsPerVertex; j++) { outArray[inputVerticleIndex * floatsPerVertex + j] = unaliasedOutArray[i * floatsPerVertex + j]; } } } Debug.Log("A22: " + sw.CollectResults()); return(outArray); }
public void Start() { var sw = new MyStopWatch(); sw.StartSegment("TamIdGeneration"); TaskUtils.SetGlobalMultithreading(false); var tonesCount = 5; var levelsCount = 5; var layersCount = 1; var tamTones = TAMTone.CreateList(tonesCount, new Dictionary <int, TAMStrokeOrientation>() { { 0, TAMStrokeOrientation.Horizontal }, { 3, TAMStrokeOrientation.Vertical }, { 5, TAMStrokeOrientation.Both } }); var tamMipmapLevels = TAMMipmapLevel.CreateList(levelsCount); var configuration = TamIdPackGenerationConfiguration .GetDefaultTamIdConfiguration(tamTones, tamMipmapLevels, ExclusionZoneMultiplier, layersCount, StrokeImagePath, BlankImagePath); ScaleStrokesGenerationConfiguration(configuration); configuration.UseSmoothAlpha = SmoothAlpha; var packGenerator = new TamIdPackGenerator(); var pack = packGenerator.GenerateTamPack(configuration, false, FindObjectOfType <ComputeShaderContainerGameObject>()); DrawDebugPlates(pack); var fileManager = new TamIdPackFileManager(); Debug.Log("Sw: " + sw.CollectResults()); if (SaveToFile) { fileManager.Save(TemporaryImagesPath, tamTones, tamMipmapLevels, layersCount, pack); var generator = new TamIdArrayGenerator(); var tex2DArray = generator.Generate(pack, tamTones, tamMipmapLevels, layersCount); tex2DArray.wrapMode = TextureWrapMode.Repeat; if (SmoothAlpha) { tex2DArray.filterMode = FilterMode.Trilinear; } MyAssetDatabase.CreateAndSaveAsset(tex2DArray, $"Assets/Generated/{AssetName}.asset"); } }
public IMeasurementResult TakeMeasurement(MeasurementScreenshotsSet inputSet) { Vector3[,] positionsArray = GeneratePositionsArray(inputSet.WorldPosition1Texture, inputSet.WorldPosition2Texture); var idArray = inputSet.IdArray; var occurenceArray = inputSet.HatchOccurenceArray; var samplesDict = GenerateSamplesDict(positionsArray, idArray, inputSet.HatchMainTexture, occurenceArray); var msw = new MyStopWatch(); msw.StartSegment("Curve calc"); var curves = CalculateCurves(samplesDict); //Debug.Log(msw.CollectResults()); return(new LinesLayoutResult() { WorldSpacePositionsArray = positionsArray, Curves = curves, Samples = samplesDict }); }
public void Start() { _once = new RunOnceBox(() => { var sw = new MyStopWatch(); sw.StartSegment("TamIdGeneration"); TaskUtils.SetGlobalMultithreading(false); var tonesCount = 2; var levelsCount = 4; var layersCount = 2; var tamTones = TAMTone.CreateList(tonesCount, new Dictionary <int, TAMStrokeOrientation>() { { 0, TAMStrokeOrientation.Horizontal }, { 3, TAMStrokeOrientation.Vertical }, { 5, TAMStrokeOrientation.Both } }); var tamMipmapLevels = TAMMipmapLevel.CreateList(levelsCount); var configuration = TamIdPackGenerationConfiguration .GetDefaultTamIdConfiguration(tamTones, tamMipmapLevels, 1f, layersCount, StrokeImagePath, BlankImagePath); var packGenerator = new TamIdPackGenerator(); var pack = packGenerator.GenerateTamPack(configuration, false, FindObjectOfType <ComputeShaderContainerGameObject>()); var fileManager = new TamIdPackFileManager(); Debug.Log("Sw: " + sw.CollectResults()); fileManager.Save(@"C:\mgr\tmp\tamid1\", tamTones, tamMipmapLevels, layersCount, pack); var generator = new TamIdArrayGenerator(); var tex2DArray = generator.Generate(pack, tamTones, tamMipmapLevels, layersCount); TamIdArray = tex2DArray; var tamIdPostProcessingDirectorOc = FindObjectOfType <TamIdPostProcessingDirectorOC>(); var mat = GetComponent <MeshRenderer>().material; TamIdArray.filterMode = FilterMode.Point; mat.SetTexture("_TamIdTexArray", TamIdArray); mat.SetBuffer("_AppendBuffer", tamIdPostProcessingDirectorOc.TamidFragmentBuffer); mat.SetInt("_FragmentTexWidth", tamIdPostProcessingDirectorOc.FragmentTexWidth); }); }
public void Start() { var msw = new MyStopWatch(); msw.StartSegment("Start"); TaskUtils.ExecuteActionWithOverridenMultithreading(true, () => { _feConfiguration = new FEConfiguration(new FilePathsConfiguration()) { Multithreading = Multithreading }; _feConfiguration.EngraveTerrainFeatures = true; _feConfiguration.EngraveRoadsInTerrain = true; _feConfiguration.TerrainShapeDbConfiguration.UseTextureLoadingFromDisk = true; _feConfiguration.TerrainShapeDbConfiguration.UseTextureSavingToDisk = false; _feConfiguration.TerrainShapeDbConfiguration.MergeTerrainDetail = true; var containerGameObject = GameObject.FindObjectOfType <ComputeShaderContainerGameObject>(); VegetationConfiguration.FeConfiguration = _feConfiguration; _heightmapListenersContainer = new HeightmapSegmentFillingListenersContainer(); _gameInitializationFields = new GameInitializationFields(); _updaterUntilException = new UpdaterUntilException(); _movementCustodian = new TravellerMovementCustodian(Traveller); _gameInitializationFields.SetField(_movementCustodian); _ultraUpdatableContainer = ETerrainTestUtils.InitializeFinalElements(_feConfiguration, containerGameObject, _gameInitializationFields, initializeLegacyDesignBodySpotUpdater: false); var startConfiguration = ETerrainHeightPyramidFacadeStartConfiguration.DefaultConfiguration; var initializingHelper = InitializeETerrain(startConfiguration); initializingHelper.InitializeUTService(new UnityThreadComputeShaderExecutorObject()); InitializeUI(startConfiguration); Traveller.transform.position = new Vector3(startConfiguration.InitialTravellerPosition.x, Traveller.transform.position.y, startConfiguration.InitialTravellerPosition.y); }); Debug.Log("Init time " + msw.CollectResults()); _initializationWasSuccessfull = true; }
public void StartDiagram() { var tonesCount = 4; var levelsCount = 4; TaskUtils.SetGlobalMultithreading(false); var tones = TAMTone.GenerateList(tonesCount, 3, 4); var levels = TAMMipmapLevel.CreateList(levelsCount); var tamPackGenerator = new TAMPackGenerator(); var msw = new MyStopWatch(); msw.StartSegment("Gen"); var pack = tamPackGenerator.GenerateTamPack(GenerateDiagramConfiguration(tones, levels, 0.7f), true, Object.FindObjectOfType <ComputeShaderContainerGameObject>()); Debug.Log(msw.CollectResults()); var fileManager = new TAMPackFileManager(); fileManager.Save(@"C:\mgr\tmp\tam2\", tones, levels, pack); }
public List <HeightmapArray> GenerateErodedArrays(HeightmapArray baseArray, List <MeiHydraulicEroderConfiguration> configurations) { var msw = new MyStopWatch(); List <HeightmapArray> outArray = new List <HeightmapArray>(); int i = 0; foreach (var aConfiguration in configurations) { var copyArray = MyArrayUtils.DeepClone(baseArray.HeightmapAsArray); var currentHeightArray = new SimpleHeightArray(copyArray); msw.StartSegment("eroding-" + i); var eroder = new MeiHydraulicEroder(); eroder.Erode(currentHeightArray, aConfiguration); msw.StopSegment(); outArray.Add(SimpleHeightArray.ToHeightmap(currentHeightArray)); i++; } Debug.Log("T22: " + msw.CollectResults()); return(outArray); }
public void Start() { _once = new RunOnceBox(() => { FindObjectOfType <LineMeasuringPpDirectorOc>().RequireScreenshotsSet((screenshotsSet) => { var gauge = new StrokesPixelCountGauge(); var sw = new MyStopWatch(); sw.StartSegment("PixelCountTime"); var result = gauge.TakeMeasurement(screenshotsSet); var debIllustration = result.GenerateIllustration(); var poco = result.GeneratePoco(); Debug.Log(sw.CollectResults()); Debug.Log(JsonUtility.ToJson(poco)); File.WriteAllText(@"C:\mgr\tmp\pixelCount.json", JsonUtility.ToJson(poco)); var ppDirector = FindObjectOfType <DebugIllustrationPPDirectorOC>(); ppDirector.ShowIllustrations(screenshotsSet.HatchMainTexture.ToTexture2D(), debIllustration); }); }, 4); }
private void MakeMeasurement() { if (!_gauges.Any()) { return; } var msw = new MyStopWatch(); var lastTestFrame = OneTestConfiguration.TestFramesCount + OneTestConfiguration.FirstTestFrame; msw.StartSegment($"Test {OneTestConfiguration.TestName} frame {_requestedTestFrame} = {_requestedTestFrame-OneTestConfiguration.FirstTestFrame}/{lastTestFrame}"); MeasurementScreenshotsSet set = _lineMeasuringModule.OnRenderImageGenerateScreenshots(); var measurementResults = new List <IMeasurementResult>(); foreach (var aGauge in _gauges) { var measurementResult = aGauge.TakeMeasurement(set); measurementResults.Add(measurementResult); } _runnerSupports.ForEach(c => c.MyOnMeasurementsMade(measurementResults, set)); Debug.Log(msw.CollectResults()); }
// Use this for initialization void Start() { _configuration = new FEConfiguration(new FilePathsConfiguration()) { Multithreading = UseMultithreading }; _configuration.TerrainShapeDbConfiguration = TerrainShapeDbConfiguration; FeGRingConfiguration.FeConfiguration = _configuration; VegetationConfiguration.FeConfiguration = _configuration; TaskUtils.SetGlobalMultithreading(_configuration.Multithreading); TaskUtils.ExecuteActionWithOverridenMultithreading(true, () => { MyProfiler.BeginSample("Sample1"); msw.StartSegment("Game initialization"); GlobalServicesProfileInfo servicesProfileInfo = new GlobalServicesProfileInfo(); if (GraphicsOverlay != null) { GraphicsOverlay.ServicesProfileInfo = servicesProfileInfo; } _ultraUpdatableContainer = new UltraUpdatableContainer( _configuration.SchedulerConfiguration, servicesProfileInfo, _configuration.UpdatableContainerConfiguration); _configuration.TerrainShapeDbConfiguration.UseTextureSavingToDisk = true; _gameInitializationFields.SetField(ContainerGameObject); _gameInitializationFields.SetField(_configuration.Repositioner); _gameInitializationFields.SetField(_configuration.HeightDenormalizer); var initializingHelper = new FEInitializingHelper(_gameInitializationFields, _ultraUpdatableContainer, _configuration); initializingHelper.InitializeUTService(new TextureConcieverUTProxy()); initializingHelper.InitializeUTService(new UnityThreadComputeShaderExecutorObject(_configuration.UseMultistepComputeShaderExecution)); initializingHelper.InitializeUTService(new CommonExecutorUTProxy()); initializingHelper.CreatePathProximityTextureDb(); SetInitialCameraPosition(); initializingHelper.InitializeDesignBodySpotUpdater(); initializingHelper.InitializeUTRendererProxy(); initializingHelper.InitializeUTService(new MeshGeneratorUTProxy(new MeshGeneratorService())); initializingHelper.InitializeMonoliticRing2RegionsDatabase(); var finalSurfacePathInitialization = new Ring2PatchInitializer(_gameInitializationFields, _ultraUpdatableContainer, new Ring2PatchInitializerConfiguration(_configuration)); finalSurfacePathInitialization.Start(); var finalTerrainInitialization = new FinalTerrainInitialization(_ultraUpdatableContainer, _gameInitializationFields, _configuration, FeGRingConfiguration); finalTerrainInitialization.Start(); initializingHelper.InitializeGlobalInstancingContainer(); var finalVegetation = new FinalVegetation(_gameInitializationFields, _ultraUpdatableContainer, VegetationConfiguration); finalVegetation.Start(); }); MyProfiler.EndSample(); }
public void Start() { var meshGenerator = new GrassMeshGenerator(); var mesh = meshGenerator.GetGrassBladeMesh(1); var material = new Material(Shader.Find("Custom/Vegetation/Grass")); material.SetFloat("_BendingStrength", 0.2f); material.SetFloat("_InitialBendingValue", 0.4f); material.SetFloat("_PlantBendingStiffness", 0.3f); material.SetVector("_WindDirection", Vector4.one); material.SetVector("_PlantDirection", Vector4.one); material.SetColor("_Color", Color.green); material.SetFloat("_RandSeed", 44.4f); var go = GameObject.CreatePrimitive(PrimitiveType.Capsule); go.GetComponent <MeshFilter>().mesh = mesh; go.GetComponent <MeshRenderer>().material = material; var instancingMaterial = new Material(Shader.Find("Custom/Vegetation/Grass.Instanced")); instancingMaterial.enableInstancing = true; _globalGpuInstancingContainer = new GlobalGpuInstancingContainer(); var commonUniforms = new UniformsPack(); commonUniforms.SetUniform("_BendingStrength", 0.8f); commonUniforms.SetUniform("_WindDirection", Vector4.one); var instancingContainer = new GpuInstancingVegetationSubjectContainer( new GpuInstancerCommonData(mesh, instancingMaterial, commonUniforms), new GpuInstancingUniformsArrayTemplate(new List <GpuInstancingUniformTemplate>() { new GpuInstancingUniformTemplate("_Color", GpuInstancingUniformType.Vector4), new GpuInstancingUniformTemplate("_InitialBendingValue", GpuInstancingUniformType.Float), new GpuInstancingUniformTemplate("_PlantBendingStiffness", GpuInstancingUniformType.Float), new GpuInstancingUniformTemplate("_PlantDirection", GpuInstancingUniformType.Vector4), new GpuInstancingUniformTemplate("_RandSeed", GpuInstancingUniformType.Float), }) ); var bucketId = _globalGpuInstancingContainer.CreateBucket(instancingContainer); var uniforms = new UniformsPack(); uniforms.SetUniform("_InitialBendingValue", 0.4f); uniforms.SetUniform("_PlantBendingStiffness", 0.3f); uniforms.SetUniform("_PlantDirection", Vector4.one); uniforms.SetUniform("_Color", Color.green); uniforms.SetUniform("_RandSeed", 44.4f); var msw = new MyStopWatch(); msw.StartSegment("AddingClassic"); for (int x = 0; x < 300; x++) { for (int y = 0; y < 300; y++) { var myTriplet = new MyTransformTriplet(new Vector3(x, 0, y), Vector3.zero, Vector3.one); _globalGpuInstancingContainer.AddInstance(bucketId, myTriplet.ToLocalToWorldMatrix(), uniforms); } } _globalGpuInstancingContainer.StartThread(); _globalGpuInstancingContainer.FinishUpdateBatch(); Debug.Log("It took: " + msw.CollectResults()); }
public void Start() { TaskUtils.SetGlobalMultithreading(false); var generationArea = new MyRectangle(0, 0, 100, 100); var generationCount = 7; var exRadius = 2; var msw = new MyStopWatch(); var randomFigureGenerator = new RandomFieldFigureGeneratorUTProxy( new Ring2RandomFieldFigureGenerator(new TextureRenderer(), new Ring2RandomFieldFigureGeneratorConfiguration() { PixelsPerUnit = new Vector2(1, 1) })); var randomFigure = randomFigureGenerator.GenerateRandomFieldFigureAsync( RandomFieldNature.FractalSimpleValueNoise3, 312, new MyRectangle(0, 0, 30, 30)).Result; //var intensityFigureProvider = new IntensityFromRandomFigureProvider(randomFigure); //var intensityFigureProvider = new IntensityFromRandomFigureProvider(CreateDebugRandomFieldFigure()); var intensityFigureProvider = new IntensityFromRandomFiguresCompositionProvider( CreateDebugRandomFieldFigure(), randomFigure, 0.3f); msw.StartSegment("StartGeneration"); var sampler = new MultiIntensityPoissonDiskSampler(); var generatedPoints = sampler.Generate(generationArea, generationCount, new MyRange(0.5f, 3), new IntensityFromRandomFigureProvider(new IntensityFieldFigureWithUv() { FieldFigure = randomFigure, Uv = new MyRectangle(0, 0, 1, 1) }), 100000); //var noCollision = new NoCollisionMultiIntensityPoissonDiskSampler(); //var generatedPoints = noCollision.Generate(generationArea, generationCount, 2,80000, 6, intensityFigureProvider); //var classicPoisson = new PoissonDiskSampler(); //var generatedPoints = classicPoisson.Generate(generationArea, generationCount, exRadius); //var simpleCollidable = new SimpleRandomSampler(); //var generatedPoints = simpleCollidable.Generate(generationArea, 15000, 40000, 0.1f, false, intensityFigureProvider); Debug.Log($"T{generatedPoints.Count} generation took: " + msw.CollectResults()); var root = new GameObject("RootPoints"); foreach (var point in generatedPoints) { var cap = GameObject.CreatePrimitive(PrimitiveType.Capsule); cap.transform.position = new Vector3(point.x, 0, point.y); cap.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); cap.transform.SetParent(root.transform); } var newMaterial = new Material(Shader.Find("Standard")); newMaterial.SetTexture("_MainTex", Ring2RandomFieldFigureGenerator.DebugLastGeneratedTexture); DebugTextureObject.GetComponent <MeshRenderer>().material = newMaterial; }