C3POwen

[Guide] Rendering LDraw models using POV-Ray

Recommended Posts

GUIDE UPDATE: I have updated the lg_color.inc file so that transparent neon colours do not appear so bright or washed out.

If you modified the lg_color.inc file does that mean that there is also a new LGEO.xml file that I need to download? I know you explained this to me already, but from what I understand, maybe I should read over it again, is that the changes on this file would not do anything unless I have a new LGEO.xml as well, right?

Share this post


Link to post
Share on other sites

If you modified the lg_color.inc file does that mean that there is also a new LGEO.xml file that I need to download? I know you explained this to me already, but from what I understand, maybe I should read over it again, is that the changes on this file would not do anything unless I have a new LGEO.xml as well, right?

As I've only modified some of the colour definitions, and not added any new ones, you don't need to download the LGEO.xml file again.

If you need to download a different version again, I'll make sure it's clear.

Share this post


Link to post
Share on other sites

Ah, thanks for explaining. I must have missed this the first time around. I have the feeling I will need to go back and render all my models again. :cry_sad:

Nah! I didn't really use many transparent neon colours. :sweet:

Edited by Palathadric

Share this post


Link to post
Share on other sites

For some reason piece 2539 gets rotated by 90 degrees on its X axis somewhere between LDView and POV-Ray. In LDView I still see it properly, but when I render the model it comes out the rotated, any idea why this is?

The LEGO logo on studs is rotated 90 degrees vs. in LDView; LDView uses the orientation from the LDraw file, and while that's likely to be correct, it's not guaranteed. There's no way in LGEO.xml to rotate the rest of the geometry of the part without rotating the studs.)

I know this was brought up last week, but it appears that the stud orientation is correct in the LGEO file, and incorrect in LDraw.

If it's of use, I've attached a zip file containing a corrected LDraw DAT file.

2539.zip

Edited by C3POwen

Share this post


Link to post
Share on other sites

So with this I won't need to change the rotation in POV-Ray, right?

Share this post


Link to post
Share on other sites

So with this I won't need to change the rotation in POV-Ray, right?

No. C3POwen just rotated the studs, not the rest of the part. Rotating the rest of the part would cause it to no longer match the official one, which would break any models using it. The LGEO part is wrong, so my posted LGEO.xml fix is still needed.

C3POwen's fix is only visible if you have stud logo textures enabled in LDView, or have a custom stud primitive that includes the "LEGO" text.

Share this post


Link to post
Share on other sites

So with this I won't need to change the rotation in POV-Ray, right?

No. C3POwen just rotated the studs, not the rest of the part. Rotating the rest of the part would cause it to no longer match the official one, which would break any models using it. The LGEO part is wrong, so my posted LGEO.xml fix is still needed.

The DAT file is for LDraw/LDView only and, like LDView Travis said, it only fixes the stud rotation.

If you want a fixed LGEO part, I have modified the default "lg_2539.inc" file to rotate the entire part by 90 degrees, so should now match the official part when exporting models directly from LDView to POV-Ray.

All you need to do is download the below file and save it to the "C:\Program Files\LDraw\LGEO\lg" folder (or wherever LGEO is installed), overwriting the previous version. This means you don't have to modify the LGEO.xml file, but if you reinstall LGEO, it will overwrite my modified version.

DOWNLOAD: lg_2539.inc

If it's useful, I can post any other "broken" LGEO files that I come across and am able to fix. The actual POV-Ray language it's written in is a bit beyond me, but I can often work out what needs to be changed to fix a file.

Share this post


Link to post
Share on other sites

So I just replace the .inc file and the renders should come out perfectly? And then the .dat file is so the bricks will look perfectly in LDraw, but it doesn't affect renders at all, I guess?

Yes, it probably would be great if there were any other files that need fix-ups. If I run into any errors, I will definitely let you know. :sweet: Thanks, again!

Share this post


Link to post
Share on other sites

GUIDE UPDATE: I have now added a section on radiosity, although there are as of yet no example images and some information needs to be added regarding floor settings.

I also plan on adding render time, and have added a note at the beginning of the tutorial in regards to this.

I'm also toying with changing the example model to something a bit more recent/complex. Suggestions welcome.

EDIT: I think I'm going to use the tipper from 4201 Loader and Tipper.

EDIT 2: I have also added some fixed and new LGEO parts to the guide.

Edited by C3POwen

Share this post


Link to post
Share on other sites

GUIDE UPDATE: I have added a zip file containing more new LGEO parts, as well as modified lg_color.inc and LGEO.xml files, alongside some simple instructions on how to install them.

