so here is a short tutorial of creating renders in Blender using Cycles - be sure you switch to Cycles, when you one new file in Blender! I used a simple 6611 Town Set as example.
1. create model (SR 3D Builder, MLCad, etc.):
- I prefer SR 3D Builder. I like the connection function, which makes the aligning of the bricks easy and the workflow is really fun.
2. export the model to lwo (Lightwave object):
- This is where I struggled a lot. There are some scripts, which imports ldraw files direct in Blender, but none of them works for me really. Then, I tried import obj files, which works quite good, however the mesh topology was bad and the logo on the studs was missing. Later I discovered the Lightwave exporter, which is available for download on the LDraw Webpage (LDraw2Lws). It has the possibility to replace ldraw parts with pre-created ones (in Lightwave format), which is really good feature, especially for the studs (they are available by default).
If you want use this exporter, read the readme file and be sure, to set the library paths correct. It uses *.dat file format, but you can open .l3b file directly.
3. import lwo objects to blender:
- The exporter creates a folder with all parts in lwo format in same directory as your model file. Blender can import them, however only one by one, which can be quite time consuming. So I modified the import script, that all the objects from the folder are imported at once.
- I use a simple studio setup in blender (there are a lot of tutorials, how to do it in Blender or just download some free blend files available) and import model to the separate layer in it.
A. modified import script
copy and overwrite the default lightwave import script in "your blender install path"\"blender version"\scripts\addons (Example: d:\Program Files\Blender Foundation\Blender\2.66\scripts\addons\) with the downloaded(See end of the post)
1. enable replaced addon (make a backup of the old one :-) ) in the blender user preferences
2. use file->import-> Lightwave (lwo) then select the directory with the parts (created with lw2ldraw application), select one file and click import -> all files from the directory will be imported (it could take some time, depending on the count of the parts)
3. you should see your imported model in blender
Basically it just do the import of the parts in a loop for all the files in the directory
4. working in blender:
A. lego tools script
A.1 download and save the Lego Tools script file on your pc. Also download the material library file.
A.2 open the script file with notepad or similar and on the line 23 set the correct path to the downloaded material library file (mine is "E:\Privat\Lego"). Save the file.
A.3 add the script in blender as any other addon. Go to user preferences in blender select addons -> install from file. Then search for lego tools and enable it by clicking on the checkbox
A.4 on the left panel (show/hide with T) in the main blender window you should see menu item "Lego Tools" with the operators (Mesh Tools, Material Tools)
B. mesh correction
- after import, the mesh looks not really pleasing. You need to recalculate the normals and also remove double vertices. Also, the 90 degree edges are too smooth now. The Edgesplit modifier solves this problem.
You can do the mesh operations only in edit mode, so this could be pretty time consuming again (selecting one object after another). So I wrote own add-on, which did the corrections on current selected objects with one click.
you can select your imported model or portion of it and use the operators. Be carefull with selection. The script runs on all selected object with type of MESH.
I use the operators in the same sequence as the buttons order. It's again just batch operation over all of the selected objects
- imported model has just simple diffuse shader material. The materials are named "Surface xxx" where xxx is the number of lego color. Because of import, Blender creates always new instance for the same material (eg. "Surface 0.001, Surface 0.002" and so on).
My plan was to auto-replace the materials with one from the lego material library for cycles, which I found on web. So the scripting again. First merge the materials, so it's always just one instance of the same material assigned to objects and then replace the materials with the
better ones from the library. Again, works only on selected objects.
to replace the materials which came with the import with the better ones from a library file (found on web) just select the objects, then click merge and then autoreplace.
The operator appends the library file (see A.1+A.2), and replaces the materials using a dictionary (in the script file from line 26). Not all colors are implemented yet!
- after all, I play a little bit with the lightning, position of camera and so on. Then render the model. Actually, you can do a lot of stuff later with compositor. I didn't use it till now, but it's on my "blender study plan", as it allows you to bring more realism to the finished picture.
So that's it. Maybe it looks a little bit complex, but in Blender it's actually only selecting the model and then 5 clicks to finish it. So, not big deal. Maybe the more time consuming part is to finish light and camera setup and rendering.
Feel free to try it yourself. Feedback and ideas for improvement are most welcome.
Here are the links for the python scripts which I'm using in Blender. They were tested with the version 2.66
Lego Tools ver 1.0:
my next topics (except building models) are to extend the color dictionary with more lego colors, try to create separate material for the slopes with the rough surface to push the renders more to reality and play with various ligthbox setups (I'll probably leave my space setup :-) and concentrate more on studio renders)
LDraw2Lws can't export the space crater plate correct (which is bad, because I have 2 Space Classic sets build already)
Edited by juraj3579, 29 May 2013 - 03:54 PM.