// Render material public Texture2D renderMaterial(Material material, List<Vector2> polygonPoints, float growthFactor, bool trimTransparentEdges) { // Calculate width and height Vector2 topLeft = polygonPoints[0]; Vector2 bottomRight = polygonPoints[0]; foreach (Vector2 polygonPoint in polygonPoints) { topLeft = Vector2.Min(topLeft, polygonPoint); bottomRight = Vector2.Max(bottomRight, polygonPoint); } // Create canvas Texture2D canvas = createCanvas((int)((bottomRight.X - topLeft.X) * Settings.BASE_SCALE), (int)((bottomRight.Y - topLeft.Y) * Settings.BASE_SCALE)); // Recursively render layers canvas = recursiveRenderLayers(canvas, polygonPoints, growthFactor, material.rootLayer); // Trim transparent edges if (trimTransparentEdges) canvas = this.trimTransparentEdges(canvas); return canvas; }
private void renderSelectedMaterial() { XElement data = ResourceManager.materialResources[_selectedIndex]; Material material = new Material(data); _materialTexture = _materialRenderer.renderMaterial(material, _drawOnPolygon ? _polygonPoints : _screenPoints, 1f, false); }