C3POwen

Eurobricks Citizen
  • Content Count

    426
  • Joined

  • Last visited

Everything posted by C3POwen

  1. I was asked to put together a tutorial on rendering LDraw-produced models in POV-Ray in as clear and simple a way as possible. Although the following might seem a bit lengthy, I have tried to keep it clear, which is what caused it require a lot of explanation. I plan on updating things and changing things as time goes on and as people give me their input, so as to create a useful guide for everyone here on Eurobricks. NOTE: To give an idea of how long these images can take to render, I will be adding the render time of each image to the tutorial. As I don't rely on POV-Ray's anti-aliasing, I have rendered each image at 2880x1620 with AA set to off, and then crop and resize the image afterwards. For computer spec comparisons, I use an Intel Core i5 running at 2.67 GHz, with 4GB of RAM running at 1333 MHz and an NVIDIA GeForce GTX 460 with 1GB of RAM. I'm also using POV-Ray 3.7, which can take advantage of more than one CPU core. Contents Introduction Requirements MLCad (including LSynth and SR 3D Builder) Special files LDView Setting up POV-Ray Rendering your model in POV-Ray (including lighting and effects) Downloads More information Version history 1. Introduction Unlike LEGO’s own Digital Designer (LDD), which can currently only output an image of exactly what you can see within the LDD window, LEGO models created using LDraw can be turned into high-quality and, in some cases, photo-realistic images. This brief tutorial covers some of the basics of converting files created in LDraw and other compatible programs into something that looks almost real. As an example throughout this guide, I will be using a model I made in MLCad of the tipper from 4201 Loader and Tipper, which can be found here. 2. Requirements Regarding operating system, I currently use Windows 7, so this tutorial will be written to mainly accommodate Windows users, and I shall assume you are using a 32-bit version of Windows with the default installation path for LDraw. For anyone using a 64-bit version, when referencing folder paths please use “C:\Program Files (x86)” instead of “C:\Program Files”. Firstly, if you do not have it installed already, you need to install the LDraw All-In-One Installer, which contains the following programs required for this tutorial: The LDraw parts library MLCad, used for building the models LSynth [optional], a system for building flexible parts within MLCad LDView, used for converting models into a POV-Ray file LGEO, a parts library built specifically for POV-Ray POV-Ray, a ray-tracer that can render 3D models in high-quality You can find the installer here: http://www.ldraw.org/ This will install everything within the "C:\Program Files\LDRAW" folder, although POV-Ray will get its own installation folder. More information on this installer can be found at http://www.holly-woo...w/aioi1-en.html At the moment, the installer seems to install POV-Ray 3.6, but if you're using a computer with multiple CPUs then it would be worth downloading and installing beta version 3.7, as this can make use of more than one CPU. This can be downloaded from http://www.povray.org/beta/ and is installed in the Program Files folder, but installs the "ini" and "include" files in your My Documents folder. Although it's still in beta, I've had no issues when using this to render images. 3. MLCad MLCad is a user-interface for the LDraw system, and makes it easier to create virtual LEGO models than hand-coding the location of each piece. It’s not as straight-forward to use as LEGO Digital Designer, but the parts list contains a greater number of “older” pieces, you ultimately have complete control over brick placement as LDD-style collision is ignored, and (if you’re feeling adventurous) you can even recreate LEGO elements yourself, if they have not been created already, and submit them to the LDraw parts lists. It is missing a number of more recent parts, but new elements are always being submitted and can be downloaded and installed fairly easily. There are many excellent tutorials on how to use MLCad, so I won’t cover that here. However, there are a few settings within MLCad that I use that you may find useful. Firstly, under Settings → General → Change... and then on the Step, Grid, Snap tab, I set the values as below: The coarse settings are left at MLCad’s default setting. The medium settings are changed to 1 unit per step, and the rotation angle is set to mimic the rotation of the new-style locking hinge pieces, which can be set at angles of 22.5 degrees. 11.25 degrees gives you slightly more freedom when using the old-style hinge pieces, but the correct angle is easily set for the locking hinges, which can be reproduced in sets of two rotations. Finally, the fine settings are set very low, so that I can accurately place items that have been rotated. Of course, if you find MLCad’s default settings enough, then they can be left as they are. I then set up the parts tree to something more useable, under Settings → Parts Tree → Tree Configuration…, although this can be quite time-consuming and if you accidentally reset the tree you cannot easily get the settings back, as the information is stored in your computer's registry. For ease of use, I have created a group file that automatically adds the values for you, an explanation of which is available in the “Downloads” section. 3.1. LSynth If this is installed alongside MLCad, it will allow you to render flexible elements, such as hoses, and store these within your LDR and MPD files. It has a bit of a learning curve (pun not intended), but once you’ve got the hang of it, it can really improve models that contain flexible parts. A modest example of what it can do can be found here in a Technic model that I’ve rendered. A good guide can also be found at http://www.holly-woo...utorial-en.html 3.2. SR 3D Builder A lot of people use SR 3D Builder as an alternative to MLCad, as it uses a system that is a little more like LDD. It uses a file format called L3B, which is essentially the LDraw format but with a bit more functionality. These files can also be opened within LDView, but certain special elements created within SR 3D Builder (such as rubber hoses) cannot be displayed using LDView, and therefore cannot be exported to POV-Ray for rendering. As far as I’m aware, SR 3D Builder does not recognise the LSynth library of parts. 4. Special files There are a few special files that are installed with the All-In-One installer which need some adjusting before rendering your model in POV-Ray. LGEO.xml This file contains all of the colour and element definitions for when LDView is exporting a model to the POV-Ray format. The default version is missing some colours, so I have created a more complete version, which can be found in 8. Downloads. Simply replace the default version with this one, and you will have more of LDraw’s colours available to render with. This needs to be saved to “C:\Program Files\LDRAW\LDView” lg_color.inc This file is installed into LGEO's program folder, in the "lg" sub-folder. It contains definitions to all of the colours of the bricks that POV-Ray uses, as well as information on element finish (transparency, reflection, etc.). The default one does not render accurate LEGO colours, so a replacement for this one can be found in 8. Downloads. This needs to be saved to "C:\Program Files\LDRAW\LGEO\lg" 5. LDView Once you have completed your model in MLCad, open LDView and locate the model file (either an LDR or MPD file, or L3B is you have used SR 3D Builder). Depending on how good your graphics card is, you should see a representation of your model that looks better than the one shown in MLCad. As LDView also displays the LEGO logo on element studs, you can use this to check to see if they are set to your desired rotation, as this will carry through to the POV-Ray render. Settings-wise, there is little that needs tweaking here, as it is mainly just for visual effect. However, you can set a better default angle, as LDView’s default is more top-down than the default one in MLCad, and when you export the model to POV-Ray, it will use the angle you currently have your model rotated to. Select View → Viewing Angles → Specify latitude/longitude, and enter your desired values. As I said, I like the default MLCad 3D angle, so I use latitude 23 and longitude 45, although latitude 30 works well with some long, low models, such as cars. Click OK and then go back to View → Viewing Angles and then click Save Current as Default. Now, when you open any model within LDView, it will always be initially displayed at this angle. The model I will be using as it appears within LDView: Render time: N/A 5.1. Exporting to a .pov file Now that you have your file open in LDView, click File → Export. This will bring up a dialog box which allows you to specify where you wish to save the exported file. It also has a button called Options..., which allows you to define various parameters. This is where you can set the aspect ratio for your render, and gives you some specific options: 5:4, 4:3, 3:2, 5:3, 16:9 and 2.35:1. I tend to go with 16:9, as that’s the ratio that modern widescreen TVs and monitors tend to use. It’s important that you remember which one you use, as you will need to set up another file in POV-Ray to account for this. There are a few other options to choose from here, and I use the ones shown below: Once you’ve chosen your settings, click OK and then from the Export window click Save. This will create a .pov file at your chosen location, using your chosen file name (by default this is the filename of the model you were looking at in LDView). 6. Setting up POV-Ray 6.1. Image resolution presets The first thing to set up is the file that contains the default resolution presets. If you are using POV-Ray 3.6, this will be located within the “C:\Program Files (x86)\POV-Ray for Windows v3.6\renderer” folder and will be called “quickres.ini”, and this cannot be edited from here, so you may need to copy the file to your desktop first and then open it from there. If you’re using POV-Ray 3.7, this can be edited within the program itself, as it stores it in you user area, so you can just open POV-Ray and select Tools → Edit resolution INI file. Open this file with a text editor and you should be able to see a list of screen resolutions, listed in this format: [1280x1024, AA 0.3] Width=1280 Height=1024 Antialias=On Antialias_Threshold=0.3 The first line is the name of the preset, and this is displayed in a drop-down box within POV-Ray. The following lines are the actual settings themselves. Copy and paste one of these settings to another location in this file, so we can create a new preset. You can leave both Antialias and Antialias_Threshold alone, as these are best left at default. If you wish to create an image that matches the aspect ratio set within LDView, this is where you set it. As I prefer to render in 16:9, then I need to make a width and height that matches this. So, for example, an image that is 1280 pixels in width must be 720 pixels in height, so you need to change this for your new preset, resulting in something like this: [1280x720 16:9, AA 0.3] Width=1280 Height=720 Antialias=On Antialias_Threshold=0.3 I add the 16:9 comment to the preset’s title, just to make it easier to see the ratio. If you’ve had to edit this from your desktop, then just copy it back to the original location. 6.2. POV-Ray INI file (3.7 only) This file is the one that contains the paths to the LGEO pieces that POV-Ray utilizes in rendering. If you’re using POV-Ray 3.6 it should already have the right paths in it. However, if you’ve manually installed the POV-Ray 3.7 beta, then it needs to be set up. Open POV-Ray and go to Tools → Edit master POVRAY.INI, and this should open the file within a text editor. At the bottom of the file, you need to insert three lines to ensure that POV-Ray can locate the right files. These are: Library_Path="C:\Program Files\LDraw\LGEO" Library_Path="C:\Program Files\LDraw\LGEO\ar" Library_Path="C:\Program Files\LDraw\LGEO\lg" Don’t forget that if you’re using a 64-bit operating system to make sure that the path uses "C:\Program Files (x86)".
  2. 21301 Birds [LEGO Ideas, 2015] MPD file I'm surprised this one hadn't been done sooner! I've just uploaded the printed tiles to the LDraw Parts Tracker, so they should be available soon.
  3. Although the Tauntaun still isn't available in LDD, it seems that the horns (and reins) now are! If you want to add these unofficial parts, I have uploaded them to Dropbox: 86057 Animal Tauntaun Horn Left 86058 Animal Tauntaun Horn Right 86059 Animal Tauntaun Rein with Bridle Make sure to install 86057 first, as 86058 simply mirrors 86057. You'll also be able to update the horns on your Wampa too:
  4. It does indeed appear to be this part. The problem is that LDView exports the torus used in this part as "48/LDX_48_slash_t08o5000_dot_dat_in_part", and it is the "48/" that is causing the problem. POV-Ray thinks you are trying to divide 48 by "LDX_48_slash_t08o5000_dot_dat_in_part", which is impossible! There are two work-arounds for this: Export the model from LDView with "Primitive Substitution" turned off. Keep "Primitive Substitution" turned on and modify the POV-Ray file. To turn off Primitive Substitution, open your model in LDView and do the following: Select "File > Export..." Click "Options..." Under "Geometry" untick "Primitive Substitution" Click "OK" Click "Save" to export your model Alternatively, to fix the problem within the POV-Ray file, do the following: Select "Search > Replace..." In the "Find" field type "48/LDX" (without quotes) In the "Replace with" field, type "LDX" (without quotes) Click "Replace All" Click "Save" Hopefully this will fix it for you! I would recommend using the first option, as you only have to remember to turn it off once, and it won't affect your renders too much.
  5. 31034 Future Flyer (Model A) [Creator, 2015] MPD file 31034 Future Flyer (Model B) [Creator, 2015] MPD file 31034 Future Flyer (Model C) [Creator, 2015] MPD file
  6. 40092 Reindeer / 40093 Snowman [seasonal, 2014] 40092 MPD file | 40093 LDR file
  7. Excellent! What parts did you get in?
  8. 31033 Vehicle Transporter (Model A) [Creator, 2015] MPD file 31033 Vehicle Transporter (Model B) [Creator, 2015] MPD file 31033 Vehicle Transporter (Model C) [Creator, 2015] MPD file I agree! I can't imagine how long it took you to build all of these and render them!
  9. 31032 Red Creatures (Model A) [Creator, 2015] MPD file 31032 Red Creatures (Model B) [Creator, 2015] MPD file 31032 Red Creatures (Model C) [Creator, 2015] MPD file Notes: - Updated with 92013 from the LDraw Parts Tracker.
  10. 31031 Rainforest Animals (Model A) [Creator, 2015] MPD file As per the set instructions, I have left the "poo" inside the parrot! 31031 Rainforest Animals (Model B) [Creator, 2015] MPD file 31031 Rainforest Animals (Model C) [Creator, 2015] MPD file
  11. 31030 Red Go-Kart (Model A) [Creator, 2015] MPD file 31030 Red Go-Kart (Model B) [Creator, 2015] MPD file 31030 Red Go-Kart (Model C) [Creator, 2015] MPD file The above set uses 18651, a new part for 2015 which I have uploaded to the LDraw Parts Tracker.
  12. 31029 Cargo Heli (Model A) [Creator, 2015] MPD file 31029 Cargo Heli (Model B) [Creator, 2015] MPD file 31029 Cargo Heli (Model C) [Creator, 2015] MPD file
  13. 31028 Sea Plane (Model A) [Creator, 2015] LDR file 31028 Sea Plane (Model B) [Creator, 2015] MPD file 31028 Sea Plane (Model C) [Creator, 2015] LDR file The above set uses 18649, a new part for 2015 which I have uploaded to the LDraw Parts Tracker.
  14. And so it begins... 31027 Blue Racer (Model A) [Creator, 2015] MPD file 31027 Blue Racer (Model B) [Creator, 2015] MPD file 31027 Blue Racer (Model C) [Creator, 2015] MPD file 31028 Sea Plane has a part new to 2015, so I'm putting that together in LDraw before my next post. Good suggestion! The Creator model only seems to be missing the dorsal spines.
  15. And so for the remaining models from 4506 Deep Sea Predators... 4506 Deep Sea Predators (Model F) [Creator, 2004] MPD file 4506 Deep Sea Predators (Model G) [Creator, 2004] MPD file 4506 Deep Sea Predators (Model H) [Creator, 2004] MPD file 4506 Deep Sea Predators (Model I) [Creator, 2004] MPD file If anyone has any idea what Model H is supposed to be (other than a very odd-looking flying fish) then I'd love to know!
  16. Having previously built the shark from 4506 Deep Sea Predators, I figured I should perhaps do the rest. So, for now, here are the first four of eight: 4506 Deep Sea Predators (Model A) [Creator, 2004] MPD file 4506 Deep Sea Predators (Model B) [Creator, 2004] MPD file 4506 Deep Sea Predators (Model C) [Creator, 2004] MPD file 4506 Deep Sea Predators (Model D) [Creator, 2004] MPD file And here's a bonus glow-in-the-dark version of Model D: I'm implementing a switch in LGEO that will allow any glow-in-the-dark parts to glow like this, which should be included in the next LGEO update.
  17. Certainly any part with irregular shapes could be a challenge using the standard Constructive Solid Geometry (CSG) method explained above @Darats creates his POV-Ray parts in a CAD application first before turning them into POV-Ray-compatible parts. He went into some detail about it here: [KEY TOPIC] Official Lego sets made in LDraw However, it appears that his parts are mesh-based (made up of polygons) rather than CSG, so I imagine that the more complex a part is the larger the file size will be (possibly going into multiple MB, rather than a few KB). The largest part file in the LGEO library is "6058 Cockpit 4 x 11 x 2.667" and that only runs to 99.4 KB. The bonus of creating them in CSG is that if I want to change one aspect of the entire library (how sharp the edges of a brick are, for instance) I can do that by changing one value in the definitions file. When running another render, all parts will then pick up the change. Here's an example where I've taken the part from the above examples and increased the roundness of the brick edges by a multiple of 10: If I leave the edges at this level, all other parts I render would also look bulbous (and quite possibly very odd)!
  18. 4998 Stegosaurus (Model A) [Creator, 2008] MPD file
  19. 7798 Stegosaurus [Creator, 2008] MPD file Currently working on this guy's big brother...
  20. I think someone asked this before, but I never got around to going into detail, so I've put together a very brief explanation of how it works below. POV-Ray shapes are based on geometric shapes (spheres, cylinders, boxes, etc.) that are defined based on X, Y and Z coordinates, unlike other 3D programs which create shapes using polygons. Therefore to create an LGEO part for POV-Ray I have to combine various shapes to get the desired result. This can make it difficult to create complex parts, but for your basic Lego brick it works like a charm. You can also set declarations and call them when placing your shapes. In the LGEO library, the height of a brick is set as follows: #declare LG_BRICK_HEIGHT = 0.96; This means that rather than setting the height of a regular brick as 0.96 or a double-height brick as 1.92, you can use LG_BRICK_HEIGHT or 2*LG_BRICK_HEIGHT. So, as an example, here's how I would construct the classic 2x2 brick: How to build a 2x2 LGEO brick in POV-Ray I start with the corners of the brick. As these are rounded I use tiny spheres, four at the bottom and four at the top: I then start connecting the spheres using cylinders: Once complete I have a nice wire-frame-effect box: Next I have to create the solid part of the box. For this I use three boxes set to slightly different sizes: When I combine these I get a nice solid box with rounded edges: Lego bricks aren't solid boxes, so I need to hollow it out underneath. For this POV-Ray has a "difference" function where you take a shape (such as the above box) and use another shape to cut away from the first one. For the Lego brick I need a box shape to create the main hollow, and four cylinders to create the holes you see underneath the studs: I then take the above shape and use that to hollow out the main box, creating four holes in the top and a hole in the bottom: Next up are the finishing touches. First I add the underside cylinder. The cylinder is pre-defined in a definitions file, so it's as simple as specifying "lg_brick_cylinder": I then add four studs to the top to get the final 2x2 brick. Again, the stud is a pre-defined part, so I can simply add four of them at the appropriate positions (although I use a macro for setting multiple studs): And we're done! You can add further details, but this is basically how LGEO parts are created. As time has gone on I've created various macros (such as one mentioned above) and tried to increase some details (like the small seams that show where the stud joins the brick), but the core of it is based on spheres, cylinders, boxes, etc. I hope that goes some way to explaining! BONUS: Here's what the above part looks like when it's been dissected down the middle:
  21. Thanks everyone! I've started looking at a few more parts to add to the collection (usually based on nothing more than what takes my interest) and have already finished one since the update a couple of days ago: (My version is the part on the right, and you might be able to make out the slight differences to the LDView-generated part on the left.) I also have a list of about 15-20 parts I started working on but never finished, so should probably get going on those!
  22. LGEO UPDATE: I have updated the LGEO-Update.zip file in the Downloads section with 6 new parts (the magnet counts as two!) and 3 fixed parts. The FIXED and NEW LGEO parts from the 2014-11-23 update It's been a while since my last update (over five months) and progress has been slow due to other interests taking up more time, but I certainly haven't abandoned LGEO and POV-Ray. There are more parts I'd like to implement, but my handle on POV-Ray's advanced maths functions is still not as good as I'd like.
  23. Thank you very much! And thank you to you too! Although yes, you have an administrator-level account, you still need elevated/specific rights to make changes to certain system folders, such as the "Program Files" folder. This wasn't an issue on XP, but was locked down by Microsoft on later operating systems, such as Windows 7 and 8. With the "Program Files" folder, I just grant my own account elevated permissions to the subfolders I need (such as the LDraw folder) for them to function properly, and leave the rest alone. This usually solves issues with legacy programs that think they're running on XP!
  24. Assuming that your LDraw installation is installed to the default location (C:\Program Files (x86)\LDRAW), I suspect that the files you're saving are being saved to the "VirtualStore" folder: %USERPROFILE%\AppData\Local\VirtualStore\Program Files (x86)\LDRAW This is what Windows uses when a program tries to write back to a folder contained within the "Program Files" folder, which is locked down by default. MLCad probably looks to its installation folder for its primary files, meaning it wouldn't show any of your updated files. You can get around this by altering the permissions of the "C:\Program Files (x86)\LDRAW" folder, giving yourself Modify permissions to this folder, which would resolve the issue of MLCad having to write any changes to the "VirtualStore" folder. Windows might warn against this, but it shouldn't cause too many issues if you're a responsible user.
  25. 1237 Asimo Robot [Technic, 2001] MPD file Links: Brickset | BrickLink