Share this post


Link to post
Share on other sites

Great Work C3POwen.

Do you think the guide could be considered "complete" now, even if still a work in progress?

Share this post


Link to post
Share on other sites

Great Work C3POwen.

Do you think the guide could be considered "complete" now, even if still a work in progress?

Thanks, Calabar!

I would say it is pretty much complete. The only other thing that could be added is a section about HDR lighting, but I've yet to get this working to my satisfaction yet.

For those that are wondering what HDR lighting is, it involves creating a giant sphere around that model and mapping an image on to the sphere, and using this as part of the light source so that you get realistic-looking reflections.

The test renders that I've tried this with come out with colours that look too dark and washed out, and adding extra lights does not seem to help.

Share this post


Link to post
Share on other sites

Good work, C3POwen! This has been a fantastic guide!

Share this post


Link to post
Share on other sites

Okay everybody. Since I have a lot of work to do in my workplace, I have less time to render LEGO models, and adjust POV-Ray settings,so I will now post my render settings that I used. Use it, adjust it, enjoy it :)

PS: I usually copy these lines after camera settings, replace the original lights created by Ldraw. I rendered the model in 3200x2400 and then resize it with Photoshop bicubic option to 1600x1200.

//Radiosity
global_settings{
assumed_gamma  1.4
max_trace_level 10
radiosity
{
   pretrace_start 0.08
     pretrace_end   0.005
     count  800
     nearest_count 1
     error_bound 0.02
     recursion_limit 1
     low_error_factor 0.2
     gray_threshold 0
     minimum_reuse 0.015
     brightness 1.0
     adc_bailout 0.01/2
   }
}

//Light
light_source {
  <1.5*LDXRadius,-2*LDXRadius,-1.5*LDXRadius> + LDXCenter	
 color rgb .4	
  area_light 200, 200, 10, 10
  adaptive 1
  jitter
  circular
  orient
}

//HDRI lighting
sphere {
 <0,0,0>,10000          
 pigment {
   image_map { hdr "rnl_probe.hdr" once interpolate 2 map_type 7 }
 }
 finish { ambient 1 diffuse 0 }
 hollow
}

Edited by Calabar
Added "code" tag

Share this post


Link to post
Share on other sites

PS: I usually copy these lines after camera settings, replace the original lights created by Ldraw. I rendered the model in 3200x2400 and then resize it with Photoshop bicubic option to 1600x1200.

Note: you should be able to put this code into an include file, set that file as the top include in LDView's export settings, and then add the following to the include file to have LDView's generated lights be ignored:

#declare LDXSkipLight1 = 1;
#declare LDXSkipLight2 = 1;
#declare LDXSkipLight3 = 1;

Share this post


Link to post
Share on other sites

I usually copy these lines after camera settings, replace the original lights created by Ldraw. I rendered the model in 3200x2400 and then resize it with Photoshop bicubic option to 1600x1200.

// Radiosity
global_settings {
       assumed_gamma 1.4
}

I've been doing a bit of reading on the gamma of the lg_color.inc file, and it looks like it may need tweaking to be able to render at different gamma settings, but will add something later for those that need it.

Your settings are also almost identical to the Radiosity_Final macro included with POV-Ray, but with a few tweaks. I'll have to give them a go and see how they turn out!

Note: you should be able to put this code into an include file, set that file as the top include in LDView's export settings, and then add the following to the include file to have LDView's generated lights be ignored:

#declare LDXSkipLight1 = 1;
#declare LDXSkipLight2 = 1;
#declare LDXSkipLight3 = 1;

I think I'm going to add this to the guide, as it's a useful thing to use, rather than manually deleting the lights. Thanks, LDView Travis!

Share this post


Link to post
Share on other sites

Hey man , I have some troubles with POV-Ray ...

When I complete my model in MLCad , I convert it to .pov file & then ready to render it but ...

The trouble is : POV-Ray often render image in low-res : 320x240 ( although I set resolution to 1280x1024 - [1280x1024, AA 0.3] )

Low-res problem ?

Example-1.jpg

LDView :

Example-2-1.jpg

Hope you guys will help me , " I'm Noob " ...

Edited by FMP

Share this post


Link to post
Share on other sites

When I complete my model in MLCad , I convert it to .pov file & then ready to render it but ...

The trouble is : POV-Ray often render image in low-res : 320x240 ( although I set resolution to 1280x1024 - [1280x1024, AA 0.3] )

Have you checked the quickres.ini file to make sure that the resolution preset has not been altered to something else by accident?

