juraj3579 Posted May 7, 2013 Posted May 7, 2013 (edited) Hello everybody, 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) Usage: 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. Mesh Tools: 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 C. materials - 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. Material Tools: 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! 5. finish - 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. Edit 29.05.2013: Here are the links for the python scripts which I'm using in Blender. They were tested with the version 2.66 Import script: https://www.dropbox.com/s/q3hapud497xvktv/io_import_scene_lwo.py Lego Tools ver 1.0: - EDIT: I just realized, that make seam operator doesn't work properly Temporarily removed from operators panel https://www.dropbox....ools_ver_1_0.py Material Library: https://www.dropbox....ls_cycles.blend Next plans: 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) Known bugs: LDraw2Lws can't export the space crater plate correct (which is bad, because I have 2 Space Classic sets build already) Edited May 29, 2013 by juraj3579 Quote
Walter Kovacs Posted May 7, 2013 Posted May 7, 2013 If somebody is interested, I can upload the scripts, so you can try it yourself and maybe give me a feedback, if something is missing or not working well or if somebody has more ideas. Yes please. I can't wait to start playing around with it. Also, a question. Assuming you already have the model done in MLCad, SR 3D, etc., how long does it take from import to completed render? On average, as there are a lot of mitigating factors, obviously. I'm trying to get a feel for render times relative to POV-Ray, if that's possible. Quote
legolijntje Posted May 7, 2013 Posted May 7, 2013 Thanks Juraj3579 I've tried rendering LDraw models using Blender a long time ago.... It wasn't succesful at all, but probably because I had very few knowledge of LDraw and Blender Btw, I've made a topic for this, since it's not very useful if it's somewhere in the LDraw models topic. Quote
juraj3579 Posted May 8, 2013 Author Posted May 8, 2013 (edited) Thanks Juraj3579 I've tried rendering LDraw models using Blender a long time ago.... It wasn't succesful at all, but probably because I had very few knowledge of LDraw and Blender Btw, I've made a topic for this, since it's not very useful if it's somewhere in the LDraw models topic. Yes, the separate topic is much better , so we don't mix it with the models and can better follow the changes and ideas, which will hopefully come. I'm still on cleaning the script to make it publishable and I also added new feature for creating the seam between the parts automatically. I'll publish it in the end of the week. Edited May 8, 2013 by juraj3579 Quote
Calabar Posted May 24, 2013 Posted May 24, 2013 Is the guide completed? I see there are not images, some image could help, expecially inexperienced users. Inform me if/when the guide is complete, so I'll index it. Quote
juraj3579 Posted May 29, 2013 Author Posted May 29, 2013 Is the guide completed? I see there are not images, some image could help, expecially inexperienced users. Inform me if/when the guide is complete, so I'll index it. I've updated the whole guide and added some images. I think it's ready for indexing Quote
lego2lego Posted May 29, 2013 Posted May 29, 2013 Very nice guide, hope I can get my hands on a windows machine so I can experiment. I tried some alternatives on my mac to import LDraw into Blender but they didn't work out. Quote
Dadda-the-hutt Posted June 24, 2013 Posted June 24, 2013 Brilliant work! Ive seen your Flickr page too... very nice. I personally love the 'glossy'ness of the brick surfaces. I must learn blender a bit more i feel... all renders are coming out very noisy/spekled. Been trying to replicate your simple studio setup (image above the fireman). Are the black boxes some type of lighting? Keep up the good work... Quote
Dilvish Posted August 8, 2015 Posted August 8, 2015 (edited) How does the converter handle the model hierarchy? For instance, a model that has multiple sub-models. Or an MPD file. Or in my case a model that has multiple sub-models that are themselves MPD files. [edit] Okay, I just tested ldraw2lws and it does not seem to support MPD files. :( [edit] LDR Importer doesn't support MPD files either. Are there any Blender importers that do? Edited August 9, 2015 by Dilvish Quote
TotalyWicked Posted August 11, 2015 Posted August 11, 2015 Interesting. thanks for your guide I was going to mess around with LeoCad to .3ds to Blender, but then got lazy and never did it. Quote
juraj3579 Posted August 20, 2015 Author Posted August 20, 2015 How does the converter handle the model hierarchy? For instance, a model that has multiple sub-models. Or an MPD file. Or in my case a model that has multiple sub-models that are themselves MPD files. [edit] Okay, I just tested ldraw2lws and it does not seem to support MPD files. :( [edit] LDR Importer doesn't support MPD files either. Are there any Blender importers that do? Hi, you can open your mpd in mlcad and export the submodels (file->export). It will export all submodels as separate files where the main file contains all the submodels. Then, you need import only this file to blender using ldr importer. This worked well for smaller models. For bigger, complicated models: Open the mpd (make a copy of original) in LDCad and in main model: select all->reorganize->inline submodel(s). If you have submodels with submodels, you have to do it also for submodels and then in main model. Save the model. Open in mlcad, go to Multipart->Export Models, then again, you need to import just main file to blender. Quote
roland Posted August 20, 2015 Posted August 20, 2015 Open the mpd (make a copy of original) in LDCad and in main model: select all->reorganize->inline submodel(s). If you have submodels with submodels, you have to do it also for submodels and then in main model. Save the model. Open in mlcad, go to Multipart->Export Models, then again, you need to import just main file to blender. You could also open the top level file, put it in nested mode then select all and copy it to the clipboard (if asked don't let it move the main line or compensate for positional/rotational data etc). After that you can paste it in e.g. notepad and it will be all flat resulting in a single ldr no matter how many files / levels the original uses. You need to do this in LDCad 1.4b though as it's kinda broken in the 1.5 alpha's. Quote
kub0slaw Posted March 15, 2016 Posted March 15, 2016 Hi Juraj, I really like you guide it saves a lot of work but by any chance have you updated your Lego Tool script or could you maybe tell me what to edit in the script? I am asking because I was using it successfully till blender ver. 2.69 but from 2.70 and upwards it dose not work, to be more precise the Auto Replace tab gives me this report error: I know that I can install blender 2.69, import the model, save and then install 2.76 (the version which I am using now) but it is kind of annoying. Your help would be much appreciated Quote
juraj3579 Posted March 16, 2016 Author Posted March 16, 2016 (edited) Hi Juraj, I really like you guide it saves a lot of work but by any chance have you updated your Lego Tool script or could you maybe tell me what to edit in the script? I am asking because I was using it successfully till blender ver. 2.69 but from 2.70 and upwards it dose not work, to be more precise the Auto Replace tab gives me this report error: I know that I can install blender 2.69, import the model, save and then install 2.76 (the version which I am using now) but it is kind of annoying. Your help would be much appreciated Hi, I'm glad you like it. However, this approach comes from "dark ages" of importing (trying to import) LDraw models to Blender and is pretty nasty . Nowdays, the ldr-importer is surely better choise as it works quite good and is also well supported. If you really want, I can look at the script, but it will take some time, because a lot of things changed in Blender since 2.69. Edited March 16, 2016 by juraj3579 Quote
kub0slaw Posted March 16, 2016 Posted March 16, 2016 Thx for the quick replay , I am using Ldr importer as well, the thing is it dose not have that neat feature of auto replacing materials so there is quite some work when you have big technic model. Anyway for now I will stick with my method of switching between 2.69 and 2.76 - it is still faster then selecting parts and creating/ tweaking materials for them . Nowadays everyone is busy so please do not waste time for me Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.