Sign in to follow this  
aeralure

Little help on POVRay (Mac)?

Recommended Posts

I'm returning to Lego after 10+ years away and just restarting a physical collection. As such, I'm using LDD a fair bit. I'd really like to enter some contests and eventually share some builds, but at first due to a lack of physical bricks it would be digital imagery and LDD files mainly.

To make the imagery I'd like to do some rendering on my Mac. I realize this is already complicating my case slightly as it seems having a PC I'd be havng little to no issues at all. I'm a graphic designer, so I can usually navigate some (but not always all) technical issues and learning new software isn't a problem or a concern. I am stuck though on a couple points and wondering if I might ask for a bit of help or be pointed in the right direction? I have done a lot of searching this forum and Google in general and found my search results lacking. Most of it is topics saying "perform a search" or "go read this thread" and I'm just not finding a simple set of steps. Maybe it's not meant to be simple. ;)

I tried Bluerenderer, but I can't even launch it. There's no GUI, so I tried to doubleclick the .jar and launch it through Terminal to no avail. I really don't know what to do with it. Perhaps I can ask in the Bluerenderer thread.

I saw a recent post about LeoCAD, Blender and 3DSMax and that looks promising, but I don't have and can't afford 3DSMax right now.

A route that does seem plausible right now is POVRay on the Mac. I can't figure out how to convert my LDD files into something POVRay can see, but I can remake models in Bricksmith (tedious) and open them in LDView and then export them to POVRay. This is the furthest I have gotten so as tedious as it is to try and work with both LDD and Bricksmith maybe it's the best way to go? Here's where I am stuck at the moment though:

Once I get a model into POVRay if I hit Render I get this error:

Possible Parse Error: Cannot find file 'lg_defs.inc', even after trying to append file type extension.
"/[address to file]/Gelgoog.pov"
line 134
Parse Error: Cannot open include file lg_defs.inc.

Render failed

I can't find that file either anywhere in the directory or inside the application itself - or - the next file coming up 'lg_color.inc'

I see "Use Ini-file" in the Preferences pre-render with an option to choose it. I also see Set search paths for additional include files. I also have a couple LGEO files from another thread, but I don't know where to put them - or - if POVRay needs them. I don't see an LDraw directory anywhere. I read somewhere else about needing to edit the Ini-file, but edit... what?

Am I alone in this labyrinthine process seeming like semi-controlled madness? It's not exactly anywhere near as straightforward as it seems like it should be. Can't imagine why it's so complicated.

Anyway, am I even close? Can someone help me pass this hurdle?

Thanks if so lol.

Share this post


Link to post
Share on other sites

These files are not comming from PovRay. You will get them if you donwload the complete LGEO library you will find on the Ldraw All In One Installer.

Share this post


Link to post
Share on other sites

Thanks Darats. I know you are supplying and/or helping to update these files, as your name is on the .rar I have, so thanks much for that. Thing is:

As I am on a Mac, the All In One Istaller I have found doesn't work. It's for Windows. I do have an .rar I got from another thread on the board here, but when unpacked it is two directories - LGEO Parts and STL Parts - and I haven't any idea where to put them. Also, looking just now through this unpack, lg_defs.inc is indeed in there but lg_color.inc is not. Guess this is an improvement to my situation, but I haven't any idea what to do with this. Do I rename the 'LGEO - Darats folder' I ended up with to 'LDraw' and put it somewhere? And then somehow tell POVRay to look in that directory for the file? And then find lg_color.inc from somewhere and do the same?

Share this post


Link to post
Share on other sites

The LGEO package I gave on the Eurobricks forum is only an update. You will need the complete package which is not provided by me. If you can use Ldraw AIOI, maybe you can find it somewhere else.

Share this post


Link to post
Share on other sites

Thanks. I need a Mac-only solution as I haven't access to anything else, but I can possibly use the AIOI installer on my cousin's PC and copy some things over to a thumb drive. I'm not sure if just copying the LDRAW folder from that install is enough (does it install other items elsewhere too?) or where to then put those things on my Mac (or how to tell POVRay to use them - I assume edit an Ini file with directory paths?).

I suppose I'm going to give up trying to render on a Mac. I can't get anywhere. Thanks for the help though.

Edited by aeralure

Share this post


Link to post
Share on other sites

To tell PovRay where the LGEO files are, you need to edit "povray.ini" file and add : "Library_Path="C:\Lego" (as an example).

You can add as many library path as you would need PovRay to have access to.

I haven't find any place where you can still download the LGEO library. Seems like the only way to to get it is from the Ldraw AIOI. You will be able to get the entire LGEO library and then copy/paste it to your MAC.

Then you will be able to add my parts ("LGEO - Darats" package) manually as is it not yet in the AIOI.