You should be able to do this from Tools > Edit resolution INI file within POV-Ray.

[You may also want to resize the images you posted, so they stay within the 800x600 limit on Eurobricks.]

Share this post


Link to post
Share on other sites

Have you checked the quickres.ini file to make sure that the resolution preset has not been altered to something else by accident?

You should be able to do this from Tools > Edit resolution INI file within POV-Ray.

[You may also want to resize the images you posted, so they stay within the 800x600 limit on Eurobricks.]

@C3P - Thank for your reply ...

Can you explain more detail ? - I'm using default quickres.ini of POV-Ray

Sometimes POV-Ray render with nice result - " rarely " ( high-res ) & sometime it render with low-res ,I don't know why ?

I try to render your model with same result : :oh3:

6941Battrax.jpg

Edited by FMP

Share this post


Link to post
Share on other sites

Sometimes POV-Ray render with nice result - " rarely " ( high-res ) & sometime it render with low-res ,I don't know why ?

I try to render your model with same result :oh3:

Can you attach one of your *.pov files in a zip file, so I can see if there's anything odd going on in it? It looks like something isn't working properly in POV-Ray.

Looking at the file will help me determine if it's a declaration in the file that's causing a problem, or POV-Ray itself.

Could you also copy the details of the "Messages" pane into a text document (open the "Messages" tab, go to Edit > Copy Pane and then paste into a text file) and include that in the zip file as well?

Share this post


Link to post
Share on other sites

Can you attach one of your *.pov files in a zip file, so I can see if there's anything odd going on in it? It looks like something isn't working properly in POV-Ray.

Looking at the file will help me determine if it's a declaration in the file that's causing a problem, or POV-Ray itself.

Could you also copy the details of the "Messages" pane into a text document (open the "Messages" tab, go to Edit > Copy Pane and then paste into a text file) and include that in the zip file as well?

Thank for your help ... :thumbup:

This is my files : [199KB] - http://www.mediafire.com/download.php?1sl1b83rjb15gfj

Hope that you will reply soon ... :thumbup:

Share this post


Link to post
Share on other sites

Could you please supply a copy of the "Messages" window from AFTER you have run a render that has not rendered at the selected size.

Sorry man , my bad ... :thumbup:

" Render -> Edit Settings\Render -> INI File - Clear " & then " Render " ? This is your mean , right ?

This is 2nd message file : [Attachments File] - Message II.txt

Share this post


Link to post
Share on other sites

Looking at your file, POV-Ray is rendering the file at 320x240 -- look at the first line under Output Options:

Output Options
 Image resolution 320 by 240 (rows 1 to 240, columns 1 to 320).
 Output file: C:\Users\admin\Documents\6941 Battrax.bmp, 24 bpp (system format)
 Graphic display......On  (gamma: 2.2)
 Mosaic preview.......Off
 CPU usage histogram..Off
 Continued trace......Off

Can you go to Render > Edit Settings/Render and under INI File click on Browse and select the "quickres.ini" file. Now from the dropdown to the right of Section select the resolution you want to use (e.g. 1280x1024, No AA) and click on the Set but don't render button. This will close the window.

Now render the image and, if it does not render at a size higher than 320x240, can you please attach the subsequent "Messages" information.

Share this post


Link to post
Share on other sites

Looking at your file, POV-Ray is rendering the file at 320x240 -- look at the first line under Output Options:

Output Options
 Image resolution 320 by 240 (rows 1 to 240, columns 1 to 320).
 Output file: C:\Users\admin\Documents\6941 Battrax.bmp, 24 bpp (system format)
 Graphic display......On  (gamma: 2.2)
 Mosaic preview.......Off
 CPU usage histogram..Off
 Continued trace......Off

Can you go to Render > Edit Settings/Render and under INI File click on Browse and select the "quickres.ini" file. Now from the dropdown to the right of Section select the resolution you want to use (e.g. 1280x1024, No AA) and click on the Set but don't render button. This will close the window.

Now render the image and, if it does not render at a size higher than 320x240, can you please attach the subsequent "Messages" information.

Thank man but no change ??? ... :wacko:

This is the best " crazy " problem I have never met before ...

Message III : [Attachments File] - Message III.txt

Hey man, I have just known that there are more way to render " .ldraw " models ( by using : L3P + MLCAD + POV-Ray [Old] - MLCAD + LDView + POV-Ray [Your Way] - LEOCAD + Blender [3] - LEOCAD + MLCAD + Blender [4] )

Well , see you later ... :thumbup:

Edited by FMP

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.