public void Start() { var ring2ShaderRepository = Ring2PlateShaderRepository.Create(); var conciever = _gameInitializationFields.Retrive <TextureConcieverUTProxy>(); var detailEnhancer = new Ring2IntensityPatternEnhancer(_gameInitializationFields.Retrive <UTTextureRendererProxy>(), _ring2InitializerConfiguration.Ring2IntensityPatternEnhancingSizeMultiplier); var ring2PatchesPainterUtProxy = new Ring2PatchesPainterUTProxy(new Ring2PatchesPainter( new Ring2MultishaderMaterialRepository(ring2ShaderRepository, Ring2ShaderNames.ShaderNames))); _ultraUpdatableContainer.Add(ring2PatchesPainterUtProxy); var patchesCreator = new GRing2PatchesCreator( _gameInitializationFields.Retrive <IRing2RegionsDatabase>(), new GRing2RegionsToPatchTemplateConventer(), new Ring2PatchTemplateCombiner(), new Ring2PatchCreator(), new Ring2IntensityPatternProvider(conciever, detailEnhancer), new GRing2Deviser(), _ring2InitializerConfiguration.Ring2PatchesOverseerConfiguration ); var gRing2PatchesCreatorProxy = new GRing2PatchesCreatorProxy(patchesCreator); _ultraUpdatableContainer.AddOtherThreadProxy(gRing2PatchesCreatorProxy); _gameInitializationFields.SetField(gRing2PatchesCreatorProxy); UTRing2PlateStamperProxy stamperProxy = new UTRing2PlateStamperProxy( new Ring2PlateStamper(_ring2InitializerConfiguration.Ring2PlateStamperConfiguration, _gameInitializationFields.Retrive <ComputeShaderContainerGameObject>())); _ultraUpdatableContainer.Add(stamperProxy); Ring2PatchStamplingOverseerFinalizer patchStamper = new Ring2PatchStamplingOverseerFinalizer( stamperProxy, _gameInitializationFields.Retrive <UTTextureRendererProxy>(), _gameInitializationFields.Retrive <CommonExecutorUTProxy>()); _gameInitializationFields.SetField(patchStamper); }
public static ESurfacePatchProvider ConstructProvider(UltraUpdatableContainer updatableContainer, Dictionary <int, float> intensityPatternPixelsPerUnit, ComputeShaderContainerGameObject shaderContainerGO, int mipmapLevelToExtract, Dictionary <int, float> plateStampPixelsPerUnit) { var ring2ShaderRepository = Ring2PlateShaderRepository.Create(); TextureConcieverUTProxy conciever = new TextureConcieverUTProxy(); updatableContainer.Add(conciever); var ring2PatchesPainterUtProxy = new Ring2PatchesPainterUTProxy( new Ring2PatchesPainter( new Ring2MultishaderMaterialRepository(ring2ShaderRepository, Ring2ShaderNames.ShaderNames))); updatableContainer.Add(ring2PatchesPainterUtProxy); UTRing2PlateStamperProxy stamperProxy = new UTRing2PlateStamperProxy( new Ring2PlateStamper(new Ring2PlateStamperConfiguration() { PlateStampPixelsPerUnit = plateStampPixelsPerUnit }, shaderContainerGO)); updatableContainer.Add(stamperProxy); UTTextureRendererProxy textureRendererProxy = new UTTextureRendererProxy(new TextureRendererService( new MultistepTextureRenderer(shaderContainerGO), new TextureRendererServiceConfiguration() { StepSize = new Vector2(500, 500) })); updatableContainer.Add(textureRendererProxy); CommonExecutorUTProxy commonExecutorUtProxy = new CommonExecutorUTProxy(); //todo updatableContainer.Add(commonExecutorUtProxy); Ring2PatchStamplingOverseerFinalizer patchStamperOverseerFinalizer = new Ring2PatchStamplingOverseerFinalizer(stamperProxy, textureRendererProxy, commonExecutorUtProxy); MipmapExtractor mipmapExtractor = new MipmapExtractor(textureRendererProxy); var patchesCreatorProxy = new GRing2PatchesCreatorProxy(CreateRing2PatchesCreator(updatableContainer, intensityPatternPixelsPerUnit)); return(new ESurfacePatchProvider(patchesCreatorProxy, patchStamperOverseerFinalizer, commonExecutorUtProxy, mipmapExtractor, mipmapLevelToExtract)); }
// Use this for initialization void Start() { _updatableContainer = new UpdatableContainer(); TaskUtils.SetGlobalMultithreading(false); _ring1Tree = new Ring1Tree(); ////////////////// var rgbaMainTexture = SavingFileManager.LoadPngTextureFromFile(@"C:\inz\cont\n49_e019_1arc_v3.png", 3600, 3600, TextureFormat.ARGB32, true, false); CommonExecutorUTProxy commonExecutorUtProxy = new CommonExecutorUTProxy(); //todo _updatableContainer.AddUpdatableElement(commonExecutorUtProxy); TerrainTextureFormatTransformator transformator = new TerrainTextureFormatTransformator(commonExecutorUtProxy); var globalHeightTexture = transformator.EncodedHeightTextureToPlain(new TextureWithSize() { Size = new IntVector2(3600, 3600), Texture = rgbaMainTexture }); /// /// VISIBILITY TEXTURE var visibilityTextureSideLength = 16; var visibilityTexture = new Texture2D(visibilityTextureSideLength, visibilityTextureSideLength, TextureFormat.RFloat, false); visibilityTexture.filterMode = FilterMode.Point; var visibilityTextureProcessorProxy = new Ring1VisibilityTextureProcessorUTProxy(new Ring1VisibilityTextureProcessor(visibilityTexture)); _updatableContainer.AddUpdatableElement(visibilityTextureProcessorProxy); var visibilityTextureChangeGrabber = new Ring1VisibilityTextureChangeGrabber(); var terrainParentGameObject = new GameObject("TerrainParent"); var unityCoordsCalculator = new UnityCoordsCalculator(new Vector2(24 * 240 * 2, 24 * 240 * 2)); var orderGrabber = new Ring1PaintingOrderGrabber(); var painterProxy = new RingTerrainPainterUTProxy(new RingTerrainPainter()); _updatableContainer.AddUpdatableElement(painterProxy); painterProxy.Update(); var mainRespondingProxy = new Ring1NodeEventMainRespondingProxy(new Ring1NodeEventMainResponder()); _otherThreadActionPairs.Add(new OtherThreadProxyAndActionPair() { Proxy = mainRespondingProxy, EveryPostAction = () => { var delta = visibilityTextureChangeGrabber.RetriveVisibilityChanges(); if (delta.AnyChange) { var visibilityTextureChagnes = visibilityTextureChangeGrabber.RetriveVisibilityChanges(); visibilityTextureProcessorProxy.AddOrder(visibilityTextureChagnes); } if (orderGrabber.IsAnyOrder) { painterProxy.AddOrder(orderGrabber.RetriveOrderAndClear()); } } }); UTTextureRendererProxy textureRendererProxy = new UTTextureRendererProxy(new TextureRendererService( new MultistepTextureRenderer(ContainerGameObject), new TextureRendererServiceConfiguration() { StepSize = new Vector2(500, 500) })); _updatableContainer.AddUpdatableElement(textureRendererProxy); UnityThreadComputeShaderExecutorObject computeShaderExecutorObject = new UnityThreadComputeShaderExecutorObject(); _updatableContainer.AddUpdatableElement(computeShaderExecutorObject); _updatableContainer.AddUpdatableElement(commonExecutorUtProxy); TerrainDetailGenerator terrainDetailGenerator = CreateTerrainDetailGenerator( globalHeightTexture, textureRendererProxy, commonExecutorUtProxy, computeShaderExecutorObject, ContainerGameObject); TerrainDetailProvider terrainDetailProvider = CreateTerrainDetailProvider(terrainDetailGenerator); var terrainShapeDb = FETerrainShapeDbInitialization.CreateTerrainShapeDb(terrainDetailProvider, commonExecutorUtProxy , new TerrainDetailAlignmentCalculator(240), false, false, false, null); TerrainShapeDbProxy terrainShapeDbProxy = new TerrainShapeDbProxy(terrainShapeDb); terrainDetailGenerator.SetBaseTerrainDetailProvider(BaseTerrainDetailProvider.CreateFrom(terrainShapeDb)); _otherThreadActionPairs.Add(new OtherThreadProxyAndActionPair() { Proxy = terrainShapeDbProxy }); var meshGeneratorProxy = new MeshGeneratorUTProxy(new MeshGeneratorService()); _updatableContainer.AddUpdatableElement(meshGeneratorProxy); _stainTerrainResourceCreatorUtProxy = new StainTerrainResourceCreatorUTProxy(new StainTerrainResourceCreator()); _updatableContainer.AddUpdatableElement(_stainTerrainResourceCreatorUtProxy); var stainTerrainServiceProxy = new StainTerrainServiceProxy( new StainTerrainService( new ComputationStainTerrainResourceGenerator( new StainTerrainResourceComposer( _stainTerrainResourceCreatorUtProxy ), new StainTerrainArrayMelder(), new DummyStainTerrainArrayFromBiomesGenerator( new DebugBiomeContainerGenerator().GenerateBiomesContainer( new BiomesContainerConfiguration()), new StainTerrainArrayFromBiomesGeneratorConfiguration() )), new MyRectangle(0, 0, 24 * 240 * 2, 24 * 240 * 2))); _otherThreadActionPairs.Add(new OtherThreadProxyAndActionPair() { Proxy = stainTerrainServiceProxy }); var gRing1NodeTerrainCreator = new GRing1NodeTerrainCreator( orderGrabber, terrainParentGameObject, meshGeneratorProxy, terrainShapeDbProxy, stainTerrainServiceProxy, unityCoordsCalculator, null, null, new GRingGroundShapeProviderConfiguration(), new GRingTerrainMeshProviderConfiguration()); var gRing2NodeTerrainCreator = new GRing2NodeTerrainCreator( orderGrabber, terrainParentGameObject, meshGeneratorProxy, terrainShapeDbProxy, unityCoordsCalculator, new GRing2PatchesCreatorProxy(CreateRing2PatchesCreator()), null, null, new GRingGroundShapeProviderConfiguration(), new GRingTerrainMeshProviderConfiguration()); UTRing2PlateStamperProxy stamperProxy = new UTRing2PlateStamperProxy( new Ring2PlateStamper(new Ring2PlateStamperConfiguration() { PlateStampPixelsPerUnit = new Dictionary <int, float>() }, ContainerGameObject)); _updatableContainer.AddUpdatableElement(stamperProxy); Ring2PatchStamplingOverseerFinalizer patchStamper = new Ring2PatchStamplingOverseerFinalizer(stamperProxy, textureRendererProxy, commonExecutorUtProxy); var gStampedRing2NodeTerrainCreator = new GStampedRing2NodeTerrainCreator( orderGrabber, terrainParentGameObject, meshGeneratorProxy, terrainShapeDbProxy, unityCoordsCalculator, new GRing2PatchesCreatorProxy(CreateRing2PatchesCreator()), patchStamper, null, null, new GRingGroundShapeProviderConfiguration(), new GRingTerrainMeshProviderConfiguration()); var subCreator = new SupremeGRingNodeTerrainCreator(new List <NewListenersCreatorWithLimitation>() { //new NewListenersCreatorWithMaximumLod() //{ // Creator = gRing1NodeTerrainCreator, // MaximumLod = new FlatLod(6) //}, new NewListenersCreatorWithLimitation() { Creator = new GVoidNodeTerrainCreator(), MaximumLod = new FlatLod(6) }, //new NewListenersCreatorWithMaximumLod() //{ // Creator = gRing2NodeTerrainCreator, // MaximumLod = new FlatLod(8) //} new NewListenersCreatorWithLimitation() { Creator = gStampedRing2NodeTerrainCreator, MaximumLod = new FlatLod(9) } }); var eventCollector = new Ring1NodeEventCollector( new DynamicFlatLodGRingNodeTerrainCreator(subCreator, new FlatLodCalculator(unityCoordsCalculator))); _ring1TreeProxy = new Ring1TreeProxy(_ring1Tree); _otherThreadActionPairs.Add(new OtherThreadProxyAndActionPair() { Proxy = _ring1TreeProxy, EveryPostAction = () => { if (eventCollector.Any) { mainRespondingProxy.AddOrder(eventCollector.RetriveOrderAndClear()); } } }); var baseQuadSideLength = 90f; StartThreading(_otherThreadActionPairs); _ring1TreeProxy.CreateHeightmap(new Ring1Tree.RootNodeCreationParameters() { UnityCoordsCalculator = unityCoordsCalculator, NodeListener = eventCollector, PrecisionDistances = new Dictionary <float, int> { //{4f * 50f/3f, 9}, //{4f * 50f/2f, 8}, { CalculatePrecisionDistance(baseQuadSideLength, 2, 1), 7 }, { 6.5f * 50f, 6 }, { 20 * 50f, 5 }, { 40 * 50f, 4 }, { 50 * 50f, 3 }, { 100 * 50f, 2 }, { 200 * 50f, 1 } }, InitialCameraPosition = Vector3.zero, }); }