void Start() { _sourceTexture = new RenderTexture(256, 256, 0); _resultTexture = new RenderTexture(256, 256, 0); _sourceTexture.filterMode = FilterMode.Point; _resultTexture.enableRandomWrite = true; _sourceTexture.Create(); _resultTexture.Create(); Graphics.Blit(_defaultTexture, _sourceTexture); _sourceRenderer.material.mainTexture = _sourceTexture; _resultRenderer.material.mainTexture = _resultTexture; _lineMaterial = new Material(_shader); _lineMaterial.color = Color.black; _lineMesh = new Mesh(); _lineMesh.MarkDynamic(); _lineMesh.vertices = new Vector3[2]; _lineMesh.SetIndices(new[] { 0, 1 }, MeshTopology.Lines, 0); _eraserMaterial = new Material(_shader); _eraserMaterial.color = Color.white; _eraserMesh = new Mesh(); _eraserMesh.MarkDynamic(); _eraserMesh.vertices = new Vector3[4]; _eraserMesh.SetIndices(new[] { 0, 1, 2, 1, 3, 2 }, MeshTopology.Triangles, 0); _weightTable = WeightReader.ReadFromFile(Path.Combine(Application.streamingAssetsPath, _weightFileName)); _sourceTensor = new Tensor(new[] { 256, 256, 3 }); }
void Start() { var weights = Path.Combine(Application.streamingAssetsPath, _weightFileName); var stopwatch = new System.Diagnostics.Stopwatch(); stopwatch.Start(); var result = ImageFilter.Deprocess( Generator.Apply( ImageFilter.Preprocess(_sourceTexture), WeightReader.ReadFromFile(weights) ) ); stopwatch.Stop(); Debug.Log("Done. Total inference time is " + stopwatch.Elapsed); GetComponent <MeshRenderer>().material.mainTexture = result; }