Learning New Tricks With LeoCAD and Blender


Let’s explore new ways to building LEGO renders using some old tools.

On Monday, I decided to hack around with Blender a bit. I’d been playing with POV-Ray and looking for a way to convert my LEGO scenes to Blender. I was unable to export SDL to a mesh. Loading up LeoCad, I discovered that I could export my models and import them into Blender. Before I knew it, I’d spent the night futzing around with shaders and modifies. The results weren’t half bad.

A little background.

As I’ve noted before, I started my modeling of LEGO bricks using POV-Ray. It is a script based language that uses shapes and math to represent objects. Precise and accurate, the models look great and LEGO bricks are simple shapes. The problem, though, is that POV-Ray's language doesn’t work well in other ray tracing programs.

For me, this generally wasn’t an issue. POV-Ray is a great ray tracing program and served me well for years. Yet, it seemed to fall behind at some point. Other 3D programs like Blender took a different approach, using mesh surfaces built with triangles. Their shading language was different as was their rendering engine. Blender produced realistic images using very different techniques.

Although POV-Ray could import these meshes, it wasn’t a modeling program. At its core, it was a ray-racing program with a wonderul scene dscription langugae. Math is king here, but you could do a lot with that math. As 3D lighting improved, POV-Ray kept up using radiosity. This allowed POV-Ray to simulating real world lighting with realistic shadows. Cycles, Blenders rendering system, did the same thing but was . The problem is that it is a pain in the ass to use.

The biggest problem with radiosity is artifacts. No matter what I do, I always seem to have a few. To fix the problem, you have to tweak various settings that tend to have effects on each other. It didn’t help that radiosity renders were very slow, making it difficult to get right. It was frustrating, even as I tried to improve my renders.

A more modern approach with Mecabricks.

With Mecabricks, I started to learn how to use Blender’s ray trace engine called Cycles. Using light probes, it could generate realistic images faster, with less artifacts. Yes, POV-Ray can use light probes as well, but the results weren’t the same. As a bonus, the rendering engine’s approach tended to fix aliasing issues.

Now, Blender isn’t perfect and I still struggle at times getting the lighting quite right. In general that wasn’t an issue. In practice, it is way easier to fix or back out of than POV-Ray. The render preview helped me tweak the scene in almost realtime. A better workflow emerged.

Yet, I still have all these old POV-Ray scenes and I still wanted to use them. I’ve been looking for ways to convert my bricks into Blender format and try things out. Sadly, that isn’t so easy. But one trick I’d landed on a few years back was using a program called LeoCAD.

Dealing with complex bricks in POV-Ray.

When I started down with LeoCAD, it was because I was using LDD to model my parts. Although fun to hand layout bricks in SDL, it can be a pain lining things up up. Using LDD to build my models, I could then import that model into LeoCAD and then export to POV-Ray. A bit of a convoluted flow, it worked well for me.

Another advantage was that it used modular parts, much like my library. I’d long ago converted my models to use millimeters and realistic brick measurements. This made it easy to swap out their parts with more realistic parts, such as those from LGEO. Or, even better, those from my own library.

Since SDL can be difficult for complex objects, it also allowed me to build on others work. For those pieces I hadn’t modeled, I could use the parts included in their libraries. It also made it easy to swap out materials, let me test different solutions. The results looked unique to me, but if only I could fix the render issues.

What’s old is new again.

Coming back to today, it clicked when I was thinking about that old workflow. I wondered if LeoCad could export in other formats? Loading it up on my MacBook—I still had it loaded—I found I could export LeoCAD creations to Wavefront objects. Blender can import those files by default. Testing with my Mini ZX81 model, the results looked decent. But the pieces were a bit blocky for my liking.

[Image]Mini ZX81 - v1 - LeoCAD by Steven Reid, on Flickr

Playing around with the import options, I figured out how to import individual parts. This allowed me apply modifiers and color changes to them. Starting with the round parts, I added a subdivision modifier to round them out. The lack of edges was a problem, is I added a bevel to a few parts. Looking at the render, I realized I missed a few parts that could use some love.

With that done, I started to clean up the colors and materials. This rabbit hole took a good part of the evening. For most of that time, I was researching priciple shader nodes and testing settings. They aren’t perfect, but good enough to get a decent render in. The results, below, aren’t half bad. Although not at the same level as what Stubs is doing with Mecabricks, but had fun learning.

[Image]Mini ZX81 - v2 - LeoCAD - v2 by Steven Reid, on Flickr

Where do we go from here?

To be honest, nowhere. I’m learning and trying things out. My existing workflow, using Mecabricks and Blender, is still a lot of fun. The results I get from Blender are great, and I keep trying to get close using POV-Ray. But now I have a few more tricks I can play with. I don’t know if this will yield value, but I have some ideas. Much like how I used LeoCAD to fill-in parts I didn’t have modeled, maybe I can do the same here?

Even if nothing comes of this, I still had a lot of fun getting here. I just wish I’d tried this sooner. Oh, and here is a final render using slightly different angles.

[Image]Mini ZX81 - v3 - LeoCad - v2b by Steven Reid, on Flickr



Comments on this article:

No comments so far.

Write a comment:

Type The Letters You See.
[captcha image][captcha image][captcha image][captcha image][captcha image][captcha image]
not case sensitive