u/RobertWetzold

▲ 291 r/Unity3D

Wrote SDF shaders for the first time for round corners

I had honestly never used SDFs before, but now I’m a fan. Instead of building extra meshes, masks, or corner textures, the shader just calculates the signed distance to the shape edge and uses that for the fill, border, radius, and antialiasing.

The nice part is how flexible it gets: same base shader, different corner radii, crisp scaling, soft edges, outlines, clipping, etc. A rounded rect is basically just math, and the GPU does the boring part.

It’s one of those things where the concept sounds fancy, but once it clicks, it actually makes the whole UI/rendering side simpler.

u/RobertWetzold — 2 days ago
▲ 2 r/UnityAssets+1 crossposts

I love Apple Swift Charts, so I fully rebuilt them in Unity the last 10 months

Finally. This has been in the making for the last 10 months and I didn't tell a soul. My personal mammoth project.

I used to develop professional realtime financial charting software back in 2001, spent 10 years on it. These days I was not happy with the charting solutions that Unity had so far. They are mostly hobbyist, overly flashy, convoluted or deprecated.

I personally love how Apple does charting. Swift charts are incredibly thoughtful, have great defaults, an amazing API and are so versatile, all on a single conceptually sound architecture. For Unity that was missing so far.

Until now. I present: Chart Guru - a nearly 100% compatible Swift Charts implementation, from defaults to look and feel, and API down to the last modifier and overload. This is enterprise-grade charting at your fingertips.

The whole package is hyper-optimized, has near-zero GC, works with canvas, IMGUI & UI toolkit. In BIRP, URP and HDRP. There are more than 40 sample scenes. Many data sources come bundled in, like Yahoo finance, Json/CSV etc.

The hardest parts were not the rendering bits I expected. Drawing bars, lines, pies, axes, labels, etc. is a lot of work, but it’s at least straightforward work. The weird part was trying to bring over the feel of Swift Charts into Unity without just making a strange C# imitation of Swift.

Swift Charts leans heavily on SwiftUI. You get layout, modifiers, animation behavior, view composition, accessibility, all that stuff as part of the ecosystem. Unity is a very different beast: components, serialized fields, editor tooling, uGUI, UI Toolkit, render pipelines, play mode, GC spikes. So “parity” turned into a lot of judgment calls. What should map directly? What should be Unity-native? What is just SwiftUI magic that does not make sense here?

The Swift importer was probably the biggest rabbit hole. I wanted to paste in Swift Charts-ish snippets and turn them into Chart Guru C#. That means understanding things like .chartXAxis, .foregroundStyle, .value, AxisMarks, gradients, dates, closures, nested modifiers, ordering, defaults, etc. It’s not a full Swift compiler, obviously, but it also very quickly stopped being “just some regex.”

Performance has also been a constant fight. Charts seem simple until they’re live-updating. Then every axis tick, label, legend item, tooltip, stacked layout, transition, and data-label animation becomes a possible tiny allocation. A lot of the work ended up being scratch buffers, pooling, stable mark updates, cached formatted strings, and tests to make sure warmed-up runtime paths stay at zero managed allocations.

I am super happy with how it turned out. If you think that sounds like a useful tool, check out Chart Guru on the Asset Store :-) Looking forward to all feedback and suggestions!

u/RobertWetzold — 12 days ago
▲ 44 r/Unity3D

Having Fun with Realtime Mesh Generation

That part has honestly been one of my favorite technical bits to work on.

At the base it’s just a panel grid: rows, columns, panel size, gaps, orientation. Then Unity builds the actual mesh at runtime with the usual stuff like Mesh, SetVertices, SetTriangles, SetUVs, SetNormals, and RecalculateBounds.

For a flat wall, that’s pretty simple. The fun starts when the same grid gets bent around an arc or wrapped into a cylinder. For inward-facing cylinders, the triangle winding and normals have to flip, otherwise backface culling and lighting/shader assumptions get weird pretty quickly.

A lot of the work is in the small annoying details: keeping UVs stable when the panel count changes, avoiding seams where a cylinder closes, making sure curved panels still line up, and packing extra data into UV channels or vertex colors so the shader knows how to draw the LED/pixel behavior on top.

It’s one of those Unity features I really appreciate. You’re not stuck with imported meshes. If the layout changes, just rebuild the mesh. If the topology changes, remap the vertices. If the shader needs more info, push it through another mesh stream. Procedural meshes + custom shaders are a surprisingly nice combo for previewing real LED stage setups.

u/RobertWetzold — 17 days ago