Share this post


Link to post
Share on other sites

I went through all of this a few months back, it's quite straightforward to get a full setup but you have to know where to look...

You will need to do the following:

1) Download and extract the LDraw parts library (http://www.ldraw.org...test-parts.html)

->You'll want to download "complete.zip"

2) Open the folder "ldraw" and create a file called "MakeList.py". Copy into this text file the code shown in the spoiler tags:

# Short script to generate parts.lst for ldraw
# Author: NathanR
import os

Parts = []

# Open each LDraw .dat file and store filename and first line (part description)
for FileName in os.listdir("./parts"):
if FileName.endswith(".dat"):
	with open("./parts/" + FileName) as LDPartFile:

		# Read line, remove first 0, remove any intermeidate white space,
		# remove carriage return from string
		PartDescr = LDPartFile.readline()[1:].lstrip().replace("\n", "")
		#.lstrip().replace("\n", "")

		PartID	= "{:<18}".format(FileName)
		Parts.append([PartID, PartDescr])

# Sort by description, alphabetically
Parts.sort(lambda x, y: cmp(x[1], y[1]))

# Output the sorted list
with open('parts.lst', 'w') as f:
f.writelines( i[0] + i[1] + '\n' for i in Parts)

Using the Mac command line terminal, navigate to your ldraw folder and then type:

python MakeList.py

This will scan the "parts" directory and produce a text file listing every brick in the LDraw library.

3) Eurobricks member Lego2Lego very kindly put the LGeo parts library in his dropbox folder. It's still there, so download from this link:

https://www.dropbox....05lff6RHja?dl=0

Place the LGeo folder and the LGeo.xml in the "ldraw" folder

4) Download and install Bricksmith

http://bricksmith.sourceforge.net

On first run, you will have to tell it where the LDraw parts library is.

5) Download and install LDView:

http://ldview.sourceforge.net

Again, on first run you will have to tell it where the LDraw parts library is.

6) Download and install Mega Pov-Ray (Pov-Ray for the Mac):

http://megapov.ineta...t/download.html

7) Have some fun - build a Lego model in Lego Digital Designer.

Save it, then use File->Export Model and select Ldraw file (ldr)

8) Open the ldr file with bricksmith and check it exported correctly.

You may need to repair the model as the LDD export is not perfect - there are some types of brick it doesn't include in the output, or sometimes it can include bricks but put them in the wrong place.

9) Open the ldr file in the lDView program. Use the camera controls to select a nice angle or view, then click File->Export.

Next to the box saying "File Format: Pov-ray scene file" there is a button marked "options". Click the button and scroll down to "Native POV geometry"

Tick "Use xml mapping file"

Set "Path to XML Mapping file" as the LGeo.xml file you downloaded from Lego2Lego's dropbox

Save all options and export.

10) Open the POV-ray scene file using POV-ray, and select the "Files and Paths" tab.

Under "Set search Paths for additional include files" browse to your ldraw folder and select:

/some/folder/ldraw/lgeo/lg/

Play about with the render settings, keep it a small scene at first for a test preview, then click render!

And there you have it, high quality renders in 10 easy steps!

You've already done a lot of this, so it should be easy to get everything up and running.

Hope this helps!

Edited by NathanR

Share this post


Link to post
Share on other sites

There were some slight hurdles but with an outline of steps such as that no real problems. For the love of LEGO thank you! I never ever would have gotten a couple of those things right. I present disembodied (bright white! blinding :tongue: ) head of Gelgoog (my simple test from an old file that renders instantly):

Gelgoog.png

Some settings to sort out, figuring out how to place a background etc, but it works thanks to the both of you!

Here's a few follow-up things for the record if anyone else wanders this way, as well as a couple questions:

The MakeList.py NathanR listed above I used as-is and got a number of indentation errors when attempting the python command. I had to do some tinkering on a few lines tabbing indents and trying again each time I got an indent error until I got that right. Pretty easy.

I then got include errors of file not founds for 'colors.inc', 'math.inc', 'functions.inc' and then 'transforms.inc' on render attempt. I just improvived on colors.inc and copied 'lg_color.inc' and made a duplicate file called 'colors.inc' and placed it also in the lg folder. Worked (maybe? I had better check with the file found on the upcoming site link actually). For the others I was stumped for a minute but I used Google Fu and found this site https://github.com/P...ibution/include and made copies of the files needed from the repository there (they are 2 years old mostly so I don't know if they are current and I'm not sure why I needed them - rather why they weren't in the install I had). Once I did that, the second render worked. Note that the link to POVRay above seemed to be for an older PPC Mac build so I installed UberPOV and maybe this is why (?). Need to go back and look at versions.

Finally, a follow-up question:

Now I have an ldraw folder now and know where it is. :blush: I assume this where I manually add Darats' part updates mentioned above? I still need to do this? (thousand thanks to Darats for doing this and also helping me above!)

Turns out (as expected) 'lg_color.inc' is formatted a bit different than 'colors.inc' and has some additional data, so I changed 'colors.inc' but got an identical render. Will probably make a difference on other renders. This is the same render image as before, I just resized the one above in Photoshop, but this one uses the new 'colors.inc' file. I also had an accident with the scissors tool as you don't undo it as you would in Photoshop. Found a reset in settings.

Gelgoog_1.png

Guess now I need to work on settings and some Star Wars models. :laugh:

Edited by aeralure

Share this post


Link to post
Share on other sites

The MakeList.py NathanR listed above I used as-is and got a number of indentation errors when attempting the python command. I had to do some tinkering on a few lines tabbing indents and trying again each time I got an indent error until I got that right. Pretty easy.

Oops :blush: Sorry, the spoiler tags removed the leading white space on each line. I've just updated my post to correct this.

Note that the link to POVRay above seemed to be for an older PPC Mac build so I installed UberPOV and maybe this is why (?)

Maybe I ot the wrong link... MegaPovRay has had a fairly recent update, it's just a bit hard to find stuff on the site. Maybe try this link instead?

http://megapov.ineta.../index.html#Mac

