public void Compute() { var generator = new Grass2BillboardGenerator( new UTTextureRendererProxy(new TextureRendererService( new MultistepTextureRenderer(_gameInitializationFields.Retrive <ComputeShaderContainerGameObject>()), new TextureRendererServiceConfiguration() { StepSize = new Vector2(10, 10) })), _billboardsConfuguration.BillboardGeneratorConfiguration); var clansGenerator = new Grass2BillboardClanGenerator(generator, _billboardsConfuguration.ClanGeneratorConfiguration); var clan = clansGenerator.Generate(); var fileManager = new Grass2BillboardClanFilesManager(); fileManager.Save(_pathsConfiguration.Grass2BillboardsPath, clan); }
public void Start2() { TaskUtils.SetGlobalMultithreading(false); var meshGenerator = new GrassMeshGenerator(); var mesh = meshGenerator.GetGrassBillboardMesh(0, 1); var generator = new Grass2BillboardGenerator(new UTTextureRendererProxy(new TextureRendererService( new MultistepTextureRenderer(ComputeShaderContainer), new TextureRendererServiceConfiguration() { StepSize = new Vector2(10, 10) })), new Grass2BillboardGenerator.Grass2BillboardGeneratorConfiguration() { BillboardSize = new IntVector2(256, 256) }); var tex = generator.GenerateBillboardImageAsync(40, 1).Result; tex.filterMode = FilterMode.Point; var material = new Material(Shader.Find("Custom/Vegetation/GrassBushBillboard")); material.SetTexture("_MainTex", tex); for (int x = 0; x < 30; x++) { for (int y = 0; y < 30; y++) { var go = GameObject.CreatePrimitive(PrimitiveType.Capsule); go.transform.localPosition = new Vector3(x, 0, y); go.GetComponent <MeshFilter>().mesh = mesh; go.GetComponent <MeshRenderer>().material = material; } } }