On Monday, I decided to hack around with Blender a bit. Id 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, Id spent the night futzing around with shaders and modifies. The results werent half bad.
A little background.
As Ive 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 doesnt work well in other ray tracing programs.
For me, this generally wasnt 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 wasnt 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 didnt 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 Blenders 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 werent the same. As a bonus, the rendering engines approach tended to fix aliasing issues.
Now, Blender isnt perfect and I still struggle at times getting the lighting quite right. In general that wasnt 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. Ive been looking for ways to convert my bricks into Blender format and try things out. Sadly, that isnt so easy. But one trick Id 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. Id 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 hadnt 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.
Whats 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 MacBookI still had it loadedI 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.
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 arent perfect, but good enough to get a decent render in. The results, below, arent half bad. Although not at the same level as what Stubs is doing with Mecabricks, but had fun learning.
Where do we go from here?
To be honest, nowhere. Im 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 dont know if this will yield value, but I have some ideas. Much like how I used LeoCAD to fill-in parts I didnt 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 Id tried this sooner. Oh, and here is a final render using slightly different angles.