(Can't actually find which exact version I have)

I then got include errors of file not founds for 'colors.inc', 'math.inc', 'functions.inc' and then 'transforms.inc' on render attempt.

Ah, maybe you need to specify another line in step 10 on my list.

Under "Set search Paths for additional include files" browse to:

Applications/POV-Ray3_7_Mac_Unofficial/include

I thought that got set by default, can you check if this works? You shouldn't be modifying the LGEO library the way you are.

Guess now I need to work on settings and some Star Wars models. :laugh:

What you do using the LDView Pov-ray file is turn off some of the lights, by adding the following commands at the top of the file:

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

Search for LDXSkipLight in the file and you'll see the light definitions, you can also modify them and reposition the lights to produce a better lit scene. If anyone knows of a better way to do this than simple trial and error, I'd be very interested :laugh:

Alternatively, if you've got a powerful computer, you can try the radiosity lighting effects, by placing this at the top of the POV file:

#version 3.7;

#include "rad_def.inc"

global_settings {
		 max_trace_level 10
		 radiosity {
						 Rad_Settings(Radiosity_Fast, on, off)
		 }
}

light_source { // X, Y, Z
		 <800, -170, 300>
		 color rgb 0.9
		 area_light 200, 200, 10, 10
		 jitter
}

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

It works by tracking photons from a light source as they repeatedly reflect off the surface of the mode, it can give much better results than the standard three lights but is very slow. Also, you need to carefully place your light source (again by trial and error). Change Radiosity_Fast to Radiosity_Final for the best quality results when you've finished setting everything else.

Edited by NathanR

Share this post


Link to post
Share on other sites

Oops :blush: Sorry, the spoiler tags removed the leading white space on each line. I've just updated my post to correct this.

No problem! It was an easy fix, but it's great to have that outline of steps as straightforward as possible for anyone else who may come along. :classic:

Maybe I ot the wrong link... MegaPovRay has had a fairly recent update, it's just a bit hard to find stuff on the site. Maybe try this link instead?

http://megapov.ineta.../index.html#Mac

(Can't actually find which exact version I have)

Yeah, this here is the one that works on Intel Macs and OSX 10.6+ which most people will have. I had UberPOV installed. I ran render tests and got identical results using each, so I'm now using this version instead despite keeping both for further testing.

Ah, maybe you need to specify another line in step 10 on my list.

Under "Set search Paths for additional include files" browse to:

Applications/POV-Ray3_7_Mac_Unofficial/include

I thought that got set by default, can you check if this works?

Works perfectly. Thanks!

You shouldn't be modifying the LGEO library the way you are.

Hahaha... Yeah, I thought my solution was... questionable, at best. :laugh:

What you do using the LDView Pov-ray file is turn off some of the lights, by adding the following commands at the top of the file:

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

Search for LDXSkipLight in the file and you'll see the light definitions, you can also modify them and reposition the lights to produce a better lit scene. If anyone knows of a better way to do this than simple trial and error, I'd be very interested :laugh:

Is it possible to use the 'Radiosity Load and Save' to append a definitions file? I tried making a file with the commands above and placing it there, but it did not work that way.

I placed the commands at the top of the POV file and I got a very dark head. There's some other lighting commands somewhere (?).

Gelgoog_2.png

Alternatively, if you've got a powerful computer, you can try the radiosity lighting effects, by placing this at the top of the POV file:

#version 3.7;

#include "rad_def.inc"

global_settings {
		 max_trace_level 10
		 radiosity {
						 Rad_Settings(Radiosity_Fast, on, off)
		 }
}

light_source { // X, Y, Z
		 <800, -170, 300>
		 color rgb 0.9
		 area_light 200, 200, 10, 10
		 jitter
}

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

It works by tracking photons from a light source as they repeatedly reflect off the surface of the mode, it can give much better results than the standard three lights but is very slow. Also, you need to carefully place your light source (again by trial and error). Change Radiosity_Fast to Radiosity_Final for the best quality results when you've finished setting everything else.

This yielded much better results for me. No longer instantaneous, but it didn't even take a minute. Maybe 15-20 seconds. Can see where it will take much longer on a larger file of course, but this is much better - except - the shadows are a bit too strong. Might need to tweak something. Is something up there controlling intensity? I'll tinker around some. Never thought I'd get this far. Thanks again!!

Gelgoog%20a.png

Share this post


Link to post
Share on other sites

First of all, welcome to eurobricks.

To know more about rendering you really should read C3POwen's excellent guide here

About Uberpov, it's an extension of povray, it's basically povray 3.7 with some added stuff. (only stumbled across it yesterday, haven't really looked into it). The GUI is the same as MACPOV and it renders the same (I checked) so you shouldn't worry about that.

Grtz

Share this post


Link to post
Share on other sites

First of all, welcome to eurobricks.

Thanks!

To know more about rendering you really should read C3POwen's excellent guide here

Now that NathanR and Darats were kind enough to help me get going and actually get it working I can read something like that and find it useful. I'm on it!

About Uberpov, it's an extension of povray, it's basically povray 3.7 with some added stuff. (only stumbled across it yesterday, haven't really looked into it). The GUI is the same as MACPOV and it renders the same (I checked) so you shouldn't worry about that.

Yeah, saw that in the description too. My basic rendering tests turned out the same for both, but I suppose for now I'll make UberPOV my default version of POV.

Share this post


Link to post
Share on other sites

Is it possible to use the 'Radiosity Load and Save' to append a definitions file?

Not sure - my personal preference is to just modify the POV scene file directly, it keeps everything together in a single file if you ever need to recreate the render.

I placed the commands at the top of the POV file and I got a very dark head. There's some other lighting commands somewhere (?).

Ah, that would be because you turned out all the lights! LDView exports the POV scene with just three lights, so by declaring "SkipLight" for lights 1 2 and 3 you create a scene with no illumination, and the only light comes from the low-level ambient light.

Can see where it will take much longer on a larger file of course, but this is much better - except - the shadows are a bit too strong. Might need to tweak something. Is something up there controlling intensity?

You can control the brightness of the light by modifying the parameter "color rgb 0.9", specifying 0.0 for pure black, 1.0 for pure white light, and any number in between for a range of greys. You can also (I think) use "color rgb <0.0 0.5, 0.4>" to create lights with custom colours according to the red, green and blue mix.

To change the intensity of the shadows, I can think of two options. Generally I just play about with where the light is placed - it seems to fall off in intensity with distance from the object. You can search the POV scene file for "#declare LDXCameraLoc" to get a feel for where the camera is placed, and then start adjusting your light source accordingly. I only do this by trial and error, and really wish I could find a better way of placing the lights. Alternatively, you can add a second light source at a different position, providing more illumination and softening the shadows on the ground. Again, this is trial and error and I've never explored this as I only have a macbook air and simple renders of models with ~100 bricks can take me 20 minutes ior more with a single light source.

Never thought I'd get this far. Thanks again!!

Always happy to help when I can!

Share this post


Link to post
Share on other sites

Now I have an ldraw folder now and know where it is. :blush: I assume this where I manually add Darats' part updates mentioned above? I still need to do this? (thousand thanks to Darats for doing this and also helping me above!)

You can add them and it will give you some new high quality parts that aren't in the original LGEO library.

Everything is explained on my thread.

Share this post


Link to post
Share on other sites

I know this thread is half a year old, but: many thanks for this!

I'd like to add: you can get povray from MacPorts (http://www.macports.org) and then simply render from the command line. The UI from UberPOV/MegaPOV kept crashing on my machine (Mac OS X 10.11.3).

These settings (that I found somewhere else here on this forum) work well for me:

povray +L/path/to/LGEO/lgeo/lg +W1920 +H1200 +A0.0 +J +R9 your_model.pov

All other dependencies are ok, so you only need the LGEO path.

I only had an issue with DX_48_slash_4_dash_4ri100_dot_dat_in_part, which apparently wasn't generated properly in the .pov by LDView. I can't figure out what part it was, since the render looks just fine:

800x419.jpg

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
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.