User:Owen Burgoyne/POV-Ray Tutorial: Difference between revisions

From LDraw.org Wiki
Jump to navigation Jump to search
m (Added "WORK IN PROGRESS")
No edit summary
 
(29 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<div class="center" style="width:auto; margin-left:auto; margin-right:auto; color:#aa0000">'''WORK IN PROGRESS'''</div>
This tutorial is a <span style="color:#aa0000">'''WORK IN PROGRESS'''</span>.
<hr/>
[[File:Pyramid POV-Ray Radiosity Final.png|thumb|300px|James Jessiman's pyramid model, rendered in POV-Ray.]]
The purpose of this guide is to take an already-built [[LDraw]] model and then render it in [[POV-Ray]] to create a near-realistic image. The guide itself will not necessarily give you ''all'' the answers on how to create exactly what you want, but will hopefully get you started in the right direction and perhaps even lead you on to investigating and mastering certain rendering techniques.


The purpose of this guide is to take an already-built LDraw model and then render it in POV-Ray to create a near-realistic image. The guide itself will not necessarily give you ''all'' the answers on how to create exactly what you want, but will hopefully get you started in the right direction and perhaps even lead you on to investigating and mastering certain rendering techniques.
For the purposes of this tutorial, I will be using James Jessiman's pyramid model included with LDraw.


=Requirements=
==Requirements==
For the purposes of this guide I have used the following:
For the purposes of this guide I have used the following:


*[http://www.ldraw.org/ The LDraw library]
*The [[LDraw]] library
*[http://mlcad.lm-software.com/ MLCad 3.40]
*[[MLCad]] 3.40
*[http://ldview.sourceforge.net/ LDView 4.2 beta 1]
*[[LDView]] 4.2 beta 1
*[http://www.digitalbricks.org/ The LGEO library] and my own [https://dl.dropbox.com/u/59864198/LDraw/Other%20Files/LGEO-Update.zip LGEO Parts Pack] (zip file)
*[[LGEO]] parts library
*[http://www.povray.org/beta/ POV-Ray 3.7 RC6]
*[http://www.povray.org/beta/ POV-Ray 3.7 RC7]
* A plain text editor, such as Notepad


The first four can all be obtained directly from the [http://www.ldraw.org/downloads-2/downloads.html LDraw All-In-One-Installer] (AIOI), although my LGEO parts pack requires manual installation.
The first four can all be obtained directly from the [[LDraw All-In-One Installer]] (AIOI), although my LGEO parts pack requires manual installation.


The LDraw AIOI currently contains POV-Ray 3.6, but I recommend uninstalling this if you already have it and installing POV-Ray 3.7. Although still currently in beta, I have had no issues using it and it contains the ability to use more than one CPU, allowing for much faster rendering when using a multi-core system.
The LDraw AIOI currently contains POV-Ray 3.6, but I recommend uninstalling this if you already have it and installing POV-Ray 3.7. Although still currently in beta, I have had no issues using it and it contains the ability to use more than one CPU, allowing for much faster rendering when using a multi-core system.


=Installation and setup=
The guide also assumes that you are running the above on Windows. (I have no Mac or Linux experience, so would not able to advise on the correct file paths for installation.)
Although the AIOI can automate a lot of the installation, there are still a few tweaks that need to be made to the default installation to optimise the setup.
==The LGEO library==


==POV-Ray==
==Setting up LDView==
POV-Ray includes its own resolution definitions, which allows you to quickly set your desired image output size. These are accessed via a drop-down box shown at the top left of the window, but the available options are fairly limited.
 
[[LDView]], which is used to export the LDraw model to the POV-Ray format, automates a lot of things, although there are a few things worth taking into account.
 
===Image aspect ratio===
 
The first thing you may want to set is the aspect ratio of the final image. Once you have your model open within LDView, you can set LDView's display aspect ratio from the menu under '''View > Standard Sizes'''. Each view size shows the relevant aspect ratio that it conforms to in brackets. For the purposes of this tutorial, I'll be using '''1280 x 720 (16:9)''', the ratio used by a lot of modern monitors.
 
To ensure that this carries over to your render, you need to set a matching ratio in the LDView export window. You can do this by going to '''File > Export...''' and then the '''Options...''' button, and selecting the appropriate option under '''Aspect Ratio'''. You can also use '''Current LDView aspect ratio''', but need to ensure that you know what you used when selecting the image size within POV-Ray.
 
However, for this to work with a lot of wider aspect ratios you need the same aspect ratio available within POV-Ray, and this is explained under the "quickres.ini" entry below.
 
===Include files===
 
LDView gives you the ability to use "include" files within your POV-Ray file, in case there are settings you always use but are not default options within the file that LDView generates. This means you can set other values for things such as floor colour, background colour, etc.
 
An "include" can be saved to any location, and the file path can then be inserted into the relevant field.
 
Below is an example of the text that I use in the top include file:
 
<pre>// Floor settings
#declare LDXFloorR = 0.9; // Floor Red
#declare LDXFloorG = 0.9; // Floor Green
#declare LDXFloorB = 0.9; // Floor Blue
#declare LDXFloorAmb = 0; // Floor Ambient
#declare LDXFloorDif = 0.9; // Floor Diffuse
 
// Fog
#if (LDXFloor != 0)
fog {
  distance LDXRadius*100
  color rgb 1
}
#end</pre>
 
The '''Floor settings''' section automatically changes the floor variables to something I find works better, meaning I don't have to edit each file that LDView exports.
 
The '''Fog''' section creates a fogging effect in the background, which softens the horizon when the POV-Ray camera is pointing at a shallow angle.
 
==Setting up the LGEO library==
 
If you've installed the LGEO library from the AIOI to the default location, then it should be located at '''C:\Program Files\LDraw\LGEO'''.
 
Although updated by Lutz Uhlmann in 2008, there are still a few errors in the library, some of which are simply compatibility issues with any version of POV-Ray higher than 3.1. Where possible, I have fixed any files that I have come across, as well as create some new files, which can be found in the LGEO Parts Pack listed above.
 
The file itself mainly contains LGEO files (marked with '''lg_''' at the beginning of the file) which can simply be copied to LGEO's '''C:\Program Files\LDraw\LGEO\lg''' folder.
 
It also contains a file called '''LGEO.xml''' which must be copied to the LDView installation folder.
 
==Setting up POV-Ray==
 
===povray.ini===
To function properly with the LGEO library, POV-Ray needs to be told where to find the library files, and this is done via the '''povray.ini''' file. To edit this, within the POV-Ray menu go to '''Tools > Edit master POVRAY.INI'''. This will open the file as a text file, and give you some basic explanation on how to add or modify settings within this file.
 
You need to ensure that library paths are included in the file, pointing to the installation folder for LGEO. If using the AIOI, this is installed by default to the '''C:\Program Files\LDraw''' folder, so the following lines would need to be added to the end of the file:
 
<pre>Library_Path="C:\Program Files\LDraw\LGEO"
Library_Path="C:\Program Files\LDraw\LGEO\ar"
Library_Path="C:\Program Files\LDraw\LGEO\lg"</pre>
 
If you're using a 64-bit version of Windows, then you may need to change '''Program Files''' to '''Program Files (x86)'''.
 
===quickres.ini===
POV-Ray includes its own resolution definitions, stored in a file called '''quickres.ini''', which allows you to quickly set your desired image output size. These are accessed via a drop-down box shown at the top left of the POV-Ray window, but the available options are fairly limited.


To alter these settings, within the POV-Ray menu go to '''Tools > Edit resolution INI file''' and the file should then open up as a text file. You should see a number of different resolutions, mainly set to the 4:3 ratio (640x480, 800x600, etc.), along with [http://en.wikipedia.org/wiki/Spatial_anti-aliasing anti-alias] switches. For example:
To alter these settings, within the POV-Ray menu go to '''Tools > Edit resolution INI file''' and the file should then open up as a text file. You should see a number of different resolutions, mainly set to the 4:3 ratio (640x480, 800x600, etc.), along with [http://en.wikipedia.org/wiki/Spatial_anti-aliasing anti-alias] switches. For example:
Line 49: Line 113:
Height=450
Height=450
Antialias=Off</pre>
Antialias=Off</pre>
You can also specify further sizes by adding variations on the above, and add anti-aliasing to each resolution by changing '''Antialias=Off''' to:
<pre>Antialias=On
Antialias_Threshold=0.3</pre>
===Custom inserts===
POV-Ray includes the option to insert pre-defined parameters into a POV-Ray file, either from the main menu ('''Insert''') or by right-clicking the Editor window.
The purpose of setting these up for rendering LDraw models is to make it easier to insert often-used options, such as radiosity settings or HDRI lighting environments. By default, POV-Ray will store the "Inserts" folder here:
<pre>C:\Users\%USERNAME%\Documents\POV-Ray\v3.7\Insert Menu</pre>
==Exporting to POV-Ray==
==Rendering in POV-Ray==
==Gallery==
<gallery widths=300px heights=225px>
Pyramid LDView.png|James Jessiman's pyramid model, as shown in LDView.
Pyramid POV-Ray default.png|The pyramid rendered with POV-Ray's default settings.
Pyramid POV-Ray area lights.png|The pyramid rendered with POV-Ray's default settings, but with all lights set to area lights.
Pyramid POV-Ray Radiosity Fast.png|The pyramid rendered with POV-Ray using the Radiosity_Fast setting and one area light.
Pyramid POV-Ray Radiosity Normal.png|The pyramid rendered with POV-Ray using the Radiosity_Normal setting and one area light.
Pyramid POV-Ray Radiosity Final.png|The pyramid rendered in POV-Ray using a modified version of the Radiosity_Final setting and one area light.
</gallery>
<gallery widths=300px heights=225px caption="Supplemental images">
Pyramid POV-Ray with fog.png|The pyramid rendered in POV-Ray using a modified version of the Radiosity_Final setting and one area light. Fogging is used to soften the horizon.
Pyramid POV-Ray without fog.png|The pyramid rendered in POV-Ray using a modified version of the Radiosity_Final setting and one area light. No fogging is used, resulting in a sharp horizon.
Pyramid POV-Ray with reflective floor.png|The pyramid rendered in POV-Ray using a modified version of the Radiosity_Final setting and one area light. The floor here is given a reflective quality.
Pyramid POV-Ray transparency.png|The pyramid rendered in POV-Ray using a modified version of the Radiosity_Final setting and one area light. The floor has been switched off and background transparency has been enabled.
</gallery>
==See also==
*[[L3P]]
==Links==
*[http://www.digitalbricks.org/ Digitalbricks.org] - The official LGEO site
[[Category:POV-Ray]]

Latest revision as of 19:39, 27 March 2024

This tutorial is a WORK IN PROGRESS.


James Jessiman's pyramid model, rendered in POV-Ray.

The purpose of this guide is to take an already-built LDraw model and then render it in POV-Ray to create a near-realistic image. The guide itself will not necessarily give you all the answers on how to create exactly what you want, but will hopefully get you started in the right direction and perhaps even lead you on to investigating and mastering certain rendering techniques.

For the purposes of this tutorial, I will be using James Jessiman's pyramid model included with LDraw.

Requirements

For the purposes of this guide I have used the following:

The first four can all be obtained directly from the LDraw All-In-One Installer (AIOI), although my LGEO parts pack requires manual installation.

The LDraw AIOI currently contains POV-Ray 3.6, but I recommend uninstalling this if you already have it and installing POV-Ray 3.7. Although still currently in beta, I have had no issues using it and it contains the ability to use more than one CPU, allowing for much faster rendering when using a multi-core system.

The guide also assumes that you are running the above on Windows. (I have no Mac or Linux experience, so would not able to advise on the correct file paths for installation.)

Setting up LDView

LDView, which is used to export the LDraw model to the POV-Ray format, automates a lot of things, although there are a few things worth taking into account.

Image aspect ratio

The first thing you may want to set is the aspect ratio of the final image. Once you have your model open within LDView, you can set LDView's display aspect ratio from the menu under View > Standard Sizes. Each view size shows the relevant aspect ratio that it conforms to in brackets. For the purposes of this tutorial, I'll be using 1280 x 720 (16:9), the ratio used by a lot of modern monitors.

To ensure that this carries over to your render, you need to set a matching ratio in the LDView export window. You can do this by going to File > Export... and then the Options... button, and selecting the appropriate option under Aspect Ratio. You can also use Current LDView aspect ratio, but need to ensure that you know what you used when selecting the image size within POV-Ray.

However, for this to work with a lot of wider aspect ratios you need the same aspect ratio available within POV-Ray, and this is explained under the "quickres.ini" entry below.

Include files

LDView gives you the ability to use "include" files within your POV-Ray file, in case there are settings you always use but are not default options within the file that LDView generates. This means you can set other values for things such as floor colour, background colour, etc.

An "include" can be saved to any location, and the file path can then be inserted into the relevant field.

Below is an example of the text that I use in the top include file:

// Floor settings
#declare LDXFloorR = 0.9;	// Floor Red
#declare LDXFloorG = 0.9;	// Floor Green
#declare LDXFloorB = 0.9;	// Floor Blue
#declare LDXFloorAmb = 0;	// Floor Ambient
#declare LDXFloorDif = 0.9;	// Floor Diffuse

// Fog
#if (LDXFloor != 0)
fog {
  distance LDXRadius*100
  color rgb 1
}
#end

The Floor settings section automatically changes the floor variables to something I find works better, meaning I don't have to edit each file that LDView exports.

The Fog section creates a fogging effect in the background, which softens the horizon when the POV-Ray camera is pointing at a shallow angle.

Setting up the LGEO library

If you've installed the LGEO library from the AIOI to the default location, then it should be located at C:\Program Files\LDraw\LGEO.

Although updated by Lutz Uhlmann in 2008, there are still a few errors in the library, some of which are simply compatibility issues with any version of POV-Ray higher than 3.1. Where possible, I have fixed any files that I have come across, as well as create some new files, which can be found in the LGEO Parts Pack listed above.

The file itself mainly contains LGEO files (marked with lg_ at the beginning of the file) which can simply be copied to LGEO's C:\Program Files\LDraw\LGEO\lg folder.

It also contains a file called LGEO.xml which must be copied to the LDView installation folder.

Setting up POV-Ray

povray.ini

To function properly with the LGEO library, POV-Ray needs to be told where to find the library files, and this is done via the povray.ini file. To edit this, within the POV-Ray menu go to Tools > Edit master POVRAY.INI. This will open the file as a text file, and give you some basic explanation on how to add or modify settings within this file.

You need to ensure that library paths are included in the file, pointing to the installation folder for LGEO. If using the AIOI, this is installed by default to the C:\Program Files\LDraw folder, so the following lines would need to be added to the end of the file:

Library_Path="C:\Program Files\LDraw\LGEO"
Library_Path="C:\Program Files\LDraw\LGEO\ar"
Library_Path="C:\Program Files\LDraw\LGEO\lg"

If you're using a 64-bit version of Windows, then you may need to change Program Files to Program Files (x86).

quickres.ini

POV-Ray includes its own resolution definitions, stored in a file called quickres.ini, which allows you to quickly set your desired image output size. These are accessed via a drop-down box shown at the top left of the POV-Ray window, but the available options are fairly limited.

To alter these settings, within the POV-Ray menu go to Tools > Edit resolution INI file and the file should then open up as a text file. You should see a number of different resolutions, mainly set to the 4:3 ratio (640x480, 800x600, etc.), along with anti-alias switches. For example:

[800x600, No AA]
Width=800
Height=600
Antialias=Off

or

[800x600, AA 0.3]
Width=800
Height=600
Antialias=On
Antialias_Threshold=0.3

This rather limits the available ratios, such as 16:9 (widescreen) or 2.35:1 (anamorphic widescreen). Therefore you need to specify your own. To make it easier to pick out which aspect ratio I need, I often specify this in the preset, as in the below example:

[800x340 2.35:1, No AA]
Width=800
Height=340
Antialias=Off

[800x450 16:9, No AA]
Width=800
Height=450
Antialias=Off

You can also specify further sizes by adding variations on the above, and add anti-aliasing to each resolution by changing Antialias=Off to:

Antialias=On
Antialias_Threshold=0.3

Custom inserts

POV-Ray includes the option to insert pre-defined parameters into a POV-Ray file, either from the main menu (Insert) or by right-clicking the Editor window.

The purpose of setting these up for rendering LDraw models is to make it easier to insert often-used options, such as radiosity settings or HDRI lighting environments. By default, POV-Ray will store the "Inserts" folder here:

C:\Users\%USERNAME%\Documents\POV-Ray\v3.7\Insert Menu

Exporting to POV-Ray

Rendering in POV-Ray

Gallery

See also

Links